Resize an existing LVM partition and add the space to another LVM partition

lvmpartition

I'd like to resize an existing LVM partition and add the space to another LVM partition.

[root@dckapstaging ~]# df -h
Filesystem                           Size  Used Avail Use% Mounted on
/dev/mapper/vg_dckapstaging-lv_root   50G   50G     0 100% /
tmpfs                                3.9G     0  3.9G   0% /dev/shm
/dev/sda1                            485M   91M  369M  20% /boot
/dev/mapper/vg_dckapstaging-lv_home  215G   93G  111G  46% /home

I want /dev/mapper/vg_dckapstaging-lv_root to be extended to another 15 GB from /dev/mapper/vg_dckapstaging-lv_home; how can I do it?

Best Answer

Assuming your volume group is already full, and you cannot extend it further, you will need to:

  1. Shrink the filesystem in lv_home using the specific tools for your filesystem, e.g. resize2fs if you use ext3/4.
  2. Resize lv_home accordingly with lvreduce.
  3. Increase lv_root with lvresize.
  4. Increase the filesystem in lv_root so that it uses all the additional space in the LV.

As always, back up your data first, resizing filesystems is always a risky business.

If you happen to use XFS in lv_home you'll need to use a different approach, because XFS does not support shrinking. In this case:

  1. backup the data in lv_home
  2. reduce lv_home with lvreduce (FS is destroyed at this point!)
  3. recreate the filesystem in lv_home with smaller size
  4. restore the data
  5. increase lv_root as per steps 3 & 4 above.
Related Question