Cloning a CentOS 7 Disk to Reduce it’s size

Assuming you are cloning from /dev/sda to a smaller size disk, /dev/sdb:

First clone /dev/sda to /dev/sdb using weresync.

Then make /dev/sdb bootable using the following commands:

mount /dev/sdb1 /mnt/sysimage
mount –bind /sys /mnt/sysimage/sys
mount –bind /dev /mnt/sysimage/dev
mount –bind /proc /mnt/sysimage/proc
mount –bind /run /mnt/sysimage/run
systemctl start multipathd.service
chroot /mnt/sysimage
cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
dracut -f
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sdb
sync
umount /mnt/sysimage/run
umount /mnt/sysimage/proc
umount /mnt/sysimage/dev
umount /mnt/sysimage/sys
umount /mnt/sysimage
sync
exit

Note that xfs can cause problems if you have to change the UUID of /dev/sdb, in which case you will need to backup /dev/sdb, then convert the filesystem to ext4 instead. When running weresync, you will need to specify the additional -S option to rsync for sparse files if you have Docker installer to avoid running out of disk space when cloning.