fdisk -l
1
可以看到现在的分区情况如下
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
/dev/sda2 64 1306 9972736 8e Linux LVM
1
2
3
2
3
创建分区 sda3
fdisk /dev/sda
1
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
Partition number (1-4): 3 # 输入 3 表示sda3,因为前面已经有两个了
First cylinder (1306-4568, default 1306): # 回车,按默认值
Using default value 1306
Last cylinder, +cylinders or +size{K,M,G} (1306-4568, default 4568): # 回车,按默认值
Using default value 4568
Command (m for help): w # 输入 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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
再次查看分区情况
fdisk -l
1
可以看到现在的分区情况如下
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
/dev/sda2 64 1306 9972736 8e Linux LVM
/dev/sda3 1306 4568 26206700 83 Linux
1
2
3
4
2
3
4
重启操作系统
reboot
1
格式化新分区为 ext4
mkfs -t ext4 /dev/sda3
1
将物理硬盘分区初始化为物理卷,以便被 LVM 使用,输入指令
lvs
pvcreate /dev/sda3
1
2
2
向卷组中添加物理卷来增加卷组的容量
df -h
1
vgextend centos-root /dev/sda3
1
查看可扩展的空间大小
vgdisplay
1
其中 Free PE / Size 就是可供分配的自由空间,最多有 24.99G,在扩展时输入小于该值
扩充磁盘空间
lvextend -L+24G /dev/mapper/vg_test001-lv_root /dev/sda3
1
使用 resize2fs 指令来增大或者收缩未加载的“ext”文件系统的大小
resize2fs /dev/mapper/centos-root
1
如果是 xfs 文件系统
xfs_growfs /dev/mapper/centos-root
1