KNOW-HOW Partimage

Backing up partitions with Partimage PARTITION TRICKS

tasosk, Fotolia Protect your system and preserve your configuration with this powerful

tool. BY KRISTIAN KISSLING

inux users love to experiment creates some complications if you want dual boot or start a liveCD. Do not with new kernels, drivers, and to back up a system. The best so- mount the source partition intended for Lprograms, but as you may already lution is to configure the computer for the backup. know from personal experience, things dual boot. Boot the system from one par- can go badly wrong. If worst comes to tition, install Partimage on it, and use Installing Partimage worst, you might have to reinstall the this version to copy the other Linux par- The source code for version 0.6.5 is whole system. tition to the server. As an alternative, available from the Partimage website [3]. Although experienced Linux users typ- you could boot the system using a Live To unpack, copy the archive to a direc- ically take this in stride, the install and CD, such as SystemRescueCd [2], which tory and enter tar -xvjf partimage-0.6.5. the ensuing configuration are time con- still uses Partimage version 0.6.4. tar.bz2 at the command line. Before you suming, and time is a precious commod- In this article, I show you how to get start the build, check first to see whether ity for most people. Why not preserve a started with Partimage. you have fulfilled all the dependencies perfect copy of the system so you can listed in Table 1. restore your original configuration when Negotiations Note that you need the header files something goes wrong? Partimage consists of two components: a (-dev) for the libraries. If you are install- Partimage [1] lets you back up com- server (Figure 2) and a client. The server ing Partimage on OpenSUSE 10.2, you plete partitions – either locally or across runs on the remote machine, where you should read the box titled “OpenSUSE the network. The Partimage backup tool store your backup copy. Up to 10 clients 10.2 and Partimage” before continuing. (Figure 1) supports several Linux filesys- can log in to the server and save their For security reasons, only the parti- tems (including , , Reiser3, and data. Of course, you don’t need a server mag user account is permitted to create XFS), as well as FAT16 and FAT32. Once if you will be creating a local backup. on the target machine. You will you finish the backup, you can burn the The first step is to launch the client on need to create a partimag user on both archive to a DVD or CD set and restore the machine you want to back up. In my the source and target systems. your system from disk if disaster eventu- example, /dev/hda7 is the device I need The setup routine will prompt for the ally strikes. to back up. account name at the make install step Partimage does not let you save parti- As I mentioned, you will need to and use the name to create standard tions that are currently in use, and this launch a different Linux version from directories.

60 ISSUE 80 JULY 2007 WWW.LINUX - MAGAZINE.COM Partimage KNOW-HOW

Backing up partitions with Partimage PARTITION TRICKS

Figure 1: Partimage lets you back up partitions locally or across the Figure 2: The Partimage server listens on the network for client network. input.

Before you can run make install, you guarantee secure transfer of your data to the server, the client’s IP address and the need to configure the source code. To do the remote computer. backup path are both shown. so, change to the directory created when The server uses the certificates to you unpacked the archive and enter prove its identity to the client. To set this Client Access ./configure --prefix=/usr to store the up, change directory to /usr/etc/partim- On the client, enter sudo partimage to data in the /usr directory. aged, become root, and enter make cer- launch the client . On Ubuntu, Assuming the configuration works tificates. The software creates certificates I originally saw the message /dev/ dm correctly, you can then type make to with appropriate privileges below /usr/ inode not found, but pressing Enter a build the binary, before entering sudo etc/partimaged. Typing ls -la shows you couple of times got rid of this message. make install to install. what has happened. In our lab, the message had no effect on The typical approach is to keep press- operations. If the message bothers you, ing the Enter key throughout the instal- Listening Service you can use the following command to lation dialog. You need to do this on It makes sense to launch the server on create the matching device file: both machines. You can then launch the target machine before trying to log Partimage on both PCs – either as the in with the client. Working as root, cre- mknod -m 644 /dev/dm b 240 0 server or as the client. ate a new user. The client logs in with In our lab, I found out that Checkin- the privileges assigned to this account; To run the command automatically stall simplified the installation procedure in this example, the username is kris. when you boot your machine, add the on Ubuntu: Checkinstall automatically To make sure the server will grant kris command to your /etc/rc.local file. builds a package from the source code access, you need to add kris to your After launching the client, you should and then goes on to install the package. /usr/etc/partimaged/partimagedusers see a fairly self-explanatory input dialog Just enter sudo checkinstall instead of file. To edit the file, enter sudo su to use box (Figure 1). To start, specify the parti- sudo make install. the console with root privileges, then tion to back up. As mentioned earlier, Again, setup will ask you for the name launch your preferred editor and add an you need to make sure that the partition of the Partimage user. Make sure you entry for the name. is not mounted. To see which partitions close any package management tools If multiple users will be creating back- are currently mounted, type mount at you have running. ups on the server, you can add entries the command line. In the line below this, for their user accounts – one name per you need the path to the backup direc- Security line. Partimage needs a user with the tory, so enter a name of your choice and It is a good idea to create SSL certificates same name on the target system on add GZ as the suffix. and store them in /usr/etc/partimaged to which the server is running. Server side, you still need to create the OpenSUSE 10.2 and Table 1: Dependencies directories in which you will store your Partimage backups. Make sure you have enough Program Header files Although I was able to build the source free space on the disk to avoid unpleas- code on OpenSUSE 10.2, I was unable OpenSSL libssl-dev ant surprises. You should also modify to access files on the SUSE Partimage Libnewt libnewt-dev the permissions to prevent access to the server from a Ubuntu machine. The Libmcrypt libmcrypt-dev directory by unauthorized users. server wouldn’t let me log on and kept Liblzo liblzo-dev Finally, type sudo partimaged to complaining about an incorrect pass- Libslang2 libslang2-dev launch the daemon – note the d at the word. I was unable to pin down the bug, Libbz2 libbz2-dev despite intensive searching, so I used an Zlib zlib-dev end of the name. A blue background ap- older version of Partimage (version Checkinstall No header file required. pears, showing you the free slots for ex- 0.6.4) as a workaround. ternal access. When a client logs on to

