#fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x2dfa2374.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').
Command (m for help): n //使用命令n新建分区
Command action
e extended
p primary partition (1-4)
p //按照提示输入p新建一个主分区
Partition number (1-4): 1 //选择分区号
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261): +1G //分区大小
Command (m for help): w //写入分区结果并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
4.3.2.3 删除分区
#fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').
Command (m for help): p //查看现在的分区情况
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2dfa2374
Device Boot Start End Blocks Id System
/dev/sdb1 1 132 1060258+ 83 Linux
/dev/sdb2 133 197 522112+ 83 Linux
Command (m for help): d //删除分区
Partition number (1-4): 2 //选择分区号
Command (m for help): p //再次查看分区情况,是否已删除
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2dfa2374
Device Boot Start End Blocks Id System
/dev/sdb1 1 132 1060258+ 83 Linux
Command (m for help): w //写入分区结果并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.