129 lines
9.5 KiB
Markdown
129 lines
9.5 KiB
Markdown
---
|
|
title: Linuxにおけるフォーマット
|
|
author: kazu634
|
|
date: 2009-04-25
|
|
wordtwit_post_info:
|
|
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4569;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
|
|
categories:
|
|
- linux
|
|
|
|
---
|
|
<div class="section">
|
|
<p>
|
|
Linuxでのフォーマットの仕方を忘れがちで何度もGoogleのお世話になっているので、ここでまとめておきます。
|
|
</p>
|
|
|
|
<h4>
|
|
パーティションの切り方
|
|
</h4>
|
|
|
|
<p>
|
|
fdiskコマンドを用います。
|
|
</p>
|
|
|
|
<pre class="syntax-highlight">
|
|
kazu634@srv634% df /media/disk <span class="synStatement">[</span><span class="synConstant">951</span><span class="synStatement">]</span>
|
|
Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
|
|
/dev/mapper/srv634-root
|
|
<span class="synConstant">329233</span> <span class="synConstant">138796</span> <span class="synConstant">173439</span> <span class="synConstant">45</span>% /
|
|
tmpfs <span class="synConstant">513816</span> <span class="synConstant"></span> <span class="synConstant">513816</span> <span class="synConstant"></span>% /lib/init/rw
|
|
udev <span class="synConstant">10240</span> <span class="synConstant">100</span> <span class="synConstant">10140</span> <span class="synConstant">1</span>% /dev
|
|
tmpfs <span class="synConstant">513816</span> <span class="synConstant"></span> <span class="synConstant">513816</span> <span class="synConstant"></span>% /dev/shm
|
|
/dev/sda1 <span class="synConstant">233335</span> <span class="synConstant">32653</span> <span class="synConstant">188234</span> <span class="synConstant">15</span>% /boot
|
|
/dev/mapper/srv634-home
|
|
<span class="synConstant">142568216</span> <span class="synConstant">294068</span> <span class="synConstant">135032012</span> <span class="synConstant">1</span>% /home
|
|
/dev/mapper/srv634-tmp
|
|
<span class="synConstant">376807</span> <span class="synConstant">10307</span> <span class="synConstant">347044</span> <span class="synConstant">3</span>% /tmp
|
|
/dev/mapper/srv634-usr
|
|
<span class="synConstant">4805760</span> <span class="synConstant">2526672</span> <span class="synConstant">2034968</span> <span class="synConstant">56</span>% /usr
|
|
/dev/mapper/srv634-var
|
|
<span class="synConstant">2882592</span> <span class="synConstant">1217136</span> <span class="synConstant">1519024</span> <span class="synConstant">45</span>% /var
|
|
/dev/sdb1 <span class="synConstant">964500</span> <span class="synConstant">17696</span> <span class="synConstant">897808</span> <span class="synConstant">2</span>% /var/backup_data
|
|
/dev/sdc1 <span class="synConstant">2010752</span> <span class="synConstant">265440</span> <span class="synConstant">1745312</span> <span class="synConstant">14</span>% /media/disk
|
|
kazu634@srv634% fdish /dev/sdc1 /media/disk <span class="synStatement">[</span><span class="synConstant">952</span><span class="synStatement">]</span>
|
|
zsh: command not found: fdish
|
|
kazu634@srv634% sudo fdisk /dev/sdc1 /media/disk <span class="synStatement">[</span><span class="synConstant">953</span><span class="synStatement">]</span>
|
|
<span class="synStatement">[</span>sudo<span class="synStatement">]</span> password <span class="synStatement">for</span> kazu634:
|
|
Command <span class="synStatement">(</span>m <span class="synStatement">for</span> <span class="synStatement">help</span>): m
|
|
Command action
|
|
a toggle a bootable flag
|
|
b edit bsd disklabel
|
|
c toggle the dos compatibility flag
|
|
d delete a partition
|
|
l list known partition types
|
|
m <span class="synStatement">print</span> this menu
|
|
n add a new partition
|
|
o create a new empty DOS partition table
|
|
p <span class="synStatement">print</span> the partition table
|
|
q quit without saving changes
|
|
s create a new empty Sun disklabel
|
|
t change a partition<span class="synStatement">'</span><span class="synConstant">s system id</span>
|
|
<span class="synConstant"> u change display/entry units</span>
|
|
<span class="synConstant"> v verify the partition table</span>
|
|
<span class="synConstant"> w write table to disk and exit</span>
|
|
<span class="synConstant"> x extra functionality (experts only)</span>
|
|
<span class="synConstant">Command (m for help): p</span>
|
|
<span class="synConstant">Disk /dev/sdc1: 2059 MB, 2059278848 bytes</span>
|
|
<span class="synConstant">64 heads, 62 sectors/track, 1013 cylinders</span>
|
|
<span class="synConstant">Units = cylinders of 3968 * 512 = 2031616 bytes</span>
|
|
<span class="synConstant">Disk identifier: 0x00000000</span>
|
|
<span class="synConstant"> Device Boot Start End Blocks Id System</span>
|
|
<span class="synConstant">Command (m for help): n</span>
|
|
<span class="synConstant">Command action</span>
|
|
<span class="synConstant"> e extended</span>
|
|
<span class="synConstant"> p primary partition (1-4)</span>
|
|
<span class="synConstant">p</span>
|
|
<span class="synConstant">Partition number (1-4): 1</span>
|
|
<span class="synConstant">First cylinder (1-1013, default 1): </span>
|
|
<span class="synConstant">Using default value 1</span>
|
|
<span class="synConstant">Last cylinder or +size or +sizeM or +sizeK (1-1013, default 1013): </span>
|
|
<span class="synConstant">Using default value 1013</span>
|
|
<span class="synConstant">Command (m for help): p</span>
|
|
<span class="synConstant">Disk /dev/sdc1: 2059 MB, 2059278848 bytes</span>
|
|
<span class="synConstant">64 heads, 62 sectors/track, 1013 cylinders</span>
|
|
<span class="synConstant">Units = cylinders of 3968 * 512 = 2031616 bytes</span>
|
|
<span class="synConstant">Disk identifier: 0x00000000</span>
|
|
<span class="synConstant"> Device Boot Start End Blocks Id System</span>
|
|
<span class="synConstant">/dev/sdc1p1 1 1013 2009761 83 Linux</span>
|
|
<span class="synConstant">Command (m for help): w</span>
|
|
<span class="synConstant">The partition table has been altered!</span>
|
|
<span class="synConstant">Calling ioctl() to re-read partition table.</span>
|
|
<span class="synConstant">WARNING: Re-reading the partition table failed with error 22: </span><span class="synSpecial">無効な引数です</span><span class="synConstant">.</span>
|
|
<span class="synConstant">The kernel still uses the old table.</span>
|
|
<span class="synConstant">The new table will be used at the next reboot.</span>
|
|
<span class="synConstant">Syncing disks.</span>
|
|
</pre>
|
|
|
|
<h4>
|
|
フォーマットの仕方
|
|
</h4>
|
|
|
|
<p>
|
|
mkfsコマンドを用います。
|
|
</p>
|
|
|
|
<pre class="syntax-highlight">
|
|
kazu634@srv634% sudo mkfs <span class="synSpecial">-t</span> ext3 /dev/sdc1 /media <span class="synStatement">[</span><span class="synConstant">959</span><span class="synStatement">]</span>
|
|
<span class="synStatement">[</span>sudo<span class="synStatement">]</span> password <span class="synStatement">for</span> kazu634:
|
|
mke2fs <span class="synConstant">1</span>.<span class="synConstant">41</span>.<span class="synConstant">3</span> <span class="synStatement">(</span><span class="synConstant">12</span>-Oct<span class="synConstant">-2008</span><span class="synStatement">)</span>
|
|
Filesystem <span class="synIdentifier">label</span>=
|
|
OS <span class="synStatement">type</span>: Linux
|
|
Block <span class="synIdentifier">size</span>=<span class="synConstant">4096</span> <span class="synStatement">(</span><span class="synIdentifier">log</span>=<span class="synConstant">2</span><span class="synStatement">)</span>
|
|
Fragment <span class="synIdentifier">size</span>=<span class="synConstant">4096</span> <span class="synStatement">(</span><span class="synIdentifier">log</span>=<span class="synConstant">2</span><span class="synStatement">)</span>
|
|
<span class="synConstant">125696</span> inodes, <span class="synConstant">502753</span> blocks
|
|
<span class="synConstant">25137</span> blocks <span class="synStatement">(</span><span class="synConstant">5</span>.<span class="synConstant">00</span>%<span class="synStatement">)</span> reserved <span class="synStatement">for</span> the super user
|
|
First data <span class="synIdentifier">block</span>=<span class="synConstant"></span>
|
|
Maximum filesystem <span class="synIdentifier">blocks</span>=<span class="synConstant">515899392</span>
|
|
<span class="synConstant">16</span> block groups
|
|
<span class="synConstant">32768</span> blocks per group, <span class="synConstant">32768</span> fragments per group
|
|
<span class="synConstant">7856</span> inodes per group
|
|
Superblock backups stored on blocks:
|
|
<span class="synConstant">32768</span>, <span class="synConstant">98304</span>, <span class="synConstant">163840</span>, <span class="synConstant">229376</span>, <span class="synConstant">294912</span>
|
|
Writing inode tables: done
|
|
Creating journal <span class="synStatement">(</span><span class="synConstant">8192</span> blocks<span class="synStatement">)</span>: done
|
|
Writing superblocks and filesystem accounting information: done
|
|
This filesystem will be automatically checked every <span class="synConstant">28</span> mounts or
|
|
<span class="synConstant">180</span> days, whichever comes first. Use tune2fs <span class="synStatement">-c</span> or <span class="synStatement">-i</span> to override.
|
|
</pre>
|
|
</div>
|