How to clone a HDD to a larger disk using linux.
http://123pab.com/blog/2013/02/how-to-clone-a-HDD-to-a-larger-disk-using-linux.php
by Peter A. Belmont / 2013-02-04
If you want to clone a hard disk using UBUNTU, readthis valuable advice. The rest of this essay is a report on my own experience. Intro
I was pretty much a LINUX-BEGINNER (“Newbie”) when I started this, and made much use of Google at every point. I advise any other Newbie to do the same. Don’t Trust what you read here—verify (as far as you can) on the internet. I also had much advice from a very patient advisor, whom I thank here without naming. My project, described below, was to clone the data and partitions from a small (250GB) disk onto a much bigger one (1TB) and also to enlarge some of the partitions. Happens my disk was “dual-boot” for Windows and Ubuntu, a Linux variety. I learned to make the initial copy (of the entire 250GB disk) via “dd” or “ddrescue” so as to get everything including the MBR, and to correct disk errors, if any. I did it by having the new disk as EXTERNAL and the existing, old, disk as INTERNAL. I learned to do all other tasks after exchanging the disks so that the new (1TB) disk had become internal for much of the re-arrangement of the partitions and subsequent copying. I learned that all disk manipulations regarding partitions pretty much must be done by use of a “live CD” for Ubuntu, that is, a CD from which Ubuntu can be run without using the INTERNAL (or EXTERNAL) disk except as data to be manipulated. And I learned that the newest “live CD” for Ubuntu (version 12.04) is a “live DVD” which does not immediately provide GPARTED, the Ubuntu partition editor, which is the workhorse for this project. (I used a “live CD” for version 10.04.) My Story – Long Version
I recently bought a Western Digital 1TB hard disk drive (HDD) and a (SABRENT EC-UEIS7) “caddy” to serve as an “envelope” for the hard disk so I could use the new HDD as an EXTERNAL HDD for my computer. My computer (a desktop) uses a 3.5” HDD, SATA, 7200 RPM, etc. The “caddy” was a 3.5” 7200 RPM device. (Laptops use a 2.5” HDD, I believe. Get it right!) My computer is set up for dual-O/S, and can run either Windows XP or UBUNTU, a version of Linux. I use UBUNTU and this discussion is entirely in terms of UBUNTU. My then-current INTERNAL HDD was 250GB. My hope was to copy the internal HDD to the external HDD, copying all data faithfully, with a view to exchanging the hard drives, so the 1TB drive would become internal and the 250GB drive would become the external drive and thus available for backup. By going to a huge (for me!) 1TB drive, I wanted both to get space for many more partitions on the new HDD and also to increase the useful size of the copies of the existing partitions. Here’s my advice to anyone attempting the same operation. How To Clone a HDD
[0] Be VERY CAREFUL, because you can wipe out ALL YOUR DATA if you make a mistake. BACKUP all important data before doing this. [1] Place the new HDD into the caddy/envelope. Follow instructions carefully. (My caddy was usable for both IDE and SATA drives. Use the proper data and power cables.) [2] Attach the caddy by USB 2.0 cable to the computer. [3] Start the computer using a UBUNTU “live CD” which contains the partition-management tool GPARTED. Don’t “install” UBUNTU, just “try” it. Caution: recent releases of UBUNTU have grown so huge that they require a DVD to contain the “iso” file. The old ones (I use version 10.04 LTS) fit on a CD and can be loaded on my small (by current standards) RAM. Live-CD UBUNTU, when run in “demo” or “try-me” mode, must create the entire file-system in RAM since it does not mount or use any part of the internal (or external) HDD (other than SWAP space on the internal HDD). [4] Run GPARTED. You will see all the partitions on your internal HDD, which will be called “a” (that is, a SATA HDD will be called “sda”). You will see an empty external HDD, in my case called “sdb”. ”A” is the name of the first internal HDD. there could be more than one. I only have one. “B” is the name for the next HDD, in my case the external HDD. Other types of HDD (say IDE HDDs) might have names such as “hda”, “hdb”. [5] Now be VERY CAREFUL, because you can wipe out ALL YOUR DATA if you make a mistake. BACKUP all important data before doing this.”b))) [6] Use GPARTED’s [7] Open a UBUNTU terminal and then excute one of the following commands: Sorry! Open a UBUNTU terminal and then execute one of these commands: BTW, I used “ddrescue” rather than “dd” on the thought that my old 250GB HDD might have bad sectors that needed rescuing. Both “dd” and “ddrescue” will do two very valuable things for you. They will copy the (invisible) MBR (master boot record) and they will copy the “ntfs” partition on which your WINDOWS system resides. They will copy everything because they copy bit-by-bit, exactly. [8] If your “live-CD” does not have “ddrescue” installed, you must install it. First, click Then quick-search “ddrescue” (without quotes) and do the rest of software installation (equivalent to typing [9] The “dd” or “ddrescue” copy will take a long time. Mine (for a 250GB /dev/sda) took 2-1/2 hours as I recall. It takes so long in part because data transfer with the4 EXTERNAL HDD (to which you are copying) is quite slow. [10] After the copying is complete, GPARTED should reveal that a very exact and precise copy was done. [11] Now do the hardware-switch. Turn everything off. Detach everything from any electric source. Remove the HDD from the “caddy”. Remove the old HDD from the computer. For this, I grounded the computer chassis, using a wall electric-socket, and I also grounded my hands using an anti-static preventing wrist-strap.. Sparks can irreparably damage certain parts of a computer. Why take a chance? So, all anti-static and grounding in place, remove the internal HDD and replace it with the just-copied former external HDD. In my DELL VOSTRO 200, the removal of the SATA power cable and SATA data cable were simplicity itself, and so were the removal of the HDD, the replacement of the new HDD, and the replacement of the cables. Place the old HDD into the “caddy” to use as a BACKUP. You do not need it any more for this exercise. [12] Now you (may) want to make your partitions bigger and to make new partitions and so forth. Here is how I did it. Use your “live-CD” again, because it is hard to do partition work if the partitions are in use (“mounted” in linux lingo). Use GPARTED again. [13] RESIZE your old EXTENDED partition until if occupies all the rest of your new and much bigger HDD. Delete the old Linux-SWAP partition and create a new one at the end of the now very large EXTENDED partition. [14] If you want to enlarge an existing partition, or merely to move an existing partition, proceed as follows. First, create the new partition in all that empty (unallocated) space in EXTENDED. Make it bigger than what you are going to move or copy or whatever. Second, use GPARTED’s COPY/PASTE to copy the data from the existing partition to the new and larger one. Do not use “dd” or “ddrescue” for this copy! They will do a bit-by-bit copy into the new larger partition, and the file-system they copy will not make use of all that new extra space! [15] After the GPARTED’s COPY/PASTE, you should have a good copy of your old partition. You can test this by creating a directory, say in your “Home Folder”, say “newpart”. Then mount the new partition (say /dev/sda10—GPARTED tells you what its name is). [16] Get out of “live-CD” and restart your real Ubuntu system. [17] Your real system still has its old FSTAB and therefore still mounts the old (pre-copying) partition for whatever you changed, in my case “/home”. Fix fstab so it knows where to find the new, copied partition. In my case, I had a separate partition for “/home” and from the old “/home” (/dev/sda7) I had made a larger partition and copy, /dev/sda13. So CAREFULLY edit fstab (after making a copy!) If you change FSTAB, then the change will not take effect until you reboot, so immediately reboot the computer. Otherwise whatever you do next will be recorded in the old partition (especially if that was “/home”) and you’ll lose it when you next reboot. [18] After you are convinced that your copy was successful and you’ll never want the old partition again, you may use GPARTED to delete it. This will create space in the EXTENDED which can be used, in later years, to resize nearby partitions which you did not move. [19] there is no step 19. You’ve done it. |