GNU/Linux distributions have many different uses. Over the years, the software has claimed many different roles, from the usual Internet server to high-end animation workstations, proving itself capable of undertaking almost any computer-related task.
One special feature of GNU/Linux--that it can run from a read-only system--has surfaced in the last few years as LiveCDs. Though credit for the popularization goes to the famous multimedia LiveCD Knoppix, the concept belonged to the late 1990s. Slackware and Red Hat had always produced LiveCDs for installations and basic troubleshooting, but the self-configuring LiveCDs started with the Linux Bootable Business Card (BBC) and peaked with Knoppix. LiveCDs supply users with a full-blown operating system; not only the bare-bones command prompt, but also the eye candy GUI, a whole range of applications (more than 2GB on a single CD), full networking support with browsers and instant messaging, the ability to read to and write from Windows shares, and, perhaps most importantly, easier hardware configuration.
The GNU/Linux community embraced the new LiveCD, using it in everyday tasks including showing off to Windows users. After some time, even some Windows admins began carrying Knoppix CDs to use in case of emergency. This was not enough for some developers, especially those who appreciate lean and mean systems. Thinking that 700MB is just too big, Damn Small Linux strips Knoppix to the bare minimum and builds up from there, supplying a GUI-based, self-configuring desktop plus troubleshooting LiveCD within just 50MB. DSL produced the leanest, meanest Linux LiveCD.
Inspired by DSL, Feather Linux concentrates on desktop workstations, including a media player capable of playing everything from MP3s to DivX movies. In 64MB (14MB more than DSL), Feather also supplies more troubleshooting and emergency utilities.
With its small footprint, Feather Linux downloads in just over an hour on a 128Kbps line. It is even possible to download via a 56Kbps modem, making it the ideal emergency LiveCD for almost everyone. Its low resource needs makes it an ideal distro for recycling legacy PCs with modest hardware, even machines with 486-DX100 CPUs or 48MB of memory. There are also active Feather Linux forums.
To demonstrate how well Feather Linux works as a rescue CD, I'm going to pose a common administrative problem and demonstrate how to solve it with the LiveCD. Think of it like a MacGyver computer exercise, with a Feather CD as the Swiss Army knife. While doing this, we will practice the Unix Way, taking full advantage of its tools: bash, Perl, pipes, redirections, and the rest of the arcane Unix heritage.
(For those with low bandwidth, most of the things described here are possible not only with Feather Linux, but also with Knoppix or most of the other Linux LiveCDs you may already have. We like the lean, mean method, but using Knoppix would not be overkill.)
GNU/Linux systems have always provided good backup solutions. Suppose you want to erase your Red Hat 9 partition and install Debian Woody instead. In the common case, all you have to do is to back up /home to have all your default userspace files and configurations. /etc and /var may also be handy. Then install Woody.
This is the simpler of the two basic approaches.
Another approach is to back up the partition as a whole: the operating system, the user files, and the configurations (if they are on the same partition). In this case, whenever you want to revert to your old system, you can restore the image.
This second scheme is more delicate. First, you need a host operating system from which to restore the image. In fact, you may not be able to make the snapshot easily from the live system, so it's possible you can't do this at all from your current operating system.
Obviously you'll have to use a boot disk or CD or another OS already
installed. That's why we have this nice, tiny Feather Linux LiveCD ready. You
also need a program to make an image from a disk and something that can restore
an image to a disk. You can use
dd to do this the pure Unix Way, but Feather Linux has a wonderful disk imager called PartImage. Written by
Francois Dupoux and Franck Ladurelle, PartImage has two very nice features:
Unknowingly, you have everything ready! You can use
in the traditional "restore the backup image from a network drive" way, or you
can use its client-server installation method. The fascinating thing is that the
developers of PartImage even thought of encrypting that server-client
Enough theory. Let's start the first Feather Linux mission: to back up and restore an entire partition.
First, boot your computer with Feather Linux. Chose the "boot from CD" option in your BIOS, if necessary; insert the CD; and start. The boot prompt is the regular Knoppix one with different clip art. At the prompt, I prefer to write:
knoppix 2 toram
knoppix 2 boots Feather Linux into a black terminal screen, not
the GUI, supplying the fastest boot.
toram tells Feather to copy
the disc to RAM and operate from there. This avoids the CD-ROM from spinning
whenever you start a new program. Second, it allows you to eject the Feather
CD and even burn the image to a CD. If you have more than 96MB of RAM, I strongly
advise you to use this option.
Here comes another basic problem. You have booted from Feather and will take the backup image of the partition, but you need some place to put it. It wouldn't be very wise to put the backup into the same disk, so a better option is to store it somewhere on the network.
The method of transfer varies; you can use SSH, FTP, or even Samba. Let's do the hardest and presume that we have a Samba server or a native Windows share on the network. The first step is to make a mount point:
# mkdir /root/mnt/k
Next, mount the share:
# mount -t smbfs -o username=user1,password=pass //192.168.1.190/E$ /root/mnt/k
This is the regular way to mount a windows share (E$) via Samba to the filesystem under /root/mnt/k.
partimage from the shell produces something similar to the result shown in
Figure 1. From there, choose the partition from which to make the image. I
advise non-English users to use the default C locale, because I experienced
problems using the
lang=tr option. This may be due to a conflict
with the Turkish locale and
partimage. Otherwise, you may not be
able to use the regular arrow keys to navigate in the menus.
Figure 1. Choosing a partition to back up
After choosing the right partition, decide on the image name. Then choose whether to back up to an image or restore an image. After the configuration, press F5 to proceed to the next screen.
Now you have the choice of a compression algorithm, as seen in Figure 2. I prefer to use gzip or no compression. Unless you have to fit the image into a limited space on a CD-R or such, I advise against using bzip. Though it will bring superior compression, it may not be worth the effort, especially if the partition has lots of multimedia files.
Figure 2. Choosing a compression type
If you want, you can divide the image into pieces. Again, this is useful for writing onto removable media or if the destination drive is a VFAT partition. (FAT32 has a 2GB file limit.)
The next prompt, shown in Figure 3, asks for an description of the saved partition, and then the imaging process begins. The length of this step depends on the size of the partition and the compression algorithm. In my tests it took 45 minutes to save the image of a 15GB NTFS partition without compression.
Figure 3. Describing the backup image
partimage can save many different partitions, including
ext2/ext3, FAT16/32, Reiserfs, JFS, HPFS, UFS, HFS, and NTFS. NTFS support is
still experimental, as the PartImage web site explains:
The NTFS (Windows NT File System) is currently not fully supported: this means you will be able to save an NTFS partition if system files are not very fragmented, and if system files are not compressed. In this case, you will be able to save the partition into an image file, and you will be able to restore it after. If there is a problem when saving, an error message will be shown and you won't be able to continue. If you have successfully saved an NTFS NTFS partition, you shouldn't have problems as you restore it (except in the case of bugs). Then the best way is to try to save a partition to know if it is possible. If not, try to defragment it with diskeeper or another tool, and try to saving the partition again."
There is little risk; if you can take the image, you can restore it. Figure 4 shows a happy success screen.
Figure 4. A successful backup
You may prefer to use
partimage from the command line, without the GUI. To
take an image of /dev/hda4 with compression and save it to
/root/mnt/k/imagefile, the command is:
# partimage -z1 -o -d save /dev/hda4 /root/mnt/k/imagefile
To restore the image, use:
# partimage restore /dev/hda4 /root/mnt/k/dosya
Let me remind you that if you want to restore an NTFS partition, you have to make some adjustments after restoring and booting from the Windows boot CD. That process is beyond the scope of this article.
If this is a Linux partition and you are using LILO as your bootloader, then you should reinstall the LILO, booting via Feather:
# mount /dev/hda4 /mnt/new # chroot /mnt/new # /sbin/lilo
With this done, you can now take an image of almost any partition and restore it. Don't forget that this is a last resort, not a regular backup option.
KIVILCIM Hindistan works as a full time computer security consultant with a CISSP, using Linux and Free Software as weapons of choice.
Return to the Linux DevCenter
Copyright © 2009 O'Reilly Media, Inc.