Backup or Replace a Windows Hard Drive Using Linux

Stephen Schultz
I write this article because I recently did this myself and thought it might be a fun article and could be useful. However, it should be noted that any and all computer repair actions you undertake are solely your own responsibility. That being said, I'll tell you the steps I used to successfully replace a Windows hard drive with an exact copy of itself.

Why did I do it this way? The software is free and this process makes and exact, bootable copy of the original.

Here's how it started: I had a 40 gig Windows XP hard drive that I wanted to replace with a bigger hard drive. Many things had been saved to that 40 gigger and I wanted to give it room to continue to expand.

Here are the tools I used: a Linux livecd, an 80 gig hard drive, and a little patience.

How to get and what is a livecd? You can see some of my other articles for more explanation, but a livecd is an entire operating system running on a cd. When a livecd is used you put in the cd and the hard drive doesn't run; your desktop, everything is coming from the cd and the computer's memory. This allows you to do diagnostics on the hard drive without actually using it.

What livecd did I use? I used Parted Magic livecd, but you can really use any Linux livecd. I like to use gparted to partition my hard drive, but it doesn't have to be done that way. I just find it very simple and it worked for me.

How does one get the Parted Magic livecd? It's free, save for the cost of a cd. Download the .iso file by going to their website or searching on the web. Once you have the parted magic iso image file, you must burn it as an image file to a cd. Slightly different than burning regular data, but is very easily done. Again, for the sake of this article, there simply isn't space to explain this process. Many tutorials on the web about burning an iso image file. For example, using Nero software, you would go to "Copy and Backup" tab then select "Burn Image to Disc." This creates a cd that automatically boots when the computer is turned on.

Oh, it should also be mentioned that your computer should be set to boot from the cd first, then from the hard drive. Most bios setups on most computers are defaulted to this, so I won't explain it too thoroughly. If your computer is not set to do this, search the web about changing your bios setup. Many entire websites are available to explain this step. It is a very simple step that can be easily taken care of.

Ok, once I had all this taken care of, I unplugged the computer's power, and then I opened the computer case. It should be noted that static electricity can be an issue, so wear a grounding wrist strap or ankle strap to negate this risk. I didn't, but I know that it can be an issue.

I had a hard drive in there already. On the back of a hard drive is a (assuming we are talking about an IDE rather than a SATA hard drive) plug in for power, a plug in for data (called a ribbon strip) and an area for jumper settings. Jumper settings (please check the pictures that go with this article) on mine were set to "CS" which is cable select. I was going to add another hard drive to back this one up, so I had to change the jumper settings. Usually this is on a sticker label on the hard drive. I changed the jumper settings to "Master" on this hard drive by moving the little jumper tab. I set the jumper settings on the new hard drive to "Slave" as was written on the hard drive. This sets my hard drives up as the original hard drive as the primary drive and the backup/replacement drive as secondary.

The secondary drive is then plugged into the secondary plug on the ribbon strip that the primary drive is plugged into. I then also plugged one of the power plugs into the secondary drive so that it is ready to go.

Are you with me so far? It may seem complicated, but if you take it one step at a time, it is really quite simple. I'm over explaining each step, but the entire process is really pretty easy to do.

Continuing, I was now ready to begin manipulating data. I plugged the power plug back into the back of the computer and turned the computer on.

I then had to hurry and put the livecd into the cd player. Yes, you could have simply put the livecd into the player then rebooted, but who has that kind of time? The secret is to get the cd in there before the computer decides "Ok, there's nothing in the cd player to boot from, I'm now going to boot from the hard drive." If you don't get the livecd in there in time, just reboot the computer till the livecd starts instead of the hard drive.

Now I've got Parted Magic livecd cooking along, getting everything running. It is a very fast, simple desktop, designed to focus its efforts on getting your hard drive set up.

Once the Parted Magic desktop was setup I wanted to look and see what was on the hard drives. I ran gparted which is the very first icon at the bottom of the screen. I'm including a picture of gparted doing its thing.

With gparted I check both cd's to see what was on them. My first hard drive (/dev/hda1) was already set with my Windows XP partition. I looked at the other hard and it wasn't set up the way I wanted, of course.

Here's where I ran a few different tools. I wanted to blank out that secondary hard drive so I used a tool called "shred" which totally erases a hard drive.

I should mention that using shred always make me a little more alert. Double, triple check everything before using shred since, once it's running, you are completely erasing the hard drive. Pick the wrong hard drive and there are no take-backs! All the data is gone.

