An open source enterprise imaging solution
As a last line in troubleshooting, Clonezilla can be very useful with system images. Having a complete system image allows you to restore a complete computer from that image and thus prevent lengthy troubleshooting procedures. Clonezilla allows you to set up such an environment. In this article you'll learn how to set it up on Ubuntu Server 8.04.
There are two versions of Clonezilla, a stand-alone version and a server version. Whereas the stand-alone version does well making and restoring images of single machines, you'll need the server version if you need to take images of multiple systems. In its current version, up to 40 workstations can be images simultaneously in a method where broadcast or multicast are used to ensure optimal use of network bandwidth.
Before installing the required software enthusiastically, make sure that your environment is set up for imaging. Basically, it comes down to two elements: a fast dedicated network for imaging (you do want Gigabit here) and workstations that can boot from the network card (PXE boot). In this article I'll assume that you have both. If not, save yourself a great deal of hassle and make sure that these are in place before you start.
Setting up Diskless Remote Boot in Linux (DRBL)
To use Clonezilla in a server environment, you need to first set up diskless remote boot. The solution for that is DRBL; download it from http://drbl.sourceforge.net/one4all. Before setting up DRBL, you must set up the network interface card. Assuming that on your Ubuntu 8.04 server you've just installed a second network board for use with DRBL which hasn't been set up yet, follow the following procedure to set it up.
1. Using root permissions, open the file /etc/network/interfaces
2. To add a second network board, which is meant to be used for Clonezilla only, add the following information to the file.
iface eth1 inet static address 10.0.0.10 netmask 255.255.255.0 network 10.0.0.0 broadcast 10.0.0.255
3. Restart the network to activate the new configuration. Don't forget to make sure that your new network board (you should see it as eth1) really is available.
Installing the DRBL software
Now that the network is prepared, you can install the DRBL software. It is a good idea to use Ubuntu's secure apt to do this, so you first need to download the 'DRBL GPG' key and next to install it. Use the following two commands to do that:
wget http://drbl.nchc.org.tw/GPG-KEY-DRBL apt-key add GPG-KEY-DRBL
Next, you need to change the /etc/apt/sources.list file to add the new installation sources which allow you to add the drbl software and keep it up to date. Make sure to add the following two lines to the sources.list file:
deb http://free.nchc.org.tw/ubuntu hardy main restricted universe multiverse deb http://free.nchc.org.tw/drbl-core drbl stable
Next, execute the following commands to install the software:
apt-get update apt-get install drbl
Depending on the speed of your Internet connection, this may take a while. When this command has finished execution, all required software is downloaded but nothing is installed yet.
When running the apt-get install drbl command, a series of steps is launched:
1. First, the installation program asks if you want to install some network boot images for different Linux distributions. This would download more than 100 MB from the Internet to allow you to perform an easy installation of workstations. Normally, you don't need to do this, so press 'Enter' to accept the default value "no," and proceed.
2. In the next step the installation program asks if you want serial console output for typical clients. Unless you know you do need it, choose the default option 'No' here.
3 Now the installer asks what kind of kernel you want to use on the clients to do imaging. Typically, you would choose option 1, which offers i586 and better. Option 0 is for old pre-pentium clients only, and option 2 is only if your CPU is the same on the DRBL server and clients. This would not typically be the case, so choose 1 here and proceed.
4. Now the installer asks if you want to upgrade your operating system. Typically it's not the best idea to do that, so press Enter to accept the default value of No here. Go have a cup of coffee now; several megabytes of files need to be downloaded and that will take a couple of minutes.
At this time everything is set up properly to start doing the configuration. In this article, I'll assume that your DRBL server has two network interfaces: the eth0, which is used for normal Internet and user traffic, and the eth1, which is used for DRBL. This eth1 is configured with the IP address 10.0.0.10 in this example. Of course, you are free to use any other address range you like. Do make sure however that you are using a 24 bits subnet mask. Otherwise the broadcast / multicast performance will be very bad.
Now, to configure DRBL, use the /opt/drbl/sbin/drblpush -i command. This will set up your server. It's not difficult to set up your server this way, because the program will detect almost all settings automatically. The first couple of questions ask you about the DNS configuration you want to use. Pay attention when you're asked what network board is used for your internet connection. You should specify the correct card here, since you'll have DRBL traffic on that card otherwise.
After selecting the Internet interface, the DRBL interface is selected automatically.
In the next step, you can populate the database of your DRBL server with the MAC-addresses of the clients. How it works? Enter "y" to make the service clear that it should start collecting MAC addresses now. Next, start up all the client computers one by one and make sure they boot from their network card. You can use the '1' on your keyboard to find out if all the clients have been found. Once you are happy with detection of the clients, press 2 to finish collecting and quit. The advantage of doing this is that you can bind particular configurations to particular workstations. You are not required to do this. Without the fixed MAC - IP connection, DRBL can also work very well.
In the next step, the DRBL program asks you if you want the DHCP server which is configured automatically to hand out the same IP address to clients at all times. This is useful if you want the same client to work with the same configuration at all times. If this is the case, press 'y.' Otherwise, press Enter to continue. In case you do want the clients to work with the same IP addresses at all times, their MAC addresses must be stored in a configuration file. The DRBL setup program creates this file automatically for you. Just press Enter to accept the default name for this file.
Next, you must specify the IP address that the DHCP server will hand out for the first client. You do this by specifying the last byte only. So if, for example, you are on the network 10.0.0.0/24, and you want the first client to have the IP address 10.0.0.101, just enter 101 here. Based on the MAC addresses that were detected a range will now be configured automatically. Press Y to accept this range. You will now see an overview of the network configuration of your DRBL server. Happy with it? Press Enter to continue.
Next, you need to specify what DRBL mode you want to use. There are two different scenarios here. First, you can use DRBL to provide each client with a boot image that you'll use to give them a useable operating system. Do this at all times, because it gives you a complete working environment available on the client and that may be useful if you need to set additional parameters from the clients PXE-delivered operating system. In the next step, specify that you want to use full Clonezilla mode. This provides everything a client needs to boot and do its work in the Clonezilla environment.
Now you are getting to the next step of the configuration. You need to assign a directory that can be used by Clonezilla. I suggest using a rather large storage device, format that with XFS and mount it on a directory; /clonezilla, for example, might be a good choice. Better not use reiserfs for this file system as it isn't very stable. Also make sure that your /etc/fstab is modified to activate this directory the next time your server boots.
After specifying what file system to use, the configuration program asks you if you want to set a password as well. When using a password, only authenticated clients can use Clonezilla services. Do what fits your situation best here.
Now the installer asks if you want to set a boot prompt for clients. It may be a good idea to do so, in order that your clients have the option to specify what they want to do when booting it. A default timeout of 7 seconds is generated for this boot prompt. If this is not enough, change it in the next step. Following that, just press Enter to specify that you don't want to see a graphical boot menu on the client computers.
Next the configuration program asks if you want to use the DRBL server as a NAT server. If you just want to use Clonezilla for cloning, select "No" here. On the next three questions, press 'Enter' to select the default options. This will start the Clonezilla DHCP server and all related services. At this stage, you can use PXE-boot on the clients to boot them into the Clonezilla server.
Configuring the clients for cloning
You've set up a basic Clonezilla environment nowand that is good. It can be better though, and you are going to make it so now by using the drbl-client-switch command. Using this command, you'll add the appropriate Clonezilla options to the boot menu, thus enabling an end user to specify what he wants to do on his client workstation. You can configure the environment in different ways -- for full-automatic setup, but also in a way that the administrator starts the cloning process automatically after using PXE boot on the client. In the next procedure you'll learn how to use the drbl-client-switch command to set up the server. After that, you'll read how to start cloning on the clients.
Setting up the server for cloning
The procedure about which you'll read now is typically a one time only procedure, and allows you to set up the Clonezilla server for cloning.
1. On the server (either by SSH, or directly), start the /opt/drbl/sbin/drbl-client-switch command.
2. Now you need to specify in what mode your client will be starting automatically. Since I assume that you'll be using PXE-boot only when you want to clone the client, there's no danger in selecting the option 'clonezilla-start' here. This will automatically start the cloning engine.
3. You can now select an automated option, which will start a clone or restore process automatically. Using these automatic options, Clonezilla will use multicast mode, thus allowing you to clone at the highest possible speed. The disadvantage of using this option, is that you'll always need to run the drbl-client-switch command before every major job. The alternative is to use the option 'select-in-client.' This option will use unicast, but gives more flexibility from within the client. In the rest of this article I'll use this option.
4. Now you can specify what to offer as the default client boot option. Make sure to select the option -y1. In the next and last screen, select -p reboot, which will reboot the client machine automatically after it has been cloned.
Cloning the client
Now that everything is set up, you are ready to start cloning your client. The next procedure shows how that works.
1. Make sure the workstation that you want to boot does so from its network card. You'll see the DRBL boot menu, with the Clonezilla option selected by default. Make sure your workstation boots this option.
2. From the Clonezilla menu, you can choose from two different options. Use the option device-image to write an image file to the Clonezilla server. The device-device option is useful only if you want to clone the contents of a hard drive to an external storage device.
3. Now specify what you want to do. The most important options are savediks, which clones the entire disk to the image file, and restoredisk, which restores the client from an image file. Otherwise, there are two other options that allow you to save and restore individual partitions only.
4. Next specify what priority should be used. The default priority fits well. It will try ntfsclone which obviously is for NTFS filesystems only, if you're not using NTFS it tries partimage and if that also doesn't work, it will use the (very slow) dd command to clone the disk. Count on that to take a couple of hours though, because dd is rather inefficient.
5. Now make sure that the option is selected which will let the client wait before cloning. This option makes sure that nothing will happen by accident -- as you can imagine, that's rather important
6. In the following screen, you need to specify what command you want to use for compression of the cloned image. The default value which uses gzip will do rather well here. Following that, you need to give a name to save the image. This is very important, because when restoring the original state of your hard drive, this image name will be the only thing that you've got. So now make sure that all your machines have a unique name, and use that machine name (added by the date on which you've created the image if you'd like) to store the image.
7. Now select the hard disk(s) that you want to clone. Typically one disk only will be offered, but if the machine you're cloning has more than one hard drive, you can clone all of them with Clonezilla.
That's all. The cloning process will start now. Be patient, because it can take some time to complete!
ABOUT THE AUTHOR:
Sander van Vugt is an author and independent technical trainer, specializing in Linux since 1994. Vugt is also a technical consultant for high-availability (HA) clustering and performance optimization, as well as an expert on SUSE Linux Enterprise Desktop 10 (SLED 10) administration.