0)fdisk /dev/sda进入交互式命令行
1)显示当前分区
p
2)创建新分区
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (524-60801, default 524):
Using default value 524
Last cylinder, +cylinders or +size{K,M,G} (524-60801, default 60801): +20G
Command (m for help): p
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x000b52a5
Device Boot Start End Blocks Id System
/dev/sda1 1 523 4200966 83 Linux
/dev/sda2 524 3135 20980890 83 Linux
//写入分区表,这一步不能少,否则分区表不会被修改!
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
3)刷新分区表
partprobe或系统重启
[root@ihost ~]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (设备或资源忙). As a result, it may not reflect all of your changes until after reboot.
[root@ihost ~]# reboot
Broadcast message from root@ihost.test.com
(/dev/pts/0) at 11:00 ...
The system is going down for reboot NOW!