1

I have /homemountpoint (Type=LVM). how can I reduce/home` from 418G to 200G and use remaining disk space for guest(KVM) Node? because XFS can not be shrunk ().

localhost home]$ lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
nvme0n1         259:0    0   477G  0 disk 
├─nvme0n1p1     259:1    0   200M  0 part /boot/efi
├─nvme0n1p2     259:2    0     1G  0 part /boot
└─nvme0n1p3     259:3    0 475.8G  0 part 
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0   7.8G  0 lvm  [SWAP]
  └─centos-home 253:2    0   418G  0 lvm  /home

/dev/mapper/centos-home xfs 418G 24G 394G 6% /home

AAserver
  • 11
  • 2

1 Answers1

0

Unfortunately you are out of luck. XFS can't be reduced directly. And as you do not have free space in LVM you can follow the next way:

  1. Add new disk with size >24GB, 30 will be fine.
  2. Partition this new disk, one partition is enough
  3. Create filesystem on this partition
  4. Mount this partition somewhere (not under /home!)
  5. Login directly as root user and logout all other sessions
  6. Stop any daemon which run from /home
  7. Copy all the info from /home to the new filesystem
  8. Unmount /home
  9. Destroy /home LV
  10. Create new LV (for /home). This time allocate only 30-40GB as you can extend it on the fly
  11. Create filesystem on this LV
  12. Mount this LV and make appropriate changes in /etc/fstab
  13. Copy back all the information to this new LV.
  14. Check all the coppied files and if all is OK unmount the partition from point 2 and remove this new disk
Romeo Ninov
  • 3,195
  • 2
  • 13
  • 16
  • The 1st step states that "Add new disk with size >24GB, 30 will be fine." Can the new disk can be external USB drive? – AAserver Nov 28 '19 at 08:29
  • Yes, this disk is just a place for backup. If you used it before you can skip the steps 2 and 3. And will be wise not to use NTFS filesystem (for backup) – Romeo Ninov Nov 28 '19 at 08:34
  • "Step 7: Copy all the info from /home to the new filesystem" I am scared of. I have Oracle database install with many files on /home. I read few conversations/posts but none are complete explaining "cp -aR" OR "rsync" command . How do I be sure Copying all files including their names starting from . and .. ; dependancies will copy absolutely everything and work after copying back to the new shrunk /home? Thanks a lot Romeo. – AAserver Nov 28 '19 at 20:39
  • For Oracle RDBMS will be much better to export the database and forget about the installation files (you can download and install it later). For copy you can use `cp -RP` to copy recursively and preserve permissions. – Romeo Ninov Nov 28 '19 at 20:46
  • But why do not create dedicated directory in `/home` and then create softlink of this directory to the place where KVM keep disk files? – Romeo Ninov Nov 28 '19 at 20:48