a. Copy all files and directories
b. Copy the image of a disk or logical partition
The first option is cool, if someone want to practice old style procedure using UNIX like commands in the open terminal. I could find instructions in “Linux Complete Backup and Recovery HOWTO” and “Howto: Backup and restore your system”.
However what I wanted was simple and easy tool to backup and restore my OS image in a snap! as with Ghost. Furthermore, I wanted to backup other OS or disk images such as the disk I assigned for Windows Vista and shared files between OS’s. That was the second option. I found three commonly used tools in Linux.
a. G4L (Ghost for Linux)
b. Partimage (Partition Image)
Any one of these three tools looked promising to me. G4L has many options from copying only portion of file to network backup. CloneZilla looked perfect choice if I needed to clone Jaunty from central management server to many company-wide desktop as in Enterprise Desktop Management System. However, I chose Partimage because it seemed one of the most popular(G4L seemed also popular) and simplest in terms of menu and usage. Most of all, I install directly from Synaptic Package Manager without any adjustment.
After I selected my tool, I needed to make bootable version of Linux to be used at restore time. Most of the cloning tools have its own CD image for this purpose with small and light version of Linux. But I didn’t want to create CD because it’s just not as portable as my USB thumb drive which I carry most of the time. Even some Laptop does not comes with CD/DVD drive, right? So, I decided to created portable USB Linux for emergency. There might be several scenario to prepare emergency USB Linux.
1. Making Ghost like USB Linux from existing USB Linux.
If someone already have Debian compatible Linux on USB thumb drive, it is easy. After booting from USB Linux, invoking
sudo apt-get install partimage
command will make your thumb drive to be a Ghost like tool. (I also recommend you to install gparted.)
2. Creating new USB Linux using “USB Startup Disk Creator”
If you do not have USB Linux, and if you want to install same Ubuntu as you're using now, it is still easy. Using “USB Startup Disk Creator” in System/Administrator menu will solve your problem easily. Maybe you already used this tool, when you install Ubuntu to your Laptop without CD/DVD drive. All you need is ISO image of Ubuntu and USB drive with at most 2G. After you select source image and target USB disk, pressing “Make Startup Disk” will create USB Linux. All you need is reboot with the USB disk and install Partimage using command above.
|From Better than nothing|
3. Moving RescueCD to USB thumb drive
This option need several steps.
1) Download CD image
Another way to create Ghost like tool is using CD image provided by tool creator’s web site. Because I selected Partimage, I could download CD image called RescueCD from web site. (Or, just click RescueCD to download)
2) Create partition
Then I needed to make new partition to install Linux on my USB thumb drive. Because fdisk does not provide resize feature, and parted still does not accept creating ext3 type, I prefer gparted. And maybe, above all the reasons, nice GUI of gparted attracted me most. If you do not have gparted already, you can install it using following command.
sudo apt-get install gparted
There are options, though, when you create partition for USB Linux.
b.ext2 or ext3
Most people choose FAT32 when creating a new partition for USB drive. Because it only use single allocation table in top of the file system rather than tree structured nodes, it usually seems more robust and safer for removable disk. However, it is quite inefficient when it comes with small sized files. So, I created ext3 type partition for my USB Linux with 250M in size. (because the size of image is around 234M). If you plan to use FAT32, you may need another 100M or more.
3) Mount CD image and USB drive
Once partition is ready, mount downloaded image and USB drive using following command.
sudo mount -t iso9660 -o loop=/dev/loop3 ./systemrescuecd-x86-1.1.7.iso ~/mnt1
sudo mount -t ext3 /dev/sdb2 ~/mnt2
4) Copy all files in CD image to USB drive
sudo cp -af ~/mnt1 ~/mnt2
5) Make USB Linux bootable
Because CD image comes with isolinux, which is boot loader for CD, more precisely ISO image, and because syslinux can only be used with FAT32 file system, I had to use Grub to make my USB Linux bootable.
grub-install --root-directory=/media/disk/ /dev/sdb2
(where /media/disk is mount folder and /dev/sdb2 is device for USB disk.)
Then, I was able to boot from USB Linux and to use Partimage.
4. Using DSL (Damn Small Linux)
Another Debian based Linux and one of the smallest is DSL. It only occupy 50M of disk space, but only comes with X. So, unless you are not going to use gparted which is partition tool of my choice, this might be another option. I believe that the preparation procedure is similar to what I described in 3. However, I love gparted and I want it to be installed in my USB Linux. So I did not tried this option.
|From Better than nothing|
Backup and restore using Partimage was really simple, once I booted from USB. After I started Partimage by typing "partimage" and pressed return, the above screen was shown. Then, I typed in the location where to store backup image after “image file to create/use,” and pressed F5. (Backup is default choice)
|From Better than nothing|
I kept the default options and pressed F5, then entered some comment. Finally, it started to backup my Jaunty. The result image was almost halt the original size. Restore from image is almost as simple as backup. After I entered image name and selected “Restore partition from image file” using TAB and arrow keys, I was able to recover Jaunty from stored image.
Finally you need to backup your partition table in safe place to prepare recovery from the lost of entire disk, not from single partition.
sfdisk -d /dev/hda > /media/disk/saved_partition_table
If you loose entire partition table, recover it from this file using following command.
sfdisk /dev/hda < /media/disk/saved_partition_table
You can find more information from "Partimage-manual Backup-partition-table."