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 05:15 PM.
Once again we can observe the master at work.
On a sidenote: don't you have to go through activation hell again when you migrate Windows to a new disk?
The main point of my thread is there is no need to reactivate XP or Vista again.
edited 21/7/07 - On Vista my experience is mixed as the copy I have is an early free downloadable version. Its behaviour is erratic. The cloned copy said "activated" but gave out warning "activation expired" later.
I assume the original copy has been activated. When the carbon copy is booted either XP or Vista will find its recorded hard disk serial number no longer matches the one in the new home and a message will be displayed demanding an immediate reboot, otherwise the new disk is not ready.
Once rebooted the record is updated and the new cloned copy is as good as the original.
A hard disk can fail and so both XP and Vista permit the hard disk the OS resides in to be changed. The original copy is hardware specific and cannot be used outside the PC from which it was installed. Since only one OS can be booted at any one time the arrangement is legal if the original is used for the backup purpose.
Many Raid systems do have two identical XP or Vista running on two separate disks permanently.
I do believe the procedure in spirit and substance does not violate the vendor's right because the cloned copy can never used elsewhere except on the original PC. What it gives is the flexibility to the users to have bootable backup copy 100% mirror image of the original at time of cloning. The backed up copy, with all the installed programs and data, is good for something to fall back on should the cloned disk be virus-infested, suffer a hardware failure or the system become unrepairable.
I want to put up this thread because that is a good example demonstrating how simple, useful and yet powerful Linux is. Every user will have a need to migrate to a bigger hard disk some times and this can be achieved by one of oldest terminal command in Linux, a Live CD and a reliable resizing tool in the form of gaparted or Parted Magic. The author of the latter is of course a member of JL. He is the one that did the hard work. I only tell others how it can be used.
Last edited by saikee; 07-21-2007 at 05:44 PM.
Question: Is this possible to do with partitions? e.g.
dd if=/dev/hda1 of=/dev/sda1 bs=32768
I ask because I'm trying to move my Vista install from a bigger hard drive (160gb) to a smaller hard drive (120gb), but Vista is installed on a 60gb partition of the bigger drive.
Thanks in advance.
You can always dd a partition in Linux. If the cloned copy doesn't boot the problem is the protection system by MS systems trying to prevent such a move.
The second link in my signature was written for doing it with a Xp. I have done it with Vista too but cloning the whole disk is a much more reliable move.
If you have to do it with a partition and knowing Vista checks the partition table every time it boots then you should have only one Vista partition in the disk and shift it to the very beginning, using Vista's own internal resizer program. This makes the partition table clean and simple with only entries in the first slot of sda1. The only difference between the two disks is the size of the unallocated empty hard disk space.
I cannot vouch it will always work but that would be the way I would do it. Also as a single partition you can use Vista's installation CD to do repair on the cloned copy as most likely it would work again if you restore its MBR which is unique for Vista. Prior to Vista XP's MBR can be restored by a Dos bootable floppy.
It is a bit irritating for having to learn how to make a bootable copy of Vista for a back up because it is not a useful knowledge of technical advancement except for overcoming artificial barriers erected by the software vendor. Thus I am not a big fan of Vista and believe a user can waste a lot of his/her time on learning useless computer knowledge that would become obsolete when the software vendor brings out another new system periodically to boost his profit.
I have cloned a Vista from a 500Gb disk into a 300Gb disk and described it in the Post #55 of this thread
Last edited by saikee; 07-01-2007 at 07:58 PM.
So I went ahead and migrated my vista install from a bigger hard drive to a smaller hard drive.
/dev/sda = 160gb hard drive
/dev/sda1 = 60gb vista partition
/dev/sdb = 120gb hard drive
Ran "dd if=/dev/sda of=/dev/sdb bs=32768" and after 45 minutes or so gave me a "disk full" error. Removed my 160gb drive and rebooted using just my new 120gb drive. Vista booted up fine and I used Vista's disk management tool to "expand" the 60gb partition to the full 120gb.
Every thing's working fine, except that I had to re-activate my vista install.
Thanks again for the guide.
Did your source disk have one 60Gb partition holding Vista with the remaining 120Gb as unallocated free space?
If it wasn't then the cloned disk sdb would have a copied partition table, from sda, indicating the partition boundary at 160Gb. Since in the target hard disk sdb is physically 120Gb large that would cause all operating systems, including Vista, to refuse to handle it.
The re-activation may be to do with its standard booting check on the partition table has been enabled. I often switch it off if the entries in the partition table is going to be altered. Vista protects itself by checking with a backup copy of the system setting and that should be disabled if the OS is to be cloned to a different environment.
I didn't need to re-activate mine in the link indicated in Post #5 when changing it into a smaller disk.
Anyway glad to see it worked out for you.
Yes. After swapping the drives, Vista correctly saw that the 120gb drive had a 60gb primary partition and 60gb unallocated free space.
Originally Posted by saikee
I am attempting to move a 32-bit Vista partition from a PATA to a SATA partition. Both are formatted to 30gb (the destination partition is a few KB bigger, so it's fine if that space gets lost).
The problem is that I do not have a Linux partition installed, though I do have an XP partition. All three partitions mentioned so far are on different physical drives, each containing other partitions that I don't want to touch.
What tool can I use to make the swap? After a successful migration I would like to format the origional PATA Vista partition (what I'm using right now), so that need not be made to work alongside the eventual SATA Vista Partition.
A seemingly elegant solution would be to do the migration with DD for Windows, disconnect the current PATA Vista partition, boot and let the Vista DVD fix the MBR when it sees nothing but a SATA version of Vista.
Think that will work? From what environment (XP, Vista partition that's being copied, boot to Vista recovery console) will DD for Windows be able to do what it needs to do? Was all this typing in vain seeing as this is a Linux site? ()
DD for windows: http://www.chrysocome.net/dd
If anyone can give me some advice I would be very appreciative. The drive I'm trying to move away from is on its last legs.
Last edited by asmith; 07-07-2007 at 04:35 PM.
Welcome to JustLinux.
I haven't used dd for Windows so I could not comment on its success but there a few things I can clear up.
(1) The suggestion I put forward in this thread is to use a Linux Live CD which run on a CD and does not need to be installed into the hard disk. Therefore you are using another operating system and the Vista is cloned just as a normal data partition. This is essential as software like Norton Ghost need to reboot and come back using a DrDos program to do the cloning work.
(2) Vista checks the partition table against a copy it keeps. To have successful result you need to keep the partition order and the number of partitions and their boundaries as similar as possible. If you clone a Vista from the first partition of one disk to a second partition of another disk I can tell you right now it will not work.
Implicit in my suggested cloning from a smaller hard disk to a bigger hard disk is that you are guaranteed to end up with an identical partition table on both disks. That is an important hurdle to cross.
(3) The reason why dd is used is because it operates on a partition's boundary using the hard disk addresses stated in the partition table. This means the boot sector, which is outside the filing system, is also cloned and therefore the cloned copy has to be bootable. I am not familiar with the partition convention in Windows so I could not be certain it does the same thing but using the word "dd" means it must be able to do that. In Linux the hard disk partitions are name sda1, sda2, sda3 etc and so the device names can accurately define the boundaries of every partition. If you have 3 disks they should be named sda, sdb and sdc.
Although this is a Linux forum but I can assure you that every Windows user is welcome too. It just that our experience and know-how are invariably linked with Linux. I do have to use Windows for work.
Cloning Vista or XP by a partition is tricky. The success rate by cloning the whole disk is more assured. The problems , pitfalls, cloning instructions and things you need to watch out for a partition is simply not worth the bother. My last cloning was from a 500Gb Sata to another 500Gb Sata and it only took 2.17 hours.
Thanks for the quick response saikee.
(1) Any suggestions on a good Linux live CD? Minimal configuration would be nice since I'm only trying to do one quick thing with it.
(2) I would be cloning from a first partition to another first partition, so hopefully there are no problems there.
Figuring out what I need to know about sectors and blocks and that sort of low level hard drive stuff is a little bit confusing. Could you help me understand what parameters I would need to give DD or point me to a relevant online resource?
The GParted Live CD will do nicely, since you can use it to resize partitions at a later time if you want.
Also do check out saikee's post (#55) here.
So what if...
I have my Linux install spread across two hard drives?
My root partition and swap is on an 80GB SATA drive (which I don't want to move...)
and my home partition is on a 120GB SATA drive.
I am considering upping the 120GB to a 400 or even 500GB drive and I want to move my home to it. Same process?
One by one the penguins steal my sanity...
I never need to do cloning with Linux partitions myself.
The mod here has taught me using tar. Here is what I would go about getting a 120Gb /home into a 500Gb disk
(1) Boot up the existing Linux
(2) I am assuming the 500Gb disk starts as a raw disk and has a name , say sde. I would use cfdisk (or fdisk if you are using a Red Hat) to create a partition sde1 for the whole disk or a size of my choice. It should automatically Type 83 native for Linux. A reboot is unnecessary but doing one is a good practice if you can afford the time.
(3) I would then format the sde1 to the filing system of my choice and then manually mount it by terminal command in root
(4) The tar instruction I learned from the mod is
mount /dev/sde1 /mnt/sde1
The tar command will copy the entire content of the current partition (that I have changed directory to), inculding all settings of ownership to /mnt/sde1.
tar cf - . | ( cd /mnt/sde1; tar xf -)
(5) I would now check the content of /mnt/sde1 and satisfy myself everything is there. Then I would edit /etc/fstab to mount the /home to sde1
On a reboot I should have my home in the 500Gb disk environment. After a short period of usage and convinced the /home is working perfectly I shall use the 120Gb disk for another purpose.
The cloning procedure of Post #1 can be used too but you have to resize the partition after the cloning operation. It has the following disadvantges
(a) You clone every bit of the the entire 120Gb including unused and empty spaces. Tar only moves files and empty spaces are left behind so it is much faster.
(b) You have to resize the partition from 120Gb to 500Gb. Tar transfer the files from 120Gb to 500Gb naturally.
The cloning is only necessary if the OS has a protection mechanism or a rigid arrangement for retrieving its system files. Linux partitions do not fall into that category and so the normal Linux commands are good enough to move Linux systems from partition to partition and from hard disk to hard disk.
I include Linux in my title mainly because I clone disks with many operating systems inside.
Personally I rarely resize a partition for Linux. I enjoy the teaching by the mod and it gives a kick every time I use it. To me that is what Linux is all about ---> a rich set of Command Line Interface (CLI) that is superior to other OSs.
I use tar, exactly the same instructions as above except cd to /mnt/sdax instead to /home, to move the entire Linux which I always installed in a single partition. When needed I mount an additional data partition.
A little word to the wise for those with little or no experience with dd. It is a very powerful command and you need to make extra sure your syntax is correct.