1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

How to migrate an operating system to a bigger hard disk.

Discussion in 'Hardware' started by saikee, Oct 5, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. saikee

    saikee Thread Starter

    Joined:
    Jun 11, 2004
    Messages:
    3,887
    I have written this thread originally in JustLinux Forum. In view of the fact that it may be useful to MS Windows users I have re-written it to suit the non-Linux users. The method can be used on a healthy system or just to salvage data off an unbootable system.

    Summary

    Step 1 – use Linux dd commands to clone the original disk to the new bigger hard disk (only two terminal commands and one of which is optional)
    Step 2 – use Gparted or Parted Magic to resize the partitions to absorb the extra space (Optional if you want to use up the spare space in the larger hard disk)


    -----------------------------------------------------------------------
    Theoretical consideration (User not interested in the theory can skip the black section and go straight to the blue text

    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.

    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. The second part is optional for teaching the user how to use the extra hard disk space.

    (A) The existing hard disk is cloned as a mirror image onto the bigger target disk. This is done by the “dd” command available in every Unix and Linux system. 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 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. If you want just the backup you can clone from a 2.5" laptop disk into a desktop 3.5" hard disk, and vice versa of course.

    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 sealed 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 NOT necessary.

    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 can use them in either as master or slave and internally or externally without touching the jumpers.

    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. The program one see at a booted up Parted Magic or Gparted is called "Gome Partition Editor". It is one of the many partitioning and formatting tools in Linux. I sugggest its use because it is the best desktop utility in the business.

    (3) Identify the hard disk names (This is the 1st line of defence for non-Linux user) – Basically you are cloning one hard disk to another so knowing how Linux names the hard disk is abosultely vital. Linux called Pata/IDE disks as hda, 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. Newer Linux call all Pata/IDE/Sata/SCSI/USB hard disks as sda, sdb, sdc, sdd, sde...etc. An internal hard disk will be detected first and so will be able to grab the sda status, leaving the external hard disk assigned with sdb. Always look at the partition information and the size of the disk to make sure you know which is which.

    (4) Identify the hard disk names one more time (This is the 2st line of defence I recommend) – 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.

    Code:
    [B]fdisk –l[/B]


    The "-l" is the "-" with a small "L". This command is optional and 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 which stands for the NTFS filing system normally used by XP. If you are cloning a XP to a new bigger disk then the "source" will have partitions inside and at least one of them has partition type 7. The "target" on the other hand shows the capacity as you have bought it and there is no partition inside.

    Make ABSOLUTELY 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 just one line (You don't need anything more to clone a hard disk, even if it is completely filled with several OS and 500Gb in size).

    Code:
    [B][SIZE="4"]dd if=/dev/hda of=/dev/sda bs=32768[/SIZE][/B]
    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 output file to the 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 bigger and is the one you want to migrate XP to it.
    If you are using a new version of Parted Magic or Gparted then the source would be "sda" and the target would be "sdb". Do adjust to suit your circumstance.

    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=32768” represents one complete track of 64 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 considerably.

    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 exactly 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/4. Thus cloning a 100Gb internal disk onto a USB hard drive, say at 10Mb/s speed, should be around 8000 seconds or 2.22 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 and boundary expansion each to be done separately, the PC rebooted and the XP is verified working properly before the next task is undertaken.


    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.
     
  2. Elvandil

    Elvandil

    Joined:
    Aug 1, 2003
    Messages:
    51,988
    Thank you very much, saikee. Many people would like to be able to clone a drive without buying apps that they may well never use again.

    Much appreciated.
     
  3. saikee

    saikee Thread Starter

    Joined:
    Jun 11, 2004
    Messages:
    3,887
    It is a pleasure to show something so simple yet so useful. Pity the functionality isn't available in MS system but I believe a Windows-version of the "dd" command is now available as a free program.

    Like I mentioned in the thread the procedure is equally good for salvage information off a dying hard disk because the original filing system is not activated and the difficulty of reading a corrupt file is therefore bypassed. The procedure will cease to work If the hard disk has developed a hardware problem.
     
  4. pmac7

    pmac7

    Joined:
    Oct 25, 2007
    Messages:
    29
    Thanks, saikee! This is great! I've got one question for you though... could you just use gparted live to copy an internal hard drive to an external USB hard drive? If so, how would this differ from the dd method?
     
  5. saikee

    saikee Thread Starter

    Joined:
    Jun 11, 2004
    Messages:
    3,887
    If one uses Gparted to move a partition around one does not necessarily reproduce the partition table faithfully because only one partition is manipulated at a time.

    XP and Vista protect themselves by checking the partition table kept inside the systems and could refuse to boot if changes took place without their knowledge fearing it might be an virus attack. Therefore to make MS systems bootable is not to mess around with the original partition table.

    To non-Linux users Gparted depends on the dd command heavily because Gparted stands for Gnome partition editor. Gnome is the name of a Linux desktop system used by 60 to 70% of Linux distros. Gparted Live CD is actually a stripped out Linux and enhanced with various partitioning tools. Gparted program itself is shipped inside many Linux. Its Linux kernel provides the dd command. Thus one can expect in a partition to partition cloning Gparted is not much different from dd.

    I find the whole disk cloning is 100% reliable myself. Once cloned and have the systems running satisfactorily then do the resizing work as a second step.

    AFAIK filing copying commands in every operating system deal with the files and the boot sector within the partition is untouched. dd does not copy files but the binary bits of "1" and "0" from the first sector to the last sector of the partition (or the disk according to the instruction given). Thus only dd can make a target partition or the disk "bootable".
     
  6. pmac7

    pmac7

    Joined:
    Oct 25, 2007
    Messages:
    29
    Saikee, thanks for the reply. I guess I was asking because I'm not sure how to bring up a command line from within a Gparted live CD. I only have XP on my computer so I thought I could copy and resize that single partition with Gparted and still be able to boot from the copy. (I'm looking into upgrading my laptop's hard drive.) So my next questions are:

    1) Is the above assumption correct?

    and in case its not,

    2) How do you bring up a command line from within Gparted Live?
     
  7. saikee

    saikee Thread Starter

    Joined:
    Jun 11, 2004
    Messages:
    3,887
    (1) The answer is yes. In your case I would resize it in the new disk, so that the original is available as a backup. That way you have no fear and can mess the new disk any way you want. I have done it with laptop disks a few times. Just purchse the new disk of size you want, like a 160Gb, put it into an external enclosure, hook up as a USB disk, clone it, remove the old disk, put new disk into its position and everything will work exactly as before but in a larger disk. Cloning speed is about 10 to 15Mb/s if an external USB disk is involved because USB2 transmission rate peaks at 480Mbit/s or 60Mb/s.

    Do remember, depending on the age of the laptop, the 2.5" hard disk can be either a Pata or a Sata. Their connectors are different and cannot be mixed.

    (2) In Gparted there is a screen icon at the bottom bar. Click it and you are in terminal. Just like the command prompt in XP. The icon is among those you can click to stop or reboot the computer.
     
  8. pmac7

    pmac7

    Joined:
    Oct 25, 2007
    Messages:
    29
    Thanks a bunch! I think I feel comfortable doing this and saving some money! :) (I am a student, after all)
     
  9. pmac7

    pmac7

    Joined:
    Oct 25, 2007
    Messages:
    29
    Just wanted to post a follow up- I now have a 160 GB internal hard drive in my xp laptop and an 90 GB external USB hard drive! dd worked great- took me a little less than an hour to transfer the entire hard drive (~75 GB) over USB.

    A few hiccups I ran into that I wanted to share to prevent others from doing the same...

    1) You have to use image-burning software to get the GParted Live CD iso onto a CD. Just burning the iso doesn't work. I recommend imgburn (http://www.imgburn.com/).

    2) When I took my internal hard drive out, it looked like my larger, newer one had the wrong type of connection (even though I checked beforehand that it would work). It ended up that there was some type of adapter on the end of the old hard drive which came off of the old one and fit onto the new hard drive.

    3) I had some trouble moving partitions around- be sure to read the GParted documentation on moving partitions and pay close attention to "set disklabel."
     
  10. Elvandil

    Elvandil

    Joined:
    Aug 1, 2003
    Messages:
    51,988
    That is a very common problem. All burning software can burn images, but the options are sometimes not too easy to find. So:

    How To Write ISO Files To CD

    Free ISO burning apps:

    Standalone ISO Burner (Be sure to check the "Finalize" box.)
    [email protected] ISO Burner
    EasyISO
    BurnISO
    ISOBurn
    ISO Recorder for XP (Uses XP's burner and adds context menu - Vista version also available.)
     
  11. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/633802

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice