15

Hi I need to increase root partition space by reducing /home, in a Centos 6.6,my situation is this:

/dev/mapper/VolGroup-lv_root      50G   46G  1,6G  97% / 
tmpfs                            1,9G     0  1,9G   0% /dev/shm 
/dev/sda1                        477M   61M  391M  14% /boot 
/dev/mapper/VolGroup-lv_home     140G  3,9G  129G   3% /home

Is it possible?

17

It is not something I would do online but I think it is possible. I guess you are using ext4.

  1. umount /home

    $ umount /home
    
  2. shrink the /home filesystem

    $ fsck -f /dev/mapper/VolGroup-lv_home
    $ resize2fs /dev/mapper/VolGroup-lv_home 80G
    
  3. shrink the /home logical volume

    $ lvreduce -L -40G /dev/mapper/VolGroup-lv_home
    
  4. resize the /home partition to the size of the LV

    $ resize2fs /dev/mapper/VolGroup-lv_home
    
  5. extend the /root logical volume

    $ lvextend -L +40G /dev/mapper/VolGroup-lv_root
    
  6. extend the /root filesystem

    $ fsck -f /dev/mapper/VolGroup-lv_root
    $ resize2fs /dev/mapper/VolGroup-lv_root
    
  7. mount /home

    $ mount /home
    
| improve this answer | |
  • is there any chances to lose data of home? – Rahul Sharma Jun 25 '18 at 11:14
  • 1
    Worked fine for me. Only thing I couldn’t do was the fsck call in (6) because the volume was mounted. – orange Nov 7 '18 at 10:23
4

Jodka is right. Here is the procedure.

umount /home
e2fsck -f /dev/mapper/vg_oracle-lv_home
resize2fs /dev/mapper/vg_oracle-lv_home 20G
lvreduce -L 20G /dev/mapper/vg_oracle-lv_home
lvextend -l +100%FREE /dev/mapper/vg_oracle-lv_root
resize2fs /dev/mapper/vg_oracle-lv_root
mount /home

Ref. Online resize LVM partitions

| improve this answer | |
1

You cannot resize or change at all any partition on a storage device that is currently mounted. That means that your system needs to be shutdown if you intend to modify the root partition (since you cannot unmount it)

You will need to boot in an external OS (e.g. using a live-CD) to perform these tasks. I would recommend you to backup any sensible data before doing anything with the partitions.

| improve this answer | |
  • I don't think that's true. Don't you think my answer would work? – Jodka Lemon Jul 1 '15 at 23:02
  • It is generally true, or at least it is generally true if you want to do it safely. Normally tools do not allow to modify mounted partitions. I have done a little bit more research and found this in askubuntu: askubuntu.com/questions/24027/… So I take that ext4 is an exception to what I said and you can do it on the fly (and therefore, your answer should work) – dave_alcarin Jul 2 '15 at 6:48
  • What OP has is not traditional partitions, but LVM logical volumes, which are more flexible than partitions. A filesystem type that can be on-line resized is also going to be a requirement. Note that some filesystems, like XFS can be extended but not shrunk while it's mounted (in fact, currently shrinking an existing XFS filesystem is not supported at all). – telcoM Nov 12 '19 at 7:36
1

If you can use GUI, then with a help of system-config-lvm this can be made in an easy graphical way.

| improve this answer | |
0

This worked for me:

mount /home

fsck /dev/mapper/vg_kaps-lv_home

esfsck -f /dev/mapper/vg_kaps-lv_home

resize2fs /dev/mapper/vg_kaps-lv_home 100G

lvreduce -L 100G /dev/mapper/vg_kaps-lv_home


lvextend -L +200G /dev/mapper/vg_kaps-lv_root

resize2fs /dev/mapper/vg_kaps-lv_root

mount /home

Saved me alot of work hours

| improve this answer | |

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.