Cloning Bootable Linux Disk

I got a new and bigger HDD for my webserver and so I decided to clone my existing one (128GB) to the new one (512GB). The best thing was that I didn’t need to install and configure all my applications again, so here is a short manual that worked in my case.

  1. Download Ubuntu Desktop
  2. Create a bootable USB disk with Rufus
  3. Start from USB disk and choose “Try Linux from bootable media”
  4. After Linux has started open a terminal and enter the following commands to copy the disk layout:
    >> sudo bash [go to superuser mode]
    >> fdisk /dev/sda [source disk]
    >> o [dump disk layout to file]
    >> q [quit]
    >> fdisk /dev/sdb [destination disk]
    >> d [delete]
    >> I [load disk layout from currently saved sda layout]
    >> w [write layout]
  5. Now clone all data from the source disk to the destination disk by following this command:
    >> dd if=/dev/sda1 of=/dev/sdb1 bs=64K conv=noerror,sync [blocksize 64K, don't stop on error and keep syncing] Don't mix up input and output disk!!!
  6. Now you have to make the destination disk bootable again:
    >> mount /dev/sdb1 /mnt
    >> grub-install --root-directory=mnt /dev/sdb
  7. If all worked correctly you can optionally open gparted and resize the cloned partation to your needings.