Simple clear advice in plain English

Backup and restore

Find out how to back up and restore your disk partitions in Linux

Last month we saw how it’s possible to make a complete copy of a partition using the standard Unix dd tool, and how this is useful to back up an entire filesystem, no matter which type it is.

This month we are going to look a little more into this area, at a couple of other tools that can come in handy and how to detect problems with your hard drive.

As we saw last month, the major benefit of using dd is that it duplicates every single raw byte of data on the partition (be it a traditional hard drive or USB stick), enabling you to restore it all again, preserving the original exactly. This also leads to a major drawback: when you duplicate a drive or partition in this way, the copy needs the same amount of space as the original. When the filesystem you wish to copy is full, this may be not be an issue. But if you have a 500GB partition that has only 10GB of data in use, having to duplicate 490GB of empty data seems wasteful in terms of the storage requirement and the time it takes to copy such an amount.

A tool that deals with this problem well is Partimage ( This handles partitions superficially in a very similar way to dd, in that it can create an image file from a partition which can then be restored later. The advantage it has here is that Partimage copies only the data that is in use on the filesystem. With that 500GB partition, the resulting image will be 10GB (with perhaps a small overhead).

Naturally, since only used data is being copied from the partition, Partimage needs to understand the filesystem it is backing up. In that respect it is really nothing like the dd tool, which is completely ignorant of the filesystem, and deals only in raw data. Partimage supports the major filesystems used with Linux, however, such as ext2, ext3 and ReiserFS. FAT16/32 is also supported, which is commonly found on USB sticks and older Windows installations. Additi onally, the image that Partimage creates tends to be very suitable for compression with standard Linux methods, like gzip and bzip2, and this facility is built into the Partimage application.

Partimage is a menu-driven terminal-based application, and as such is run from the command line. Despite not having a modern graphical interface, it is very easy to use. Enter ‘partimage’ at the shell prompt to start it up. The tool needs direct access to storage, so you will almost certainly need to be logged in as root to use it.

The attached image shows a list of partitions found, in the usual /dev/sda, /dev/sdb style. Each entry lists the filesystem type and the size of that partition. Use the tab key to switch to different sections of the screen; Shift & Tab can be used to go the other way. All that needs doing first is to choose whether to back up a partition or to restore from an image file, and to enter the path of the image file to create or use. When backing up there are a few more options.

On the next screen, select the compression level to use: gzip is probably the best option; it is much faster than bzip2 and will compress almost as well, in most circumstances. Now proceed to the final screen where Partimage will present a summary of information about the filesystem, including the amount of space used on the partition. Next, Partimage will begin copying the data, giving a progress indicator, as well as the current size of the image file for backups.

Never try to back up or restore a partition which is in use, particularly the partition you are running your operating system from. For that reason, Partimage needs the partition you are working on to be unmounted. This presents a problem if you want to back up or restore your operating system partition. The way around this is to use an alternative boot method, the easiest of which is a live CD. Here, since you are running the operating system entirely from a CD, you can work on any hard drive partition without restriction. There are several Linux distributions dedicated to this kind of task, and one good one is Parted Magic ( This very small (50MB) distribution contains Partimage together with several other recovery tools, and is designed to work on older computers just as well as newer ones.

Article tags

Reader Comments


Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles


Get VirtualBox working in Ubuntu Linux

Virtualbox is great if you need to get Windows apps working in Ubuntu but it may need help to get working


Tame the Ubuntu 11.10 Unity interface with MyUnity

Customise how the Unity desktop looks and works


Compress files with 7-zip

Extract files from and create your own compressed folders

Question & Answer

Q.How can I re-enable items that I have disabled with...

> Read the answer

Q.How can I stop Ubuntu launching as the default operating...

> Read the answer

Q.Is it possible to stop internet access to one of two...

> Read the answer

Best deals on the web


Dell Inspiron 620 (D006250)

£349.00- Buy it now


Apple iMac 21.5" (MC309)

£926.60- Buy it now


Dell Inspiron 620 ST Intel Core i3-2100 3.10GHz / 3GB / 500GB / DVDRW / Win 7 Home Premium

£329.00- Buy it now

Latest issue & subscription deals


Which is your preferred web browser

Jargon Buster

Computing terms explained in plain English

Virtual drive

A set of files seen by Windows as a separate hard disk.

Great shopping deals from Computeractive