目次 >> ディスクの管理・設定
ここでは、Linuxのハードディスクに関する設定を中心に説明する。nfsに関しては、「NFS(Network File System)の設定」を参照。
接続されているハードディスクを調べるにはfdisk -lをrootで実行する。
# fdisk -l Disk /dev/sda: 41.2 GB, 41174138880 bytes 255 heads, 63 sectors/track, 5005 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xdffb2301 Device Boot Start End Blocks Id System /dev/sda1 1 5005 40202631 83 Linux Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00053c19 Device Boot Start End Blocks Id System /dev/sdb1 1 262 2104483+ 82 Linux swap / Solaris /dev/sdb2 * 263 8617 67111537+ 83 Linux /dev/sdb3 8618 121601 907543980 83 Linux Disk /dev/sdc: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x000568e1 Device Boot Start End Blocks Id System /dev/sdc1 1 262 2104483+ 82 Linux swap / Solaris /dev/sdc2 * 263 2873 20972857+ 83 Linux /dev/sdc3 2874 19457 133210980 83 Linux
GUI環境であるならば、gpartedが便利。
もしgpartedが使えないならば、コマンドラインからfdiskおよびmkfsを使ってフォーマットする。
まず、fdiskを使って、基本パーティションもしくは拡張パーティションを作成する。たとえば次のようになる。
# fdisk /dev/sdb Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-30401, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-30401, default 30401): Using default value 30401 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
そして、お好みのファイルシステムでフォーマットする。ここでは、ext4でフォーマットしている。
# # mkfs.ext4 /dev/sdc1 mke2fs 1.41.9 (22-Aug-2009) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 9773056 inodes, 39072080 blocks 1953604 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 1193 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
ext4でフォーマットする場合はmkfs.ext4であるがそれ以外にも、mkfs mkfs.ext2 mkfs.minix mkfs.reiserfs mkfs.bfs mkfs.ext3 mkfs.msdos mkfs.vfat mkfs.cramfs mkfs.ext4 mkfs.ntfs といったコマンドが存在する。
なお、増設した場合、これを実際に使うには、マウントする必要がある。
# mkdir /bak # mount -t ext3 /dev/sdb1 /bak
ここでは、ルートディレクトリにbakというディレクトリを作成して、 /dev/sdb1をマウントしている。
起動時に自動的にマウントするには、/etc/fstabを書き換える。
ディスクをマウントするには、mountコマンドを使う。
# mount /dev/sda1 /mnt/hoge
単にmountと打つと、システムのマウント状況を知ることができる。
ディスクをアンマウントするにはumountコマンドを使う。
# umount /mnt/hoge
もしdevice is busyというエラーが表示されるときは、fuserコマンドでどのプロセスが使用中かを調べることができる。
# fuser -muv /mnt/hoge/ Cannot stat file /home/foo/.gvfs: Permission denied USER PID ACCESS COMMAND /mnt/hoge: root 28203 ..c.. (root)bash
最終更新日