There is no way to reduce in XFS, so we remove completely the /home/ and give space to the root (/dev/centos/root)
backup the current user /home/msen/ files to copy paste later
we have home as 48G and root 50G. We need to get rid off home and increase root
$ df -h
Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 50G 1.2G 49G 3% / devtmpfs 911M 0 911M 0% /dev tmpfs 921M 0 921M 0% /dev/shm tmpfs 921M 17M 904M 2% /run tmpfs 921M 0 921M 0% /sys/fs/cgroup /dev/mapper/centos-home 48G 33M 48G 1% /home /dev/sda1 497M 147M 351M 30% /boot tmpfs 185M 0 185M 0% /run/user/1000
first connect as root and kill msen processes under /home
$ ssh -l root 10.10.1.22
$ lsof /home
$ kill -9 [process id]
then unmount home
$ umount /home/
let’s see the logical volumes
$ lvdisplay
--- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID L4JIDc-qv5u-M6r5-Cpl9-zFM8-M9NX-Cj8LFP LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-04-04 14:32:20 -0500 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/home LV Name home VG Name centos LV UUID ubV1VZ-RNcA-ZAfn-buod-2Taw-DvKL-XMTMfu LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-04-04 14:32:21 -0500 LV Status available # open 0 LV Size 47.45 GiB Current LE 12146 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID Vdym8t-rNd4-gfDy-9bGG-KIZI-6RXz-XMeccx LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-04-04 14:32:21 -0500 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
remove logical volume home
$ lvremove /dev/centos/home
Do you really want to remove active logical volume home? [y/n]: y
Logical volume “home” successfully removed
We have now 47.51G free space
$ vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz–n- 99.51g 47.51g
resize root partition
$ lvextend –size +47.50GB -r /dev/mapper/centos-root
let’s recheck the logical volume, there is no home and root is resized to 97.5 GB
$ lvdisplay
--- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID L4JIDc-qv5u-M6r5-Cpl9-zFM8-M9NX-Cj8LFP LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-04-04 14:32:20 -0500 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID Vdym8t-rNd4-gfDy-9bGG-KIZI-6RXz-XMeccx LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-04-04 14:32:21 -0500 LV Status available # open 1 LV Size 97.50 GiB Current LE 24960 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
finally remove cantos-home from fstab either manually or do it like here
$ sed -i ‘/centos-home/d’ /etc/fstab
let’s reboot
$ shutdown -r
backup the previous user /home/msen/ files under new created /home or signing again as root and re-create the new user from scratch
first delete the user and its corresponding folder and files
$ userdel -r msen
$ adduser msen
$ passwd msen
give sudo privileges
$ gpasswd -a msen wheel
now exit and relogin as msen
$ exit;
$ ssh -l msen 10.10.0.107
YEEYYYY!!!!