Linux fdisk Command
Linux fdisk is a program for creating and maintaining partition tables; it is compatible with DOS-type partition tables and BSD- or SUN-type disk labels.
Syntax
fdisk [必要参数][选择参数]
Required parameters:
- -l lists all partition tables
- -u used together with -l to display the number of partitions
Optional parameters:
- -s
specifies a partition - -v version information
Menu operation instructions
- m: display menu and help information
- a: toggle the active/bootable partition flag
- d: delete a partition
- l: display partition types
- n: create a new partition
- p: display partition information
- q: quit without saving
- t: set the partition ID
- v: verify the partition table
- w: save changes
- x: extended application, advanced features
Example
Display the current partition situation:
# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Display the partition information of each SCSI hard disk
# fdisk -lu
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 63 208844 104391 83 Linux
/dev/sda2 208845 20964824 10377990 8e Linux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk /dev/sdb doesn't contain a valid partition table
Linux Command Reference