If you use Windows XP/Vista, it might object to a new hard disk as part of its Windows Genuine Advantage system, and you might have to revalidate online. Once the cloning has finished - it will probably take an hour or more, depending on the size of the original hard disk - you should shut down the computer, remove the old disk (you must disconnect the old disk before you can continue!), and boot from the cloned copy to test things. Otherwise, you might well overwrite the data on your old disk! It’s extremely important that you ensure you get the old and new disks in the right order. Add the -v command option to provide a status report as the command progresses: Use ddrescue by first specifying the old hard disk, then the new hard disk.
Then click the Close button, and agree to refresh the list of software when asked.Īfter this, type sudo apt-get install gddrescue at the prompt to install ddrescue. Click System -> Administration -> Software Sources, and put a check in the box alongside Community-maintained Open Source software (universe).
However, before doing this, it’s necessary to enable the Universe software repository (of course, you will need to use NetworkManager to get online too, if you haven’t already). Although the computer is running the Ubuntu install CD live distro mode, it’s still possible to install additional software from the online repositories. This needs to be installed because it isn’t a default system tool. Now that we have this information, we can install ddrescue and use it to clone the disk. You can ignore the handful of minor errors that are reported. When cfdisk starts, type W (note that’s Shift+w) and then type yes to write a blank partition table. If necessary, replace /dev/sdb with the details of the new hard disk you discovered earlier. Then type sudo cfdisk -z /dev/sdb to start the cfdisk partitioning program, which we’ll use to write an initial partition table to the disk. Look for the reference to your new hard disk and make a note of it. Yours will probably be similar, if not identical. It should be obvious that, on my test computer, /dev/sdb is the new hard disk because it has no partitions (it “doesn’t contain a valid partition table”), while /dev/sda has the standard partition layout of an Ubuntu system. Beneath each heading is technical information about the disk, and beneath that the partitions on that disk are listed. Two hard disks are listed in the results: look for the headings Disk /dev/sda and Disk /dev/sdb. Here are the results from my test system:ĭisk /dev/sdb doesn't contain a valid partition table
This will avoid confusion when partitioning.Īfter all this, open a terminal window, and type the command sudo fdisk -l, which will scan the hard disks and list their partitions. Third, remove any USB memory sticks, card readers, or other kinds of attachable storage, such as MP3 players or mobile phones. Ideally, you should check the Windows filesystem for errors too. Second, it’s a good idea to check the filesystem of the original hard disk for errors and possibly enact repairs. The instructions that follow involve drastic fundamental disk management and the possibility of data loss. First, back up all valuable personal files to CD/DVD-R/RW disc, a USB keystick, or an external hard disk. Preparing to cloneīefore starting, it’s a good idea to do three things in preparation. At no point in the process do you need to boot into your standard Ubuntu installation, apart from to test the cloned disk at the end. Note that all the following stages are carried out using the Ubuntu install CD’s live distro mode. To carry out the following instructions, boot from your Ubuntu install CD, and select Try Ubuntu from the boot menu.
It’s not a good idea to clone a hard disk that’s in use (any more than it’s a good idea to repair a car while it’s being driven), so you must use your Ubuntu install CD’s live distro mode. Third, once ddrescue has finished, you must use the Gparted utility to expand the disk partition(s) (assuming that the new disk is bigger than the old one, which is almost certainly going to be the reason for upgrading in the first place). Second, you must install ddrescue and then use it to clone the disk. First, you must discover how Ubuntu refers to the hard disks. This article is excerpted from the newly published book Ubuntu Kung Fu and published with the express permission of the publisher, the Pragmatic Programmers, LLC.