来源:http://blog.51cto.com/hujizhou/1841367
场景:
虚拟机中有2块磁盘。
磁盘1:20G,默认安装操作系统,操作系统创建默认的LVM。
磁盘2:50G,安装完操作系统之后添加的,并手动创建了LVM。现需要将第2块磁盘从50G扩大至80G。
步骤:
1、将第2块磁盘在虚拟机设置中调整至80G
2、在linux系统中输入pvresize -v /dev/sdb 扩展PV容量,扩展完后可以用pvdisplay命令查看扩展是否生效。
// pvresize还可以收缩PV空间大小,如下:
EXAMPLES
Expand the PV on /dev/sda1 after enlarging the partition with fdisk:
pvresize /dev/sda1
Shrink the PV on /dev/sda1 prior to shrinking the partition with fdisk (ensure that the PV size is appropriate for your intended new partition size):
pvresize --setphysicalvolumesize 40G /dev/sda1
3、先用lvs命令查看下当前PV下的LV容量是多少,以便于判断操作后是否生效。
4、使用如下命令扩展LV
# lvextend -l +100%free /dev/testvg/testlv
5、再次使用lvs命令查看结果。
6、最后再用命令对文件系统更新容量。
resize2fs /dev/testvg/testlv