Wednesday, January 25, 2012

LVM

How to reduce LVM Logical volume on production server.

While online enlarging is no problem, you have to umount for shrinking!

Code:
# umount /dev/vg_blah/lv_blah
Perform a check of the filesystem...
Code:
# e2fsck -f /dev/vg_blah/lv_blah
Resize the filesystem first.
Code:
# resize2fs /dev/vg_blah/lv_blah 9G
Then reduce the size of the logical volume.
Code:
# lvreduce -L -1G /dev/vg_blah/lv_blah
After that you can shrink down the volume group if desired.
Code:
# vgreduce vg_blah /dev/sdxy
Warning: It is crucial that you use the exact amount of space. If you reduce volume more than the filesytem you truncate the logical volume and you risk data loss!


Resize LVMs

  a. 'lvresize -L 6GB /dev/volgroupvar/logvolvar'
  b. 'resize2fs /dev/volgroupvar/logvolvar 6G'
  c. 'lvresize -L 4GB /dev/volgroupvar/logvolvar'
  d. 'resize2fs /dev/volgroupvar/logvolvar 4G'

Note: Reductions will likely return errors resulting in re-provisioning of the FS, LVM reduce should execute on run level 1/single user mode.




No comments:

Post a Comment