Using a Linux Live CD to clone XP and/or Vista
27 Apr 09 - The procedure set out here is applicable to Xp, Vista and Win7, regardless how many of them in the hard disk. No re-activation is needed but a reboot is generally necessary for the system to update its registry to account for a change in the hardware. Remember to remove the source disk or hide the source partition when booting the new traget partition or disk. Newer M$ systems uses a unique code for each partition identification which will be faithfully cloned. This can cause confusion to the OS if two identical partition codes are encountered. Generally the OS will disable the second partition and possibly invalidate its booting code.
30 Jan 07 - for reliably resizing XP partitions there are now free Linux Live CD on Gparted and Parted Magic
For a modern, informative and authoritative use of dd see AwesomeMachine's thread "Learn dd command"
13 May 07 - Section B added to include cloning the whole hard disk. I have since rewritten Section B as a separate thread in view of it being a general method which is recommended because it is a lot simpler but totally reliable. All you need is a hard disk exactly in size or just larger.
1 July 07 - A worked example to clone Windows Vista has been added in Post #55 of this thread
21 Oct 07 - Recommended block size now changed from 32768 to 32256 as the latter proves easier to finish with a full record in the last transfer.
Section A - Cloning a XP partition
For cloning Vista or an easier scheme see Section B
An installed Windows XP protects itself from being cloned even for the backup purpose. Specialised software like the Norton Ghost, Acronis or PowerQuest Drive Image has to be used so that the OS can be moved to a bigger hard drive in a disk upgrade.
Linuxs dd command also works the same way but this needed to be performed on the whole hard disk so that the MBR and partition table are cloned as one whole lot.
The method described below shows how Linux can be used to clone a XP partition. In the example here the source is a XP Pro partition in a 30Gb IDE drive recognised by Linux as hda1. For simplicity I used a disk with just one partition in it. The source XP partition has a SATA driver previously incorporated when installed. The target is a brand new unformatted 200 Gb SATA disk recognised by Linux as sda (older kernel may report hde).
To demonstrate the power of Linux I use only a Live CD from Knoppix 3.4. There is no other bootable Linux in the hard disk.
(1) Install both source IDE (hda) and SATA (sda) as internal hard disks into the PC and boot the computer up with Knoppix Live CD.
(2) Click Knoppixs terminal mode, type
to become the root user.
to check the hda and sda structures if needed (Recommended so that you know what you are doing).
to write down the exact size of hda1, assumed NTFS type.
and create a primary sda1 partition, select file type NTFS (type No 7) and size identical to hda1, select it to be it bootable too, let it write the partition table and exit (recommend a reboot here to make the partition table permanent)
(6) Native copying by typing
The 32256 is the track size for 63 sectors each 512 byte. Progress is slower if bs is omitted and Linux would use the default block size 512.
dd if=/dev/hda1 of=/dev/sda1 bs=32256
(7) When dd operation completes it will show the time taken on the screen. Power down, remove Knoppix, remove the source disk hda. (re-set the new disk as the master, no action is needed if it is in cable select mode for the Pata disk. Sata disk has no master/slave setting and the booting queue is controlled by the Bios only)
(8) Boot system up with a DOS floppy (with fdisk.exe inside) to restore MBR by typing
This works even on a SATA disk. Alternative boot up any Win2k or XP installation CD, go to the recovery console and issure command
(9) Remove DOS floppy and the SATA should be bootable with XP cloned.
Did this twice with a XP home and then a XP Pro. The above example has XP Pro in a 28.6Gb partition with 16.1 filled data. It took 4297 second or 72 minutes. On another 10.1Gb partition with XP home in 5.24 Gb data the time was 1409 seconds or 24 minutes. Naturally the two different licenses of XP booted successfully.
If the Linux has been installed from a hard disk and has the 2.6 kernel the time needed can be reduced considerably (about 50%).
The cloning rate for current versions Linux is about 45-55Mb/s for internal disks.
Section B - Cloning the whole disk containing either Win2k, XP, Vista or in any combination with or without other operating systems.
This method is highly recommended because it is the most reliable. The whole source disk is cloned to a target disk. The only essential requirement is the target disk must be as larger as the source disk, down to the exact number of sectors or simply just bigger.
The cloning has been 100% successful in the following applications
From a Pata to a Sata disk or the opposite way, both internal disks.
From an internal disk to an external USB hard disk or the opposite way
From a 2.5" latop disk to a 3.5" desktop hard disk (the opposite way not tried).
The number of operating systems and the types are immaterial to the cloning. I have the maximum 63 partitions in many disks cloned this way and every operating systems in the clone boots exactly as the original. The systems I cloned include a mixture of Dos, Windows (3x, 9x,2k, Xp & Vista), Linux, BSD and Solaris.
I am so confident with this method that on the completion of the cloning process I would remove the original source disk, put it away for safe keeping as the backup and start to use the newly cloned disk straight away, as I have never met a problem in upgrading my hard disk from 200Gb to 300Gb, then to 400Gb and finally to 500Gb.
I shall use the example of cloning an existing Pata hard disk known in Linux as hda into a newly purchased larger Pata disk hooked up as a USB hard disk. To Linux a USB disk belongs to the SCSI/Sata family and is called sda if it is the first one in the PC, otherwise it could be a sdb, sdc, sdd, sde etc.
Here is the simple steps
(1) Obtain a Linux Live CD. Any one will do because the dd command is an integral part of Linux terminal command. However for fast cloning please use the current version of Linux Live CD. Recommeded distros are Slax, Knoppix, Kanotix, Mepis, Fedora Live, Mandriva Live etc. Ubuntu is also suitable but it is slight more work to get root privilege.
(2) Obtain a hard disk enclosure and purchase a new hard disk is has a capacity larger than the original source disk. Cloning is just like putting a carbon paper between two sheets. It will not work out if the bottom sheet is physically smaller than the top sheet as part of the information cannot be recorded out. That will happen exactly to hard disk cloning. It is very simple. The partition table has been copied from a bigger original disk resulting some hard disk addresses cannot be found on the smaller cloned hard disk.
(3) Cut the seal from the new disk and install it into the hard disk enclosure as a raw disk. Hook it up to the PC as a USB hard disk. Boot up the PC with a Linux Live CD.
(4) Select terminal mode and become the superuser by issuing the terminal command
The standard practice in Linux Live CD is to waive the demand of root password which will be demand only if the Linux is installed into the hard disk, but there are always variations. If a root password is demanded take a look at the /home directory as the Live CD developer usually left a hint on how to get the root password. Some distros will work if you just press enter (i.e. blank password), other will accept "root" or "toor". I recommend Slax and its family distros because the root password is printed before the login.
(5) Check the hard disk naming notation in Linux by command
Linux call a Pata either hda, hdb, hdc or hdd. For Sata it can be sda, sdb, sdc, sdd, sde, sdf etc. An USB disk also follows the SCSI/Sata notation so it will be call sda if there is no Sata or SCSI disk in the system, otherwise it will take the name sdx where x is the next alphabet not yet taken. One can see the name of the newly hooked USB disk as it has no partition inside and the capacity should correspond to the size purchased. I shall assume this new target disk to be sda. Please adjust according to your own circumstance.
(6) You can start the cloning process by one line of command
In the above "if" is the input device and "of" stands for the output device. The Block size parameter bs has been chosen to be one complete track of 64 sectors each 512 bytes. Omitting the bs parameter will cause dd to default to 512 bytes in each transfer and this slows down the cloning. The 32256 is about the optimum I have found.
dd if=/dev/hda of=/dev/sda bs=32256
For AMD 3200 Athlon PC with 1Gb ram my cloning speed between internal disk is about 50Mb/s. If one disk is a USB this can drop to about 10Gb/s.
dd does not output any information until the process is completed. The flickering LED of the hard disk tells us dd is busy. On completion dd will always report the number of records, each equal to the the specified block size, transferred. Multiplying the record number with the block size should correspond to the capacity of the source hard disk.
I recommend removing the source disk, put it away for safe keeping as the backup, install the cloned disk in its place and start using the new disk right away.
For those who is not already aware dd stands for "data dump" meaning the binary pattern from a source disk is read and then written on the target disk. Technically it is impossible to clone a disk that is not a 100% carbon copy of the original.
The newly cloned disk's extra capacity over and above the original disk simply become the unallocated hard disk space which can be absorbed into the existing partitions by gparted or Parted Magic. It is recommended the current versions of these software to be downloaded and run as Live CD.
It has been my experience the whole hard disk cloning will always work on XP and Vista.
The current Live CD versions of gparted and Parted Magic are good for resizing XP. To resize Vista I recommend using its own internal resizer program which is faster and the success is guaranteed by M$.
It is recommended Vista to be cloned as the whole hard disk. This is because the current Vista has a new MBR and will conduct a check on the partition table. It can use a change to the partition table, between a reboot, as an excuse for the security risk to refuse to boot. Cloning the whole disk gives Vista no such excuse because the partition table isn't changed. Vista will still be able to detect the hard disk has been altered and demands an immediate reboot, same as XP. After a reboot Vista will work normally after the hard disk serial number has been updated.
Re: Using a Linux Live CD to clone XP
Yes, you MUST reboot here. If you don't, you risk serious damage to your drive.
Originally posted by saikee
Type "cfdisk /dev/hde" and create a primary hde1 partition, select file type NTFS (type No 7) and size identical to hda1, select it to be it bootable too, let it write the partition table and exit (recommend a reboot here to make the partition table permanent)
The only way you can get around rebooting is by running program partprobe.
Partprobe works great, and I have used it several times before with no problems.