Hack 65. fdisk を使用したパーティショニング

サーバを新品のディスクにインストールした後、fdisk のようなツールを使用してパーティションを作成する必要があります。

次のものは 5 つの典型的なアクション(コマンド)です。fdisk 内で実行することができます。
o n - 新規パーティションを作成
o d - 既存パーティションを削除
o p - パーティションテーブルを表示
o w - パーティションテーブルに変更を書き込む。たとえばセーブする。
o q - fdisk ユーティリティを終了

パーティションの作成

次の例では、/dev/sda1 というプライマリパーティションを作成しました。

# fdisk /dev/sda 

Device contains neither a valid DOS partition table, 
nor Sun, SGI or OSF disklabel Building a new DOS disklabel. 
Changes will remain in memory only,
until you decide to write them. 
After that, of course, the previous content won't be recoverable.

The number of cylinders for this disk is set to 34893.
There is nothing wrong with that, but this is larger than 1024, 
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sda: 287.0 GB, 287005343744 bytes
255 heads, 63 sectors/track, 34893 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
    e extended
    p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-34893, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-34893, default 34893):
Using default value 34893

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

パーティションが正しく作成されたかを確認

# fdisk /dev/sda

The number of cylinders for this disk is set to 34893.
There is nothing wrong with that, but this is larger than 1024, 
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 287.0 GB, 287005343744 bytes
255 heads, 63 sectors/track, 34893 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 34893 280277991 83 Linux

Command (m for help): q