一、步骤:
1、创建新的分区,并修改分区类型为8e
2、创建物理卷PV
3、将新建的PV添加到要扩展的VG中
4、用命令lvextend或lvresize来将新加入的PE添加到要扩展的LV中
5、用命令resize2fs扩展文件系统
二、命令
1、新硬盘创建PV
#pvcreate /dev/sdb3
dev_is_mpath: failed to get device for 18:02
Physical volume "/dev/sdb3" successfully created
2、扩展VG
#vgextend testvg /dev/sdb3
Volume group "testvg" successfully extended
3、扩展LV
#lvextend -L 10G /dev/testvg/testlv //L参数是扩展到10G,dev/testvg/testlv这个事testlv的路劲,可 //用lvdisplay testlv查看
Extending logical volume testlv to 10.00 GiB
Logical volume testlv successfully resized
4、扩展文件系统
#resize2fs /dev/testvg/testlv
resize2fs 1.41.12 (17-May-2014)
Filesystem at /dev/testvg/testlv is mounted on /mnt/lvm; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/testvg/testlv to 3407872 (4k) blocks.
The filesystem on /dev/testvg/testlv is now 3407872 blocks long.
===================================================================
一、步骤
1、先卸载文件系统,然后强制执行检测e2fsck -f,缩减逻辑卷一定要先离线
2、然后确定要移除的物理卷的大小,有多少个PE。然后用命令resize2fs缩减文件系统大小,然后重新挂载逻辑卷
3、用命令lvreduce或者lvresize缩减指定个数的PE, 也可以计算出相应的大小来缩减
4、LV缩减之后,通过命令pvdisplay查看,指定要移除的PV,如果要移除的PV有PE在用,用pvmove转移PE到空闲的 PV
二、命令
1、卸载文件系统
#umount /mnt/lvm
2、强制检测文件系统
#e2fsck -f /dev/testvg/testlv
e2fsck 1.41.12 (17-May-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
3、缩减文件系统
#resize2fs /dev/testvg/testlv 9.7G
resize2fs 1.41.12 (17-May-2014)
resize2fs: Invalid new size: 9.7G
4、查看要移除的PV是否有PE被占用
#pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name testvg
PV Size 3.01 GiB / not usable 2.75 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 770
Free PE 519
Allocated PE 251
PV UUID xNUWFa-1FdZ-Ctkj-rvJp-dACa-FnJw-mJf6Sc
--- Physical volume ---
PV Name /dev/sdb3
VG Name testvg
PV Size 1.01 GiB / not usable 3.41 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 258
Free PE 258
Allocated PE 0
PV UUID 8esNBR-k4zM-sQW6-Z71N-hKBX-0YlT-Egb1o5
可以看出/dev/sdb1有251个PE被分配,而/dev/sdb3的258个PE都是空闲的,所以通过pvmove命令来转移被分配的PE到/dev/sdb3
#pvmove /dev/sdb1 /dev/sdb3
/dev/sdb1: Moved: 0.0%
/dev/sdb1: Moved: 31.5%
/dev/sdb1: Moved: 74.5%
/dev/sdb1: Moved: 100.0%
5、将sdb1从testvg中移除
#vgreduce testvg /dev/sdb1
Removed "/dev/sdb1" from volume group "testvg"
6、移除PV
#pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped
原文:http://www.cnblogs.com/gdou123czh/p/3875592.html