Creating Images Of Your Linux System With SystemImager
Creating
Images Of Your Linux System With SystemImager
Version 1.0
Author: Falko Timme
Have you ever had the problem that you have set up the "perfect system", and now you want to back up this system before you make changes to it so that you can restore the original state if you changes are not satisfying? Or are you a system administrator in a large company where you have to maintain hundreds of Linux machines that run exactly the same software, but are sick of installing each machine manually? Or did you develop a Linux-based hardware appliance, and now you want to sell it in big numbers on different hardware platforms (i.e., different hard disks, etc., not different processor architectures!) without having to maintain an image for each platform? Or do you want to distribute this solution to your resellers overseas, so that you do not have to ship expensive hardware and your resellers can sell their own hardware*? This is where SystemImager comes into play!
From the SystemImager website:
"SystemImager is software that automates Linux installs, software distribution, and production deployment.
SystemImager makes it easy to do automated installs (clones), software distribution, content or data distribution, configuration changes, and operating system updates to your network of Linux machines. You can even update from one Linux release version to another!
It can also be used to ensure safe production deployments. By saving your current production image before updating to your new production image, you have a highly reliable contingency mechanism. If the new production enviroment is found to be flawed, simply roll-back to the last production image with a simple update command!
Some typical environments include: Internet server farms, database server farms, high performance clusters, computer labs, and corporate desktop environments."
SystemImager lets
you create images of your installations. To do so, you need an image
server (should have enough disk space to store your images) and a
so-called golden client
(i.e., your "perfect system" of which you want to make an image).
This means that you have to install some software on your image server and on
your golden client in order to run SystemImager. SystemImager provides Debian
packages as well as rpm packages for rpm-based distributions such as RedHat,
Fedora, SUSE or Mandrake. In this example both my image server and my golden
client are running under Debian.
This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.
This document comes without warranty of any kind!
*This is what we do in the company I am working for. We distribute images of our spamfilter appliance to our resellers over the internet, so that they can install and sell it on their own hardware platforms. If you are interested, write to [email protected].
1 Install SystemImager On The Image Server
Add
deb http://download.systemimager.org/debian stable main
to /etc/apt/sources.list and run
apt-get update
To install the SystemImager server simply run
apt-get install systemimager-server
2 Install SystemImager On The Golden Client
Add
deb http://download.systemimager.org/debian stable main
to /etc/apt/sources.list and run
apt-get update
To install the SystemImager client simply run
apt-get install systemimager-client
3 Create An Image Of your Golden Client On The Image Server
Now let's assume that my image server has the IP address 192.168.0.2, and my golden client has the IP address 192.168.0.100.
In order to pull an image from the golden client, you should shut down any firewall on the golden client, or at least allow connection to port 873 TCP (rsync). Now, on the golden client, run the following command:
prepareclient --server 192.168.0.2
On the image server, run
getimage -golden-client 192.168.0.100 -image my_golden_client -ip-assignment replicant
where my_golden_client is the name of the image you want to create. -ip-assignment can have one of the following 4 values (see man getimage):
· static_dhcp -- A DHCP server will assign the same static address each time to clients installed with this image. The DHCP server in this case also assigns the corresponding host name. It is possible therefore, when using static dhcp, to change a machine's hostname and IP address by simply changing one value in the dhcpd.conf file. Some may find this desirable. Also see the mkdhcpstatic command.
· dynamic_dhcp -- A DHCP server will assign IP addresses dynamically to clients installed with this image. In dynamic dhcp, the IP address of a machine may change, but you want it to retain the same host name. Therefore the hostname is set by the machine itself. They may be assigned a different address each time.
· static -- The IP address the client uses during autoinstall will be permanently assigned to that client.
· replicant -- Don't mess with the network settings in this image. I'm using it as a backup and quick restore mechanism for a single machine.
4 Create A Boot Diskette
SystemImager lets you install images on systems that have nothing installed on it. But we have to tell such a system where to get the image from. This can be done with a boot diskette (which means that your new system needs an IDE floppy drive, it will not work with a USB floppy drive). To create a boot diskette, insert an empty diskette in your image server and run
mkautoinstalldiskette
This will create a standard boot diskette. Now we have to create a configuration file called local.cfg:
HOSTNAME=www DOMAINNAME=example.com DEVICE=eth0 IPADDR=192.168.0.100 NETMASK=255.255.255.0 NETWORK=192.168.0.0 BROADCAST=192.168.0.255 GATEWAY=192.168.0.1 GATEWAYDEV=eth0 IMAGESERVER=192.168.0.2 IMAGENAME=my_golden_client |
It should contain the desired network settings of your new machine. DEVICE and GATEWAYDEV should be the Linux device name of your network card. IMAGESERVER should be the IP address of your image server, and IMAGENAME should be the name of the image to be retrieved.
Save this file to your boot diskette. You can even do this on your Windows workstation, but be sure to save the file with UNIX linebreaks!
Another way of creating your boot diskette is this:
Create a file /var/lib/systemimager/my_golden_client.local.cfg on your image server. /var/lib/systemimager/my_golden_client.local.cfg should be filled with the same contents as local.cfg above. Then run
mkautoinstalldiskette -config /var/lib/systemimager/my_golden_client.local.cfg
This will create your boot diskette with your local.cfg included!
A third way of creating a boot diskette is this: Download this boot diskette image and write it to a diskette. On a Linux system, you can do this with the following command:
dd if=systemimager-floppy-image.img of=/dev/fd0
On Windows, you can use a tool like RawWrite to achieve this. Afterwards, you still have to create a local.cfg on the diskette as described in the first method to make a boot diskette above.
5 Install Image On A New System
On your image server, execute the following command:
/etc/init.d/systemimager-server start
or
/etc/init.d/systemimager-server-rsyncd start (depends on your version of SystemImager)
Be sure that port 873 TCP can be accessed from the outside (firewall!).
Now insert your boot diskette into your new system and boot from the diskette. Your new system will install the image my_golden_client automagically, and you are done!
6 Update An Image
Let's say you have made some important changes to your golden client, and now you want to update your previously created image my_golden_client. The steps are the same as in paragraph 3:
On your golden client, run
prepareclient --server 192.168.0.2
(Be aware of your firewall!)
On the image server, run:
getimage -golden-client 192.168.0.100 -image my_golden_client -ip-assignment replicant
7 Delete An Image
If you want to delete an image on your image server, simply run
rmimage my_golden_client
(my_golden_client
should be replaced with the name of the image to be deleted.)
Links
SystemImager: http://www.systemimager.org/