Tag Archives: ntfsclone

Easy Partition cloning in Linux with dd, ntfsclone, gparted and Mageia 2


Over the past few months, whenever I booted under Windows, it would just freeze and force me to reboot. Then do a very long checkdisk at the next boot. I blamed Windows. Then at some point, while using GNU/Linux, I got a notification on the GNOME desktop that one of my hard drives was failing and was having bad sectors. (By the way, kudos for the team behind the Palimpsest utility that generated such notification). Since it was consistent with the windows freeze and failures, I figured it was time to replace my hard drives. Switch to SSD, maybe? After shopping,  I ended up buying a 120GB SSD drive, as well as a 750GB HDD. Which were supposed to replace my two dying 250GB drives (well, only the primary drive was dying, but I was thinking about expanding the storage on my personal laptop anyways…).

The task

Let’s call O1 my old primary hdd, O2 the secondary one, N1 the SSD and N2 the new HDD. O1 contained some data partition, as well as the original Vista partition, and “Splashtop/Rescue partition”. O2 contained more data partitions, and my existing Mageia 2 installation.

Somehow, I’d have to find a way to replicate the system partitions from O1 on the smaller N1, then copy the contents of O2 on N2, and put the rest of the old data partitions from O1 to N2. Any idea how to do that without having to purchase proprietary software?

The solution

Well, the answer is in the title. Using a Mageia 2 Live CD (most likely any other GNU/Linux Live CD would have worked as well), I could boot into a fully functioning system that didn’t require any of my hard disks to be mounted. So I carefully plugged O2 and N2, then booted the Live CD. From there, opening a terminal, I made sure both hard drives were not mounted (mount -a will show you what’s mounted and what isn’t), then I just used dd to clone O2 onto N2.

dd if=/dev/sda of=/dev/sdb

Warning: pay very very very special attention when using dd. Many a partition has been wiped inadvertently by a bad use of dd. dd is simple, it takes whatever you pass as if, and binary copies it onto of. I strongly advise you to use hdparm -i /dev/sdx (with /dev/sdx the device name of your hard drive) in order to identify which drive is which.

Running the above command clones O2 onto N2. Nice and clean. Only thing is, it also clones the partition table. So N2, my 750GB drive, now looks like it’s only maxed out at 250GB. In order to fix that, I used gparted, and simply “extended” the partition table so that it takes the whole 750GB of available space.

Now, dd is cool, but it’s really low-level, and will not be able to cope with faulty drives very well (how surprising… if the data cannot be read, it cannot imagine the bits and pieces magically? 🙂 )

To take care of the bad NTFS Partitions, I put back O1 in the laptop, left N2 as the secondary drive, and booted in safe mode. (Actually, at this point, I also tried booting the GNU/Linux freshly cloned onto N2, just to make sure everything was fine. And of course it was 🙂 ). Once in safe mode, I tried to check the drive for bad sectors one last time before the cloning:

chkdsk /f

After that was done, I rebooted under the LiveCD, and proceeded on the partition cloning. Due to the bad sectors on the drive, dd would fail me. Instead, I used ntfsclone, which also allows cloning of partition even when they are in a ‘dirty’ state. The syntax is slightly different from dd. Again, be very careful and re-read your command seven times before hitting the Enter key. The magic option for “best effort” is the --rescue option. And with ntfsclone, the last argument is the input file (called the source on the man page), while the output file/device is specified by the --overwrite option (when copying to a non-existing partition, --output works just fine).

ntfsclone --overwrite /dev/sdb5 --rescue /dev/sda1

Here, I basically asked the first partition on /dev/sda1 to be cloned on the second drive, as the partition called /dev/sdb5.

That went rather smoothly. I continued the process with the remaining partitions, eventually switched hard drives a couple more times, but I think by now, you get the idea.


  • Always triple, quadruple check your commands before running any of them. Read the man page for each beforehand. Use hdparm -i /dev/sdx 0in order to identify your disks.
  • To clone one hard drive directly onto another one, use a LiveCD of a GNU/Linux distro, and after carefully checking your disk labels, launch the dd utility to perform a low-level binary copy of everything.
  • When cloning onto a larger drive, you may want to use gparted afterwards to fix the partition table and make it extend to the full size of your disk.
  • To clone an NTFS partition, which has bad sectors, instead of dd, use the ntfsclone utility with the --rescue option.

Happy cloning 🙂