FDISKの使い方


/dev/sdcを例に取って

1.新たに装着したHDDにパーティッションを作成する。
# export LANG=C  (文字化けする場合このコマンドを打ってからFDISK)
# /sbin/fdisk dev/sdc

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

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p (基本領域 primary partitionで設定)
Partition number (1-4):1
First cylinder (1-2232, default 1) :1
Last cylinder or +size or +sizeM or +sizeK (1-2232, default 2232): 196 (シリンダ数での設定)

又は

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p  (基本領域 primary partitionで設定)
Partition number (1-4):1
First cylinder (1-2232, default 1) :1
Last cylinder or +size or +sizeM or +sizeK (1-2232, default 2232): +2000M (MBで設定)

上記の様にシリンダ数かMBでも設定できます。


Command (m for help):n
Command action
e extended
p primary partition (1-4)
e  (拡張領域 extendedで設定)
Partition number (1-4):2
First cylinder (197-2232, default 197) :197
Last cylinder or +size or +sizeM or +sizeK (1-2232, default 2232):2232

 通常、パーティッションは4つしか作成できません(primary partition)それを上回る設定を行う場合はextended(拡張パーティション)で設定します。
それ以降のパーティッションは5(論理パーティション)から始まります。(この場合sdc5、それ以降はsdc6〜)  
最大のパーティッションの数はIDE ディスク 63 個までSCSI ディスクは 15 までです。


extendedで設定すると次のパーティッションから若干表示が変わります。

Command (m for help):n
Command action
l logical (5 or over)
p primary partition(1-4)
l (論理領域 logical で設定)
First cylinder (197-2232, default 197): 197
Last cylinder or +size or +sizeM or +sizeK (197-2232, default 2232): 392

Command (m for help):n
Command action
l logical (5 or over)
p primary partition(1-4)
l   (論理領域 logical で設定)
First cylinder (197-2232, default 393): 393
Last cylinder or +size or +sizeM or +sizeK (393-2232, default 2232): 2232




2.パーティション・タイプを変更。初期値は"Linux native"(83)です。id 変更

Command (m for help): l ←設定可能なパーティション・タイプを表示する

0 Empty         17 Hidden HPFS/NTF  5c Priam Edisk     a6 OpenBSD
1 FAT12        18 AST Windows swa  6c SpeedStor      a7 NexXTSTEP
2 XENIX root      1b Hidden Win95 FA   63 GNU HURD or Sys b7 BSDI fs
3 XENIX usr      1c Hidden Win95 FA   64 Novell Netware   b8 BSDI swap 
4 FAT16 <32M    1e Hidden Win95 FA   65 Novell Netware   c1 DRDOS/sec (FAT-
5 Extended       24 NEC DOS       70 DiskSecure Mult  c4 DRDOS/sec (FAT-
6 FAT16        3c PartitionMagic    75 PC/IX         c6 DRDOS/sec (FAT-
7 HPFS/NTFS     40 Venix 80286     80 Old Minix       c7 Syrinx
8 AIX          41 PPC PReP Boot   81 Minix / old Lin    db CP/M / CTOS / .
9 AIX bootable     42 SFS           82 Linux swap      e1 DOS access
a OS/2 Boot Manag 4d QNX4.x         83 Linux          e3 DOS R/O
b Win95 FAT32    4e QNX4.x 2nd part   84 OS/2 hidden C:   e4 SpeedStor
c Win95 FAT32 (LB  4f QNX4.x 3nd part   85 Linux extended    eb BeOS fs
e Win95 FAT16 (LB  50 OnTrack DM     86 NTFS volume set   f1 SpeedStor
f Win95 Ext'd (LB   51 OnTrack DM6 Aux 87 NTFS volume set   f4 SpeedStor
10 OPUS        52 CP/M         93 Amoeba         f2 DOS secondary
11 Hidden FAT12   53 OnTrack DM6 Aux 94 Amoeba BBT     fd Linux raid auto
12 Compaq diagnost 54 OnTrackDM6     a0 IBM Thinkpad hi   fe LANstep
14 Hidden FAT16 <3 55 EZ-Drive       a5 BSD/386        ff BBT
16 Hidden FAT16    56 Golden Bow


Command (m for help): t ←パーティションのコードを変更する
Partition number (1-6):5
Hex code (type L to list codes) : 82     ←SWAP領域に設定

Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): fd     ←ソフトRAID領域に設定 
Changed system type of partition 1 to fd (Linux raid autodetect)




3.パーティション情報の確認。

Command (m for help): p

Disk /dev/sdc: 255 heads, 63 sectors, 2232 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 196 1574338+ fd Linux
/dev/sdc2 197 2232 16354170 5 Extended
/dev/sdc5 197 392 1574338+ fd Linux swap
/dev/sdc6 393 2232 14619118+ fd Linux raid autodetect

Command (m for help):




4.パーティッション情報書き込み

パーティッション情報をディスクに書き込む
Command (m for help): w           ←情報を書き込んで終了する
The partition table has been altered!

Calling ioctl() to re-read partition table.
SCSI device sdc: hdwr sector= 512 bytes. Sectors= 35861388 [17510 MB][17.5 GB]
Sdc: sdc1 sdc2 < sdc5 sdc6 >
SCSI device sdc: hdwr sector= 512 bytes. Sectors= 35861388 [17510 MB][17.5 GB]
Sdc: sdc1 sdc2 < sdc5 sdc6 >
Syncing disks

WARING: If you have created or modified any DOS 6.x
partitions, please see fdisk manual page for additional
information.
[root@**** /root]#_


5.パーティッション書き込みせず終了

パーティッション情報をディスクに書き込まず終了する。
Command (m for help): q         ←情報を書き込まないで終了




6.パーティッションを削除する。

パーティッション情報を削除する。
Command (m for help): d         ←情報を削除
Partition number (1-6): 2





コマンド

a ブートの可否を切り替えます
d パーティションを削除します
l 利用可能なパーティション・タイプを表示します
m メニュー(コマンド集)を表示します
n 新しいパーティションを作成します
o DOSパーティションを作成します
p パーティション情報を表示します
q 保存せずに終了します
t パーティション・タイプを変更します。初期値は"Linux native"(83)です id 変更
v パーティションを検査します
w パーティション情報を書き込み,終了します




デバイス対応表

ハードディスク デバイス名
IDE 一台目 /dev/hda
IDE 二台目 /dev/hdb
SCSI 一台目 /dev/sda
SCSI 二台目 /dev/sdb