As I was saying, I wanted to blank out that secondary drive and start from scratch. The shred command is something that is native to Linux, so it is amazingly easy to use (sometimes too easy if you've picked the wrong drive). The drive I wanted to "shred" was designated as /dev/hdb. Yours may be designated as something else, so be cautious and certain.

I opened a terminal on the Linux desktop. This is the Linux command line, second icon on the bottom of the Parted Magic desktop.

Once the terminal was opened, I ran "fdsik -l" without the quotes. That's fdisk command with the -l option (a lower case L, not the number one) to get a list of all the disks plugged into this computer. Just double checking.

Fdisk tells me that I have two drives plugged into this computer; the second drive is /dev/hdb. This is exactly what gparted told me but, again, just double checking.

I'm ready to shred. I type in "shred -vfx -n 1 /dev/hdb" without the quotes. That is just telling shred to overwrite the hard drive 1 time. I could tell it to overwrite 50 times for true erasing power, but I'm not trying to avoid the authorities, just clean the drive thoroughly. Remember, double check before you hit enter 'cause once shred is going, the damage is done.

After shred is all done I reboot the computer and re-setup Parted Magic.

I open gparted again and set my secondary drive (which is a now blank /dev/hdb) with a new partition. I create an NTFS file system (the default type with XP, but also the same as my /dev/hda1 partition). I now have a brand new, ready to go secondary drive. Whole process took me 15-30 minutes or so, depending on how long it took shred to do its thing (it's very thorough).

I reboot the computer and re-setup Parted Magic. Home stretch now: time to copy.

With Parted Magic ready to go again, I open up gparted, check everything out again, and get ready to go. I now know I want to data dump all the stuff from my primary hard drive to my secondary hard drive, both as partition one on their own hard drives.

So, I open a terminal again. I then run "dd if=/dev/hda1 of=/devhdb1 bs=32256" without the quotes. This tells the computer to data dump stuff from "if" to "of" and then tells it what speed to do it. Your /dev/ designations (short for "device," but you knew that, right?) may be different than mine, so check and be certain. Many websites out there on how to and specifics of data dump via a livecd, but this is the process that I used and have used it successfully on internal hard drives, external hard drives, Windows, Linux, etc.

I let dd run and do its stuff. While it's running there is NO indication that it is doing anything. Just move the mouse every once in a while so that you can see what is going on without the screensaver kicking in, then be patient. If you have big drives, it can take many minutes. I've never had this process take more than an hour though but, again, be patient.

Once the process is done there will be a list of what data was transferred and how successful it was. The terminal will go back to the command prompt awaiting further instructions.

I then reboot and get Parted Magic set up again. This is when I'm really glad that Parted Magic doesn't take a long time to load and is quite quick.

I look at gparted and see what is going on. By opening gparted on the new drive I automatically extend the new NTFS system into its new home, taking up the whole partition. I know this can be done with running extend via a Windows command line, but I find the gparted way much simpler and effective.

The new drive is ready to go! I then shut everything down, unplug the computer, swap the primary and secondary drive and set the jumpers on the new drive to "CS" just as the first drive was when we got started. I set everything back to how it was when I started, just with a new drive in there.

I then restart the computer (you plugged the power cord back in and took the livecd out, right?) and boot into my new system. I've found that I have had to on occasion let the system run a disk check and, occasionally, let the system re-authenticate itself. This is not a problem since I've only exchanged one piece of hardware and the authentication is still valid (it takes over 3 pieces of hardware changed to void the MS authentication, as I understand it).On rare occasion I've found that I need to repair the master boot record, or MBR, but this is usually a piece of cake and I'll sometimes do it just to get it out of the way. This shouldn't be an issue as the system is an exact copy, but by booting with an MBR repair tool you can fix this. There are many freebies on the market, just look around. One way to do it is run an Ubuntu Linux livecd, run this from terminal "sudo apt-get install ms-sys" without the quotes. This installs MS systems tools. Then run "ms-sys --mbr /dev/hdX" without the quotes, specifying which hard drive you want the MBR on in place of "X." There is a link to these instructions here.

As I mentioned, the new system may take some settling in by updating itself and running check disk on itself, but that is expected and even desired to get everything squared away. When all is said and done, a little bit of time and effort with almost no money you now have a brand new hard drive running your pc. Save the old drive if you want a backup or blank it out and use it somewhere else; the choice is up to you.

Hopefully this was all inclusive and helpful. Each aspect of these directions is available somewhere else on the web, I just hope I've given you a good compilation of data and some mildly entertaining reading. Good luck on all your computer endeavors.

Published by Stephen Schultz

Stephen Schultz has been in sports and fitness since the 3rd grade. Since receiving his degree in Kinesiology, he has been a personal trainer and trainer of trainers for the last 12 plus years. He has al...  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.