0

Is there any possible way to take space from centos-home and add it to centos-root or /dev/mapper/root? my storage details:

    Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                  95G     0   95G   0% /dev
tmpfs                     95G     0   95G   0% /dev/shm
tmpfs                     95G   19M   95G   1% /run
tmpfs                     95G     0   95G   0% /sys/fs/cgroup
/dev/mapper/centos-root   50G   16G   35G  32% /
/dev/sda1               1014M  194M  821M  20% /boot
/dev/mapper/centos-home  898G  356M  898G   1% /home
tmpfs                     19G     0   19G   0% /run/user/0
/dev/sdb1                 55T   18T   35T  35% /vod

1 Answer 1

1

First check what filesystem are you using on you /home logical volume (for example with lsblk -f. It it is XFS (which is default in CentOS) then there's nothing you can do, because XFS currently doesn't support shrinking. If you are using Ext4 (or other shrinkable filesystem), you can shrink your /home with

lvresize -L-50G --resizefs centos/home

(this will reduce size of your /home by 50 GB)

and then grow your root logical volume with

lvresize -L+50G --resizefs centos/root

Depending on the filesystem you are using you might need to do this from a LiveCD environment because resizing of mounted filesystems isn't usually fully supported (ext4 supports online growing but not shrinking for example).

As with all storage related operations, making a backup first is strongly recommended.

I see you are currently using only 356 MB from your /home so if it is XFS, you should be able to backup the data, remove the /home logical volume with lvremove centos/home and create new smaller logical volume and then grow the root logical volume. Or reformat the /home LV to ext4 and resize it. In both cases you'll need to update /etc/fstab because the /home LV is most likely referenced there by UUID.

You could also try converting the filesystem with fstransform. I have no experience with this tool and with /home being basically unused in your case, reformatting or recreating the LV will probably be easier and safer.

4
  • /home is indeed xfs, if i backup the home files then convert it from xfs to ext4 then make another partition out of it will that affect anything on my OS? thanks for replying Dec 17, 2021 at 19:05
  • i just need to add more storage for /root Dec 17, 2021 at 19:07
  • Yes, that is possible, I've updated my answer. Dec 18, 2021 at 6:41
  • I checked, my disk use LVM, does it support shriking centos-home then extending centos-root without data loss? I tried the command you sent and i got an error saying xfs shriking is unsupported, is there a way to shrink it and add to root? based on LVM. Dec 21, 2021 at 20:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .