Saturday, May 1, 2021

Shrink XFS partition, simply possible ?

 

My colleague asking me how to resize/shrink his CentOs 7 /home partition which is 240 GB to 160 GB and then allocate the remaining free space to / (root). Well, actually we can't directly shrink XFS therefore what we can do is backup all the data on /home, delete it and then recreate the /home, here is what todo :

1. Backup the contents of /home

tar -czvf /data/home.tgz -C /home .

2. Test Backup

tar -tvf /data/home.tgz

3. Unmount home

umount /dev/mapper/cl-home

4. Remove the home logical volume

lvremove /dev/mapper/cl-home

5. Recreate logical volume for /home, format and mount it

lvcreate -L 160GB -n home cl

mkfs.xfs /dev/mapper/cl-home

mount /dev/mapper/cl-home /home

6. Extend /root 

lvextend -r -l +100%FREE /dev/mapper/cl-root

7. Restore /home

tar -xzvf /data/home.tgz -C /home

8. Check /etc/fstab for any mapping of /home volume and ensure the file system type.

cat /etc/fstab

10. Ensure things already on their places.

$ lvdisplay

$ fdisk -l

$ mount -l 

$ df -h 

 

 

 

 

        

No comments:

40 Hadist Seputar Keluarga Samawa (Bagian 3)

 ﷽ Ustadz Yusuf Abu Ubaidah As-Sidawi hafizahullohuta'ala Masjid Al-Aziz  Jl. Soekarno Hatta No. 662 Bandung Hadist 11 : Doa Orangtua Bu...