WWW.LINUX - MAGAZINE.COM ISSUE 80 JULY 2007 61 KNOW-HOW Partimage

Figure 3: Choose your compression level: if you see this dialog box Figure 4: Changing the compression level. You can even change the during a network backup, you know that remote login is working. compression level through the Partimage user interface.

To select an action, use the radio but- Options lets you specify whether Parti- launch the server by entering ./partim- ton. To back up a partition, select Save mage should check the partitions before aged start. The partimage file stays on partition into a new image file. The next saving; you can enter a description or the client. step is to specify where the server is lo- disable the prompt, which warns you To launch the client software, type cated and whether you will be using a when you are about to overwrite an ex- ./partimage, again working as root, then secure SSL-encrypted connection. Enter isting version. enter the IP address of the remote ma- the IP address for the machine with the This just leaves one more thing: the chine; there is no need to log on or gen- listening daemon. Clients will use port Image split mode. Partimage will either erate certificates. 4025 to log on to the server by default. If automatically split the image file if it you have a firewall running on the client runs out of space or it will create files Coming Home or server, make sure you modify the of a definable size. Saving a partition on a remote server rules to accommodate this. If you check Wait after each has a number of benefits. If the server is To protect the data stream against change, Partimage will take a break hosted by a commercial web hoster, you sniffing, check Use SSL to encrypt net- when the sub-image reaches a certain can rely on your data being backed up work data then press F5 to tell Partimage size, which is a useful feature if you are regularly, although a slow Internet con- to go to the next screen, where you need backing up to DVDs or CDs. nection would be a disadvantage be- to enter the user name and password. The If finished successfully option tells cause it would drastically slow down Make sure that: the client what to do after completing a the restore. • an account for this user exists on the backup. For the time being, this is all In our lab, the program took about 10 server, there is to it, so press F5 to start creating hours to restore the data on a 10GB par- • an entry for this user is in the /usr/etc/ the backup; this can take a while de- tition over the wire. Local backups on partimagedusers file, and pending on the volume of data and external disks take just a fraction of this • this is not the user that launched the available bandwidth. time. The partition on which you restore server. the backup must be the same size as or Now click OK to tell the client to knock Special Case bigger than the original partition with at the server’s door. This is the exciting Although I had no problem installing the your data. If you restore a smaller parti- part of the process: if the login fails, you current version of Partimage on Open- tion to a larger target, the unused space might have a problem with the privi- SUSE 10.2, Ubuntu was unable to access is left empty. leges, paths, or the passwords. Recheck the server on OpenSUSE. Strangely, this To restore a partition, launch the client your entries. worked with the older version 0.6.4 of and the server, select Restore partition Once you have everything set up cor- Partimage. from an image file in the dialog you used rectly, a new dialog box should appear, Another advantage is that the archive previously for the backup, enter the ad- and the program will ask you how to contains just two binaries – partimage dress of the remote server, then press F5 compress the data. If you take a look at and partimaged – removing the need to to change to the next screen. the server display in the meantime, you build the software. Optionally, you can tell the program to should see the client IP address and a Unfortunately, this version does not simulate the process or to overwrite free connected status message. support secure data transfer, although blocks with zeroes. The If finished suc- Returning to the client, you might re- there is nothing to prevent you from cessfully option tells the server what to call that it was asking which Compres- using it for backups on the local network do after executing the backup. Pressing sion level you would like to use. Gzip is or on local disks. F5 starts the write operation. the default; Bzip2 creates small footprint After you unpack the archive, copy the images but takes a while to do so (Figure partimaged file to the directory in which Local Backup 3). Uncompressed images are fast, but you will be storing your backups on the If you are short on time, you might pre- they take up more disk space. server. Then, you can become root and fer to back up your data to a local disk.

62 ISSUE 80 JULY 2007 WWW.LINUX - MAGAZINE.COM Partimage KNOW-HOW

Partimage win- 10 hours, backup and restore on the USB dow, create a di- drive took just 20 minutes. rectory below this path, then enter Conclusions the path plus a Partimage gives users a simple approach name for the to backing up a partition, and it is useful backup. for backing up a complete Linux installa- Just ignore any- tion. If you value security and intend to thing related to ac- use a remote server, you’ll need to go to cessing machines additional trouble to add SSL, which will over the network slow down the backup process. and press F5 to A local backup is faster, but it involves Figure 5: Partimage displays file information when a backup is in move to the next some residual risk, and it might not be progress. screen, where you what you are looking for. Whichever ap- can select the proach you choose, Partimage’s simple For this, you only need the client, and compression level, which you should be controls will take you quickly where you you can do without passwords, new user familiar with from the network backup. want to go. Partimage is perfect for pri- accounts, and privilege management. The next step is the backup itself; there vate use and small networks, but regular In our lab, I used an external USB disk is no need to log on. backups should be left to other tools. ■ as the backup device. The steps are basi- cally the same, but you do not need to Restoring a Partition INFO launch the server, just the client. In the The steps for restoring a partition follow [1] Partimage: http:// www. partimage. org Partition Image window, enter the path the same pattern: Launch Partimage, [2] SystemRescueCd: to the local directory in which you will specify the image you want to write to http:// www. sysresccd. org be creating the image file. the partition, and off you go. Ubuntu automatically mounts the Although restoring data across the net- [3] Download Partimage: http:// www. partimage. org/ Download external drive in /media/usbdisk. In the work with an encrypted connection took

Advertisement