$ fdisk /dev/sda
Welcome to fdisk(util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p #查看以分区数量(存在两个sda1和sda2)
Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bc5e0
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
Command (m for help): n # 新增一个分区
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p # 分区类型为主分区
Partition number (3,4, default 3): 3 #因为已经存在两个分区,所以分区号为3
First sector (41943040-83886079, default 41943040):
Using default value 41943040
Last sector, +sectors or +size{K,M,G}(41943040-83886079, default 83886079):
Using default value 83886079
Partition 3 of type Linux and of size 20 GiB is set
Command (m for help): t #修改分区类型
Partition number (1-3, default 3): 3 #分区号
Hex code (type L to list all codes): 8e #分区类型为8e
Changed type of partition 'XENIX usr' to 'Linux LVM'
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: Device or resource busy.
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.
$ reboot# 分区后需要重启
一、背景zstack创建的centos7虚拟机磁盘不足,加载磁盘后进行扩容。二、步骤1.查看当前磁盘情况,找到新挂载的磁盘,此处为/dev/sdafdisk -l2.新增磁盘分区$ fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you d...