How do I save a disk image of my laptop hard drive?

Kurt Granroth plug-discuss at granroth.org
Fri Apr 6 08:02:30 MST 2007


Mark Phillips wrote:
> Knoppix "sees" hda1 and hda2 as they are available read only from the desktop. 
> One points to the Linux partition and one points to the Windows partition.  
> However, when I type mount at the root prompt, hda is not mentioned (nor hda1 
> nor hda2).
>
> There is also an hdc, but I can't seem to access it. Perhaps that is the swap 
> partition?
>
> I am so confused!
>   
Okay, it looks like you are getting bits of information here and there
that assume a higher level of expertise than you have.  I'll try to
break it down for you.

You are trying to save a disk image of your laptop hard drive.  This is
an IDE drive which, under Linux, is referred to has /dev/hda.  There are
two primary partitions on this drive.  Partition 1 (known as /dev/hda1
in Linux) is Windows and partition 2 (/dev/hda2).  You may have those
switched.  You likely have a swap partition (/dev/hda3?) but honestly,
it doesn't matter at all right now.  The /dev/hdc you are seeing is
almost surely your cd-rom drive.  You don't care about that at all either.

Your goal is to get a perfect image of this entire drive onto another
hard drive.  There are two parts to this:
1. Finding a way to "connect" your laptop drive and the new drive
2. Finding a way to create the image and copy it to the new drive

There are generally three practical ways to connect the old and new hard
drive:
1. Connect both drives to the same physical computer.  You already said
that you can't do that and with a laptop, it's not the easiest way
anyway, so we'll leave this option alone.
2. Put the new hard drive in an external enclosure (USB, usually) and
connect it to your laptop.  This is a really good option and makes a lot
of things a lot easier.  However, you would have to go buy an external
hard drive enclosure, take out the new hard drive from your other
computer, and install it all.  None of that is hard, but it does take a
little bit of geek knowhow.
2a.  Mind you, if your new drive *is* an external drive, then it's
trivial: Just plug it into your laptop.  This is, IMO, by far the best
option.  But you would have to go out and buy one
3. Connect to your new drive over the network.  You say you have the
laptop and your desktop and so I assume you have a local network in your
house that you can use to connect between your two computers.  Since you
likely have your new hard drive in your desktop computer, this is the
cheapest and best option.

So we have step 1 down: We're going to connect the old and new drive
over the network.  Now for step 2.  We need to find a way to create the
image and copy it over a network to your new drive on your desktop computer.

There are some dedicated products for doing this but, honestly, I don't
have any experience with them.  Most of them assume that your new drive
is physically hooked to the same computer or is in an external
enclosure.  Most will not copy over a network.

I recommend using 'dd' to make the disk image.  The 'dd' command is a
command line utility which will make a block by block copy of your hard
drive.  That's exactly what you want.

But how to get it over the network to your new drive?  We'll use 'ssh'
for that.  I'll be following George's example from here on out but
explaining it a bit more.

1. Make sure that you have SSH enabled on your desktop box.  You can
test this by 'ssh'ing from your laptop to your desktop.  What is the IP
address of your desktop?  Something like 192.168.1.100?  You can check
using the command '/sbin/ifconfig eth0' in a window on your desktop. 
Open up a terminal or shell window on your laptop and type this:

  ssh root at 192.168.1.100

Change the 192.168.1.100 to whatever your actual IP is for your
desktop.  Enter your desktop's root password when it asks.  If that
works, then you have ssh connectivity.  You can safely logout of the
'ssh' connection.

2. Make sure you have enough space on your new hard drive.  Open up a
shell or terminal window and type 'df -h'.  Is there enough space on
your disk to contain your entire laptop drive?

3. Now to start the copying process.  Using a livecd like Knoppix
(recommended), boot your laptop.

4. After you login, type this command:

dd if=/dev/hda | ssh root at 192.168.1.100 "> /laptop-backup.img"

Change the 192.168.1.100 to whatever your desktop's actual IP address
is.  Otherwise, type it *exactly* like that (even with the quotes).

This step will take a very long time.  How long... well, it depends on
how fast your network is.  I would guess something like (size of your
laptop drive in megabytes / 10) seconds.  So if your laptop drive is
60GB, then that's 60,000 MB divided by 10 is 6000 seconds or 100 minutes
or 1 hour, 40 minutes.  Like I said, a very long time.

When you are done with all that, you will have a perfect image of your
entire laptop drive stored in the file 'laptop-backup.img' on your new
drive!

Let me know if any of that doesn't make sense or if I made some wrong
assumptions.

Kurt


More information about the PLUG-discuss mailing list