2

I have a hard disk which is 1 Tb in size. I have created and installed windows Xp on a partition of size 10 Gb. I want to clone the partition to a file on another disk such that I can dd the file to any new disk resulting it to be a exact same clone of 10 Gb partition.

NOTE I do not want to clone the entire 1Tb disk into a file but just the bootable 10Gb partition. The partition is a GPT type.

I am specifically looking for any commands that I can use from booting the system through a live CD.

Any suggestion are welcome.

1
  • If you can give up dd usage you can try Clonezilla - its will be faster than dd (only used blocks are cloned).
    – g2mk
    Nov 19, 2015 at 5:29

3 Answers 3

1

So I was able to do what I wanted.

I used gnu parted and dd to copy only the bootable partition.

I first used parted command to printthe start and end of the drive say /dev/sda and then noted the start and end of the bootable drive. For e.g end is at 7890Mb just convert this into bytes and divide by 512 which is the block size of the drive I was working in. Lets say this result is N. The result would be the count you will supply to dd command.

Now just use dd if=/dev/driveWhereBootablePartionExist of=/backup/img.img count=N from above bs=512(or block size)

This resulted in fully bootable image file for the partition equal to partition size.

1

You can use dd to copy the entire partition, as in:

dd if=/dev/sda3 of=windows-xp.img

(Change /dev/sda3 and the output filename as necessary.) You'd then reverse the process to copy it back:

dd if=windows-xp.img of=/dev/sda3 bs=4096

Note that I've added bs=4096 as an option. This causes output to be sent in chunks of 4096 bytes, which is likely to be faster on most modern disks. (This will have little or no effect when creating the backup, though.)

Although using dd, as you specified in your question, will work, it's inefficient. A better way is to use a tool called ntfsclone, at least assuming the partition uses NTFS. (This is a Linux tool. Based on the fact that you specified dd and said you're using a live CD, I'm assuming it's Linux.) To clone a partition with ntfsclone, you'd use something like this:

ntfsclone --save-image --output windows-xp.img /dev/sda3

Restoring it requires a command like this:

ntfsclone --restore-image --overwrite /dev/sda3 windows-xp.img

There are more examples of its use near the end of the ntfsclone man page (type man ntfsclone to read it).

The advantage of ntfsclone is that it uses a sparse file format, which means that it doesn't back up sectors that aren't in use. By contrast, dd copies everything, so if the partition has lots of unused space, dd will probably take longer and will definitely chew up more disk space. Depending on the state of the disk before you installed XP, compressing the dd backup might not help that much, since the unused sectors might have old data on them.

Either way, there are a few caveats to keep in mind:

  • Both ntfsclone and dd will back up the boot loader data in the Windows partition, but not the boot loader on the disk's MBR. You'll have to back that up separately. (OTOH, you said that the disk is GPT, and Windows XP can't boot from GPT disks, except for some exotic Itanium builds, IIRC. Are you using this in a virtualization environment?)
  • Both dd and ntfsclone pose a risk of serious damage if you enter the wrong device filename, particularly when restoring the image. If the restore target is the wrong partition, you're likely to wipe out everything on that target, which could be disastrous. Be very careful!
  • You need root privileges to execute these commands. Depending on your live CD environment, that might be the default, or you might have to add sudo to the start of each command.
0

Try gparted. It can copy partitions to another disk. Or dd can be used like this:

dd if=/dev/sda1 of=/dev/sdb1 bs=1M

You need to reinstall boot loader to make it bootable after such copy.

1
  • I do not want to touch the bootloader part separately. Thus I asked this question. Thanks for the response though.
    – abhi
    Nov 19, 2015 at 6:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .