What is the best way to clone a disk?

My guess is that dd if=/dev/sda of=/dev/sdb bs=4096 will work out well for me. I have some concerns though:

  • What is the ideal bs size?
  • Is it advisable to use a live cd? I simply don't want to include running applications, temp files and other useless files in my clone.
  • How much size should the destination be? I hope this will not as be as big as the source.
  • How to restore the clone (from the removal disk) back to the laptop?

Any help is appreciated.


bs stands for block size. which mean size of block taken by the dd command. Ideal bs refers to your file system files.as u make bs larger as you move faster in cloning.

and yes it's better to use a live CD to not clone those temp and other unneeded files

The size of the destination must be the same or bigger (you can still clone to smaller hdd but it need much more configuration and fixing issues you'll face)

To restore the clone easily reuse the dd tool again. now the laptop hdd will be the destination

To clone to smaller hard disk refer to How to clone to a smaller harddisk?


Out of dd you can use clonezilla which is a great application for cloning. download the iso file and use it as live CD . It will be much easier for newbies to try


I have just gone through this exact process successfully, so at the risk of bumping an oldish thread here it is.

Scenario: Ubuntu 16.04, windows xp dual-boot. There are old windows games I still love which won't run under wine...

Old Disks:

1x ancient IDE, with / and swap

1x 450GB SATA with home directory and winxp partition

New Disk:

spanking new 2TB SATA.

Procedure:

  • power down. Add 2TB disk. Boot from ubuntu liveCD (I used workstation 16.04). You will need to set up networking somehow for the next step--unfortunately not everything you need is on the liveCD.

  • Enable ubuntu universe and install uuid.

    # apt update
    # apt install uuid
  • Start gparted. This tool has a copy function which can resize a partition on the fly. It's a winner.

Gparted will show the existing partitions and most likely unallocated space on the new drive. Delete everything on the new drive, no need to prepare partitions.

Using gparted copy and paste, you can copy any partition and paste it into the unallocated space on the new disk. gparted will do everything needed for the copy and resize operation.

So much for the easy bit...

Now you have your original partitions and the new copies under the liveCD root. At this point you need to do four more things for success:

  1. Change the partition UUIDs on the copies to new ones. For each copied partition:
    • use uuid to generate a new UUID
    • use tune2fs -U [UUID from above step] /dev/[device] to apply it to your COPY. This is so you don't mangle your existing, working system. NOTE:do not do this to an NTFS partition. The UUID is used by windows to validate itself and as I understand it, you are in for trouble if you change it. See below, Cleanup. UPDATE: gparted can create a new UUID for you. Only noticed this just now.
  2. Edit fstab
    • assuming you mount your "/" drive copy on /mnt
    • edit /mnt/etc/fstab and replace the UUID for all old your mounts with those of your copies which you have just changed. If you have mounts using devices only, consider changing this approach which is now well and truly legacy.
  3. Reinstall GRUB2. I used the chroot method, and heartfelt thanks go to Nathan Kidd.
    mount /dev/sdXY /mnt
    for dir in /dev /dev/pts /proc /sys /run; do
        mount --bind $dir /mnt$dir
    done
    chroot /mnt
    update-grub2

This bind-mount bit appears to be essential but I do not know why grub even cares about these run-time things. However, it seems to be magic. This step even worked out the new location of my XP partition.

  1. In XP itself, the boot.ini may need to be modified. You will most likely need to change the default and multi incantations so the windows boot loader can find everything else. Documentation for this part is in the usual microsofty places. You will know this is the case if you get a message about missing HAL.DLL. Don't start copying files, fix up boot.ini and it should come good. I did this by fuse-mounting the NTFS partition on the liveCD root and editing it by hand.

Then you remove your old drives and reboot into the new drive. Worked for me, including windows with no invalidation of licence. YMMV, it seems to be pretty random in my experience.

  • Cleanup: Now that I have a working new drive, I'm going to reboot into liveCD with both of the SATA disks and zap the contents of the old 450GB disk. This is because I believe that if you have two NTFS partitions with the same UUID mounted on the system, Bad Things can happen. I could be wrong...but why risk it? Also, make sure you disable any previously bootable disk in your BIOS. I forgot to do this and wasted a bit of time with a not-booting system until I worked out what was going on.

It can then be reused for something else. The IDE drive, who cares?

I have gone to the trouble of posting this because it's taken me two days to sift through the contradictory and often outdated or sketchy info on this topic. I hope it is useful to someone and saves some effort and trouble.