March 21, 2018

How to extend/reduce volume group and logical volume

vgextend volume group

❑ How to extend/reduce the volume group.
❍ vgextend [VG name] [PV path] : Extend the capacity by adding PV(Physical Volume) to the VG(Volume Group).
* e.g. vgextend vg0 /dev/sdb1
❍ vgreduce [VG name] [PV path] : Reduce the capacity by removing PV from the volume 
* If data is in PV, you should move the data to another location with "pvmove [PV path]".
❍ vgdisplay : Check the VG size has changed.


❑ How to extend/reduce the logical volume.
❍ lvextend -L [Capacity] [LV path] -r : Extend the capacity of LV to [Capacity].
lvextend -L +2G /dev/vg0/lv01 -r : Current capacity + 2 GB
* lvextend -L 4G /dev/vg0/lv01 -r : Change capacity to 4 GB
* If you do not use the "-r" option, the file system is not expanded and can cause problems(The results of "lsblk" and "df -Th" look different).
* If you didn't really using the "-r" option, you can extend the file system with the xfs_growfs (xfs), resize2fs (ext4) commands.
❍ lvreduce -L [Capacity] [LV path] -r : Reduce the capacity of LV์˜ to [Capacity].
lvreduce -L 100M /dev/vg0/lv01 -r
* The xfs file system does not support LV reducing.