Using linux you can pull this off pretty easily with dd. dd is a Linux command line utility that allows you to mirror/copy a drive or a partition from a drive to either a file or another drive. It copies the partitions byte for byte, including any unused space on the filesystem.
Can I assume from your username and icon that you're using Ubuntu? :-) I'm assuming some knowledge here, so feel free to ask in the comments if you have any questions.
Note: If you're not using Linux and are on Windows, you have a few options. You can use dd for windows or boot from an Ubuntu disc/USB drive. You can then mount the file in Windows using one of the tools linked in the comments below.
Determine which partition you want to clone
So let's say the drive you want to copy is /dev/sda. (If it is an external drive, it might be /dev/sdb, /dev/sdc, etc...) For you to be able to mount it (the partition you're interested in) later, you'll want to copy the individual partitions, not the full drive image. If you already know which partition you want (ie. the 3rd partition, /dev/sda3), you can go ahead and skip this part. If you're not sure or want to check, use the fdisk tool to list out your partitions:
$ sudo fdisk -l /dev/sda
![example output](../../I/static/images/324293a511e6b5be1d579a955819463900052ff540db496eb3ad14155fd352e2.png)
You're probably interested in the largest one, measured in blocks. Let's say it's /dev/sda3
Copy the partition to a file
Let's assume that you want to copy that drive's contents to /media/thumbdrive/backup.img
Check out the man dd
manpage for details on what all the arguments to dd mean. I'll provide a working example here:
dd if=/dev/sda3 of=/mount/thumbdrive/backup.img bs=1M
Showing progress
dd does not normally give any output while it works, and it can take a long time. You can get dd to show its progress by sending it a USR1 signal. You do this with the kill command.
Open another terminal, and run
killall dd -USR1
dd will then output its progress in the other terminal.
Mounting the partition later
After the copy is done, you can mount that backup.img file as if it were a device, using the -o loop
option to the mount command. Let's say you want to mount it onto /media/backup:
sudo mkdir -p /media/backup # create a directory for it to mount onto
sudo mount -o loop /media/thumbdrive/backup.img /media/backup
ls /media/backup # you will see the files that are on the drive you copied
You can unmount the file later:
sudo umount /media/backup
Note that you can edit or add files inside backup.img while it's mounted. Changes will be persisted as long as you unmount properly.
Could I have the setup: --computer with its internal HDD --one of the partitions on the external HDD be boot-able --and the other partitions (or just images if I only wanted one partition) on the external be loop-mounts on the external drive back to the external drive? – willbuntu – 2012-11-23T15:53:37.093
Yes, I don't see any problem with that working – Edward Anderson – 2012-11-23T15:56:23.003
@willbuntu: You can always use Acronis True Image or Ghost if you want a Windows solution. There's also dd for Windows.
– Karan – 2012-11-23T22:40:04.590@nilbus: "You can still boot from an Ubuntu disc/USB drive and use dd to back up the partition, but you won't be able to mount it in Windows." - Why not? Free: OSFMount, P2 eXplorer, Sleuth Kit/Autopsy, ImDisk, VhdTool to convert to VHD and mount using Virtual PC or Gizmo Drive and so on...
– Karan – 2012-11-23T22:41:58.820@nilbus: (Contd.) Non-Free: Forensics software such as those from EnCase, FTK etc., Mount Image Pro and so on... There are any number of ways to access raw disk (dd) images on Windows.
– Karan – 2012-11-23T22:42:43.860@Karan very cool - good to know! – Edward Anderson – 2012-11-23T23:17:20.710
@nilbus: You can edit your answer as well, since future readers might skip the comments. – Karan – 2012-11-23T23:21:17.610
Great idea - done! – Edward Anderson – 2012-11-23T23:35:32.543