{"id":36,"date":"2022-04-22T02:52:21","date_gmt":"2022-04-22T02:52:21","guid":{"rendered":"https:\/\/surfnz.com\/blog\/?p=36"},"modified":"2022-04-22T08:02:45","modified_gmt":"2022-04-22T08:02:45","slug":"cloning-a-centos-7-disk-to-reduce-its-size","status":"publish","type":"post","link":"https:\/\/surfnz.com\/blog\/cloning-a-centos-7-disk-to-reduce-its-size\/","title":{"rendered":"Cloning a CentOS 7 Disk to Reduce it&#8217;s size"},"content":{"rendered":"\n<p>Assuming you are cloning from \/dev\/sda to a smaller size disk, \/dev\/sdb:<br><br>First clone \/dev\/sda to \/dev\/sdb using weresync.<br><br>Then make \/dev\/sdb bootable using the following commands:<br><br>mount \/dev\/sdb1 \/mnt\/sysimage<br>mount &#8211;bind \/sys \/mnt\/sysimage\/sys<br>mount &#8211;bind \/dev \/mnt\/sysimage\/dev<br>mount &#8211;bind \/proc \/mnt\/sysimage\/proc<br>mount &#8211;bind \/run \/mnt\/sysimage\/run<br>systemctl start multipathd.service<br>chroot \/mnt\/sysimage<br>cp -p \/boot\/initramfs-$(uname -r).img \/boot\/initramfs-$(uname -r).img.bak<br>dracut -f<br>grub2-mkconfig -o \/boot\/grub2\/grub.cfg<br>grub2-install \/dev\/sdb<br>sync<br>umount \/mnt\/sysimage\/run<br>umount \/mnt\/sysimage\/proc<br>umount \/mnt\/sysimage\/dev<br>umount \/mnt\/sysimage\/sys<br>umount \/mnt\/sysimage<br>sync<br>exit<br><br>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\/sysimagemount &#8211;bind \/sys \/mnt\/sysimage\/sysmount &#8211;bind \/dev \/mnt\/sysimage\/devmount &#8211;bind \/proc \/mnt\/sysimage\/procmount &#8211;bind \/run \/mnt\/sysimage\/runsystemctl start multipathd.servicechroot \/mnt\/sysimagecp -p \/boot\/initramfs-$(uname -r).img \/boot\/initramfs-$(uname -r).img.bakdracut -fgrub2-mkconfig -o \/boot\/grub2\/grub.cfggrub2-install \/dev\/sdbsyncumount \/mnt\/sysimage\/runumount&hellip; <a class=\"more-link\" href=\"https:\/\/surfnz.com\/blog\/cloning-a-centos-7-disk-to-reduce-its-size\/\">Continue reading <span class=\"screen-reader-text\">Cloning a CentOS 7 Disk to Reduce it&#8217;s size<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[28,24,20,21,26,25,23,22,27],"_links":{"self":[{"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/posts\/36"}],"collection":[{"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":4,"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":41,"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions\/41"}],"wp:attachment":[{"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/surfnz.com\/blog\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}