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?


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.
  • 2
    For ext2/ext3/ext4, lv_home needs to be unmounted before shrinking. Enlarging the volume can be done while it's mounted. – Gilles Jul 13 '15 at 23:00

First off, you want to unmount the partitions in question. Boot an usb stick or similar. Backing up important data is always recommended before fiddling with filesystems.

Reduce the filesystem first in /dev/mapper/vg_dckapstaging-lv_home. Otherwise, resizing the lv will drop the data. The way to do it depends naturally from filesystem. resize2fs works for ext2/3/4 filesystems. resize2fs /dev/mapper/vg_dckapstaging-lv_home 200G

After you've shrunken the filesystem, run lvresize -L -15G /dev/mapper/vg_dckapstaging-lv_home to free up the 15GBs and lvresize -L +15G /dev/mapper/vg_dckapstaging-lv_root to enlargen the lv_root

Finalize with your fs resize tool. For ext that'd be resize2fs /dev/mapper/vg_dckapstaging-lv_root to enlarge it to maximum available space.

EDIT:corrected a typo: partition -> filesystem

  • resize2fs before lvresize ? (just a question, I never did it). BTW there is a typo 200G instead of 20G. – Archemar Jul 13 '15 at 9:41
  • @Archemar resize2fs first because lvresize doesn't check whether reduced part contains data i.e. it's filesystem agnostic. resize2fs (or filesystem equivalent) does. 200G isn't a typo, resize2fs takes new size instead of relative size. Or my version does, at any rate. 215G - 15G = 200G – WhimsicalWombat Jul 13 '15 at 9:46
  • @WhimsicalWombat resize2fs /dev/mapper/vg_dckapstaging-lv_home 200G doesnt work after unmount gives resize2fs invalid new size – Danny Jul 13 '15 at 13:36
  • @Danny That's weird. You're using ext2/3/4 filesystem, right? Check your resize2fs manpage to be certain that your version accepts the G-suffix. If that's not it then... I don't know. Sounds like a syntax error but the command you wrote seems to be ok. Double check for typos I guess. – WhimsicalWombat Jul 13 '15 at 14:46
  • When shrinking, you need to shrink the filesystem before the volume. But when enlarging, you need to enlarge the volume before the filesystem. – Gilles Jul 13 '15 at 23:01

This is a risky operation

  1. you should try to clean / (have a look at /var/log /var/spool and delete old and big file)

  2. theorical way to proceed include

    fsck -F /dev/mapper/vg_dckapstaging-lv_home
    lvresize --size -15G /dev/mapper/vg_dckapstaging-lv_home
    resize2fs /home
    lvresize --size +15G /dev/mapper/vg_dckapstaging-lv_root
    resize2fs /
  3. Disclaimer

    3.1. be sure to have a valid backup !!

    3.2. If this is a production system, please do try to test it before.

  • There's a big problem with your commands: with lv_home, you're shrinking the container before shrinking the content! That will break the content. Also the argument to resize2fs must be the volume names, not directories (and you need to unmount before shrinking). – Gilles Jul 13 '15 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.