Open-source HDD imaging software?

jonessoda

Golden Member
Aug 3, 2005
1,407
1
0
Okay, so I'm running Kubuntu Dapper and my sound doesn't work, and wanted to do some experimenting with FC 6 and Ubuntu Edgy. Now, last time I tried Edgy, though my sound card worked perfectly (it was a known issue with my audio chipset that they'd fixed with Edgy) whenever I tried installing my video drivers, it wouldn't boot up again after a reboot. So I had to reinstall again, which was kind of annoying since I'd got it just where I wanted it otherwise. So, I'm looking to do something like Ghost and copy my HDD as some image file, so if neither work better for me, I can just format and image my HDD.

I have a portable hard drive that is far bigger than my HDD, so space to store an image isn't an issue. I have no proprietary software, so licensing isn't an issue. I just haven't been able to find any open-source software to image my HDD. Any ideas?
 

phisrow

Golden Member
Sep 6, 2004
1,399
0
0
There may be more elegant solutions; but dd should work.

dd if=/dev/hda of=/mnt/sda/image.img

Replace /dev/hda with the block device that corresponds with the drive you want to clone(probably hda for first IDE disk, probably SDA for newer SATA drives)
Replace /mnt/sda with the actual path to your external drive and image.img with whatever you want to call the image.

To restore, you reverse the process:

dd if=/mnt/sda/image.img of=/dev/hda

http://www.rajeevnet.com/hacks_hints/os_clone/os_cloning.html goes into a fair bit of detail and offers some useful tips; but those suggestions are tailored to more complex situations.

The other thing you can do is tar up your entire system for storage and then untar the result on a formatted disk to reinstall. You'll need to reinstall grub; but that would allow you to move between disks of different sizes.
 

jonessoda

Golden Member
Aug 3, 2005
1,407
1
0
I have sda, sda1, sda2, and sda5... any idea which of those I'd want to dd on a standard kubuntu installation?

Edit: those are all /dev/sda*. Also, they all show sizes of 0b.

Edit: looks like /dev/sda1 is my main drive, but do I just want to dd /dev/sda?
 

phisrow

Golden Member
Sep 6, 2004
1,399
0
0
/dev/sda corresponds to the first physical SATA/SCSI disk. sda1, 2, and 5 are partitions. I'd bet that 5 is swap and the other two are / and /home; but you should check your fstab to be sure (cat /ect/fstab will show you what devices are mounted where).

In any case, you want to dd if=/dev/sda of=/media/Name_Of_Your_External_Hard_drive/image.img

In Ubuntu, anyway, removable external drives are automatically mounted under /media/. Other distros may do it differently, with /mnt being another common place. For the of= portion of the command, just substitute the mounted path of your external disk.

What this command actually does is read from your primary disk bit by bit and transfers the bits to a file on your other hard drive. /dev/sda is a way to access the raw bits on the drive, whereas / is the mounted filesystem.

Incidentally, there are a few fun things connected to the /dev/* area. If you want to make a CD image out of a physical CD in Linux, you can simply dd if=/dev/cdrom of=~/cdrom.iso This will produce a cd image from whatever is in your drive at the time, and put it in your home folder. This also works for floppies, zip disks, etc.

In the domain of Stupid Linux tricks: Open a Terminal, enter cat /dev/audio . Depending on what you happen to be playing at that time, the output will look significantly different. It's a poor man's visualization. catting /dev/mem into /dev/audio can be amusing as well.
 

jonessoda

Golden Member
Aug 3, 2005
1,407
1
0
That's pretty good information, thanks. But... if it copies my entire hard drive, it seems to me that, since my portable HDD will be mounted in that hard drive (it usually mounts as /media/sdb1), it would try to copy itself and end up in an infinite loop... I guess that doesn't happen... does dding a hard drive ignore extra mounted media?

edit: tried the cat /dev/audio trick, just ended up outputting groups of question-mark-in-diamond characters.
 

phisrow

Golden Member
Sep 6, 2004
1,399
0
0
Ah, that's the tricky bit. With the dd command we've been discussing, we are actually approaching your hard drives in two quite different ways.

The Linux filesystem is organized in a hierarchical tree from / on down; but this has only a very loose relationship with where the data are on physical devices. In this case, you external drive (mounted at /media/sdb1) is lower in the hierarchy than your primary hard drive (mounted at /); but this does not mean that your primary hard drive contains your secondary hard drive. The linux filesystem hierarchy is a virtual filesystem. / and /media and all the others don't really exist on a disk in the usual way. Disks are mounted on these locations, according to /etc/fstab; but the / hierarchy is a system wide, independent construct.

That is to say that, when accessed through /dev/sda, your primary hard drive contains absolutely no data from your secondary hard drive, so you won't encounter a loop.

I'm sorry if my explanation is poor. Have a look at http://www.uwsg.iu.edu/UAU/filesystem/ for the messy details.
 

jonessoda

Golden Member
Aug 3, 2005
1,407
1
0
OFFS

My portable HDD is apparently formatted FAT32... I should have remembered that. I remember being unable to load full-size dual-layer DVD ISOs onto it... so my HDD image is too big to be put onto it. Any workarounds?

Edit: I think I'm just going to reinstall and hope for the best... and if worst comes to worst, reinstall again. Oy.

Edit: I guess I won't, because it seems both my Xubuntu and Fedora Core 6 downloads were corrupt. *sobsobsob*