How to migrate XP, Vista, Linux, BSD and Solaris to a bigger hard disk
----Edited 5 Oct 09 - Confirmed the method has been successfully applied to 32 and 64 bit version of Win7 and on SSD hard disk. No problem encountered as expected.
----Edited 22 Jun 08 - A reference to a thread on resizing and moving Xp and Vista added.
----Edited 20 Oct 07 - An example of cloning a hard disk with XP, Vista and 10 Linux has been added in Post #36 ------------------------------
----Edited 21 Oct 07 - The recommended block size changed from 32768 to 32256 making it easier to end up with a full record in the last transfer ------------------------------
Summary ( for regular Linux users)
Step 1 – use Linux dd command to clone the original disk to the new bigger hard disk
Step 2 – use Gparted or Parted Magic to resize the partitions to absorb the extra space Optional only if you want to increase the partitions sizes.
Resizing and moving Xp and Vista partitions are harder than cloning these operating systems because the partition table is changed and the hard disk addresses/locations altered. This thread gives some pointers on how to go about them.
The following has been written for PC users new to Linux
With hard disks getting bigger in capacity and selling cheaper per Gb many PC users can now afford to upgrade the hard disk to a bigger unit. Migrating an operating system to a different hard disk can be hazardous because the integrity of the filing system and the boot loader may be affected in the new home. However if the basic rules are adhered to then the migration can be effortless.
This thread is written to show how to use a Linux Live CD, of either Gparted or Parted Magic, to clone from a smaller source disk into a bigger target disk. Both Gparted or Parted Magic are now available as free downloadable bootable iso images. Just download any one of them, burn the iso into a bootable CD and you are in business. There are other Linux Live CD that can perform the task too but I concentrate on the above two because they are most user-friendly to non-Linux users, have a graphic desktop showing the hard disk partition on a boot-up and the root privilege (Admin. Right in MS systems) is given automatically.
If you don't need the cloned disk to absorb the extra hard disk space then any Linux Live CD can do the cloning job because the operation requires essentially just one line of dd command, as shown and fully explained in Step (5) below.
The operating system type to be migrated is irrelevant and so is the number of them. I often clone hard disk with the Linux-permit-maximum of 63 partitions with 62 different operating systems inside (one less because an extended partition cannot hold an operating system).
How reliable is the migration?
It is both watertight and bomb-proof technically as far as I am concerned. The migration comprises of two parts
(A) The existing hard disk is cloned as a mirror image onto the bigger target disk. This is done by “dd” command available in Unix and Linux. The binary pattern of the original disk is read and then the information is written on the new bigger hard disk, in block size as specified by the user until the number of records in source disk is exhausted. Since it is the binary pattern of the hard disk being copied at the hardware level and so no filing system is involved and there is no need to mount the partitions/disk. Therefore the type and the number of the operating systems in the original hard disk is immaterial. In PC standard the first sector of the hard disk is the Master Boot Record (MBR). Inside it is the partition table. This information is faithfully duplicated onto the new bigger hard disk and so the boot loader will be exactly same as before and be able to load its operating system in exactly the same hard disk address. The operating system that carries out cloning is from a Linux Live CD which is self sufficient. The to-be-clone operating system residing inside the hard disk is undisturbed.
(B) The extra capacity in the newly cloned bigger hard disk automatically becomes unallocated space. The reason I suggest Gparted or Parted Magic is because they can reliably resize NTFS partitions and naturally many of the standard partition types used by Linux. On partitions not supported by Gparted or Parted Magic, like those from BSD and Solaris, the user will have to go to the operating system to alter the partition boundaries. The new MS Vista has its own resizer program inside and it is recommended to use it because the new Vista conducts a check on the partition table on every boot up and will refuse to boot if a user carry out the change without its knowledge.
The procedure below has been tried on migrating a Pata/IDE disk to Sata disk and vice versa. Equally it works seamlessly from an internal disk to an external disk.
Steps (using migration of a XP disk as an example below)
(1) Hardware connections – Here I assume the original disk is inside the PC as an internal hard disk. For easy operation at the expense of slower cloning speed the bigger hard disk can be put into an external hard disk enclosure and offered to the PC via a USB cable or firewire connection. There is no need to do anything with the new bigger hard disk and I often just cut off the seal envelope and hook it up as a raw disk. As soon as the first sector is cloned the new disk will have the partition table of the original disk and all previous information on the new bigger hard disk will be gone. Thus formatting or creating partitions in the new disk is a waste of time.
Pata disk has a jumper for setting it to Master, Slave or Cable select. I recommend “Cable select” because such setting allow the same disk to work as a master or a slave according to connection to the end and middle plug respectively. Once set the disk does not need to be altered again. All my 30+ hard disks were set to cable select and I use them in either as master or slave and internally or externally.
Sata disks have no master or slave setting and the order depends on the physical port location on the motherboard.
(2) Boot up the Parted Magic or Gparted Live CD – It is a Linux Live CD that can run wholly on a CD without being installed into the hard disk. On a boot up you will automatically be given the admin right. A graphic desktop will appear to show the 1st hard disk of your PC. You can see other hard disks, including those attached to the USB ports by clicking the choices available.
(3) Identify the hard disk names (1st line of defence against making an error of the source disk for a non-Linux user) – Basically you are cloning one hard disk to another so knowing how Linux names the hard disk is vital. Linux called Pata/IDE disks as had, hdb, hdc or hdd. A PC can have a maximum of 4 such devices. The SCSI/Sata/USB disks are called sda, sdb, sdc,sdd, sde, sdf…and so on and there can be 16 of such devices. You should be able to know which disk you are looking at by the information of the partitions displayed on the screen. A raw hard disk will have no partition inside.
(edited - Since this thread was published Linux with kernel 2.6.20 and newer employ libATA driver to detect hard disks. As a consequently all SCSI, Pata, Sata and USB hard disks are now called sda, sdb, sdc, sdd, sde....etc)
(4) Identify the hard disk names one more time (2st line of defence against make a mistake on the source disk) – You will then click the terminal icon to get into the terminal mode to execute the cloning process. Before the cloning starts you issue this command in the Linux terminal
The above command instructs Linux to display every partition of every disk it can find in the system. Pay particular attention to the partition type as Type 7 stands for the NTFS filing system normally used by XP. (For a complete break down of 100+ partition types supported by Linux you can run the fdisk program on any hard disk by command like “fdisk /dev/had” and then select “l” to list the partition type.)
Make sure you know the input device or the original disk where XP is residing.
(5) The cloning process – The Linux command to carry out the cloning is
The cloning is done by the command “dd” which stands for data dump. The “if=/dev/hda” is the input file from device “hda”. Similarly the “of=/dev/sda” is the output file to device “sda”. It is vital that you should have the original disk, containing the XP, in the input device and the target disk is indeed the one you want to migrate XP it.
dd if=/dev/hda of=/dev/sda bs=32256
Linux “data-dumps” the binary pattern it reads from the input device and then writes on the output device using the block size specified. The “bs=32256” represents one complete track of 63 sectors each with 512 bytes. This is about the optimum in my experience with the hardware I have. Omitting the bs parameter will cause dd to default to 512 bytes in each transfer and can slow down the process significantly.
There is no information showing the progress but the flickering hard disk LED is the only indication that the Linux is busy in the cloning process.
When dd completes the task it always reports the number of records transferred. This number multiples with the block size should correspond to the capacity of the source disk (the one with XP inside).
Cloning speed with say a AMD Athlon +3000 will be around 45 to 55Mb/s if both disks are internal. If one disk is an external USB device the speed can drop to between 1/3 and 1/5. Thus cloning a 100Gb internal disk onto a USB hard drive, say at 10Mb/s speed, should be around 2.8 hours. If the target disk is hooked internally, even on a temporary support, the time taken can be reduced to less than an hour.
(6) How to use the cloned disk – Just power down, remove the source disk, put it away for safe keeping as the backup, install the cloned disk in its position, boot up the PC and start using the cloned XP straight away.
If the original disk is not removed then it must be relocated and not used for booting at the new location because it will not boot. Instead the cloned drive, hardware wise, should take over the original disk position because it is supposed to work as the original disk except with a bigger capacity of space.
XP has a protection mechanism that will discover the recorded hard disk serial number no longer matching the cloned disk. It would demand an immediate reboot so that this record is updated. On a reboot XP will work normally again. M$ does allow a XP user to change disk which, being an electromechanical item with moving parts, can break down in time.
If anything goes wrong in the cloning process your original input device is intact because it is used only for the reading purpose. Thus you can repeat the process as many times as needed to get things right. I never need to clone a hard disk twice unless I need a third copy.
The original disk can be later wiped clean to be used as a second hard disk after you have satisfied that the cloning has been 100% successful.
(7) How to use the extra capacity of the bigger hard drive – Run the Parted Magic Live CD again. You can move a partition around and resize its boundary to absorb the extra hard disk capacity. It is recommended the moving of the partition to be done separately, the PC rebooted and the XP is verified working properly before its boundary is resized.
As the residing operating system is not disturbed therefore the above procedure is also suitable for salvage an unbootable hard disk, keep the original copy as back up and carry out repair work on the cloned copy. dd also has parameter to allow a user to slow down the hard disk read/write speed, by altering the DMA mode say from ATA133 to ATA66, to improve the reliability of the data retrieval from a dying disk.
Last edited by saikee; 10-05-2009 at 06:15 PM.