Site Tools


server:shrinking_xfs

https://serverfault.com/questions/861522/centos7-xfs-lmv-cloning-on-smaller-device

Just to take a note on what I've done. Just to take a note:

1) fdisk /dev/sdb and do:

  create a new empty DOS partition table
  add a new partition, 1 for boot like sda1, id 83 and same start and end
  add a new partition, 2 for LVM, id 8e and of 135G, less than sda2 as i need to reduce
  toggle a bootable flag on partition 1

2) mount -o remount,ro /boot

3) dd if=/dev/sda1 of=/dev/sdb1

4) reboot

5) chroot my root

  mount /dev/centos/root /mnt/root/
  mount /dev/sdb1 /mnt/root/boot/
  mount --bind /dev/ /mnt/root/dev/ && mount --bind /dev/pts && mount --bind /proc/ && mount --bind /sys /mnt/root/sys
  chroot /mnt/root/

6) install bootloader

  grub2-install /dev/sdb
  grub2-install --recheck /dev/sdb
  grub2-mkconfig -o /boot/grub2/grub.cfg

7) shutdown

8) swap the drive

9) verify all is running fine

  I'm currently using boot from sda (new drive) and root from sdb (old drive)

10) pvcreate /dev/sda2

11) vgextend centos /dev/sda2

12) pvmove -n swap /dev/sdb2 /dev/sda2

13) pvmove -n root /dev/sdb2 /dev/sda2

14) yum install xfsdump

15) lvcreate –size 80G –name new_home centos /dev/sda2

16) mkfs.xfs /dev/centos/new_home

17) mount /dev/centos/new_home /mnt/root/

18) xfsdump -J - /home | xfsrestore -J - /mnt/root/

19) verify same Selinux labels

  ls -Z /home/
  ls -Z /mnt/root/

20) umount /mnt/root/

21) lvrename /dev/centos/home /dev/centos/old_home

22) lvrename /dev/centos/new_home /dev/centos/home

23) mount /home/

  Got error unmounting home but mounting home I guess the new has ran fine

24) reboot, all is running fine

25) lvremove /dev/centos/old_home

26) vgreduce centos /dev/sdb2

27) pvremove /dev/sdb2

28) shutdown & disconnects sdb

Finish.

server/shrinking_xfs.txt · Last modified: (external edit)