WeFixIT

shrink XFS partition

Below you find a description how to reduce a XFS partition. Important: This contains a full backup and restore of all data because XFS does not support shrinking.

Environment

  • Arch Linux (Kernel 5.15.82-1-lts)
  • XFS partition on LVM (vg_root/lv_home)

Workflow

  • Boot Arch Linux from an USB drive
  • Mount an USB disk for the backup data
    mount /dev/sdc1 /mnt/usb
  • Store the UUID
    blkid /dev/mapper/vg_root-lv_root > /mnt/usb/uuid
  • Install xfsdump
    pacman -Sy xfsdump
  • Mount the LV
    mkdir /mnt/vg_root-lv_home
    mount /dev/mapper/vg_root-lv_home /mnt/vg_root-lv_home
  • Make a backup
    xfsdump -l 0 -f /mnt/usb/vg_root-lv_home.xfsdump /mnt/vg_root-lv_home
  • umount /mnt/vg_root-lv_home
  • lvremove vg_root/lv_home
  • lvcreate –size 380GB –name lv_home vg_root
  • mkfs.xfs /dev/mappger/vg_root-lv_home
  • mount /dev/mapper/vg_root-lv_home /mnt/vg_root-lv_home
  • xfsrestore -f /mnt/usb/vg_root-lv_home.xfsdump /mnt/vg_root-lv_home
  • xfs_admin -U <UUID which you saved before into /mnt/usb/uuid> /mnt/vg_root-lv_home
  • reboot

Done. Now you have shrinked your XFS partition.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top