Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Server
Table of Contents
Prologue...........................................................................................................................................3
Apologies.........................................................................................................................................3
DRBL y Clonezilla Server...............................................................................................................4
Operation.........................................................................................................................................5
Performed Tasks..............................................................................................................................5
Form work........................................................................................................................................6
ANNEX I ........................................................................................................................................8
INSTALLATION OF DRBL-Clonezilla SE .............................................................................8
INSTALLATION WITHOUT DHCP........................................................................................9
ANNEX II .....................................................................................................................................10
Imaging and Cloning W7 and Linux.........................................................................................10
ANNEX III ...................................................................................................................................12
Build Rules Script.....................................................................................................................12
ANNEX IV....................................................................................................................................17
Running Scripts after Clone......................................................................................................17
Parsing scripts for Sysprep .......................................................................................................18
ANNEX V......................................................................................................................................20
Tasks Scripts.............................................................................................................................20
This document tries to explain how to use DRBL/Clonezilla as a maintenance and deployment tool
for computer labs.
The idea is to use DHCP server's configuration file, which contains data of our already running
network, so that the DRBL/Clonezilla server works with it.
Clonezilla allows working with IP lists. Perl scripts are been created to work with names of labs
directly, without typing all IP's.
You can see the details of how the cloning is made in the scripts attached at the end of this
document.
I hope that this work helps to setup DRBL/Clonezilla SE according to your our needs.
At last, this document (and the perl scripts attached) surely could be improved. Please be free to do
it.
Apologies
This text is originally written in Spanish (I'm and Spanish). I try to do the translation the better
possible. Sorry for my terrible English. I promise to improve it soon.
We opted for the use of DRBL-Clonezilla Server because it is free and GPL. Implements
multicasting and allows you to clone partitions separately. Which tools do not allow, as FOG.
The minimum requirements on the client, according to tests carried out, is 512MB of RAM.
Project developed by NCHC Free Software Lab's (National Center for High-Performance
Computing located in Hsinchu, Taiwan).
DRBL is an open source solution for deployment and management of operating systems GNU /
Linux on multiple computers.
DRBL will provide the necessary services, to clients computers, for network boot using the PXE
protocol. With this protocol a bootloader is passed to the client from the server DRBL.
This bootloader is created by automated DRBL depending on the tasks that get executed on clients.
Basically, the bootloader will release a minimal Linux system that mount NFS file systems:
/tftpboot/node_root, /usr, /opt, /home and /var/spool/mail from DRBL server (see Annex III).
You need to clone up to 27 equal computers per labs. Each computer will have installed Windows7
and Linux.
To date, the tool used is rembo toolkit, but to become deprecated and does not support Windows7
and the ext3 file system (yes the ext2 with journaling enabled).
It intends to use the DHCP server already running (with the IP-MAC mapping).
Operation
It will have a DRBL server that will allow clients, using PXE boot, launch a minimal Linux system
that will use Clonezilla to clone partitions.
The client will mount a part of their filesystem via NFS from the DRBL server. Thus, the client will
have access to the images and the scripts we want to run the client (see Annex IV).
Performed Tasks
In order to use DRBL for our purposes, we have performed the following tasks:
DRBL server: Debian lenny with DRBL/Clonezilla installed (see Annex I).
DHCP server: Debian lenny with dhcp3.
Clients: PC's with network boot and PXE protocol enabled.
The usual way of working is to introduce the tasks on the server and start the client DRBL.
The server tasks are introduced through a perl script created (see Annex V) for working with labs
(by groups of IP's) and individual computer (by matching IP).
INSTALLATION OF DRBL-Clonezilla SE
Steps 6, 7 and 8 can be performed by parsing dhcpd.conf with the script we have called
/BuildRules.pl (see Annex III).
We will have to create an image of the entire disk (selecting all partitions) on the server.
Windows7:
W7 creates a partition of 100 MB approx. hidden and the system partition, then in our case
W7 will be in the /dev/sda1 (hidden) and /dev/sda2 ( c: \ ).
Once installed the system or the desired apps run the sysprep to act on the response file
sysprep.xml (which will be parsed with information from dhcp after cloning).
Then the generated image is ready to run sysprep on the first start, using the sysprep.xml
parsed, after cloning.
Note: Students user must delete before creating the image server. Since the first boot, up
a user (compulsory process) with that name.
Linux:
Desired distribution was installed on the source system. In our case we use the /dev/sda3
(for the root system) and /dev/sda4 (to swap).
Will need to modify /boot/grub/grub.cfg to boot by default W7 and remove rescue mode for
Linux.
The Linux system will be configure to get the network parameters IP and hostname from dhcp.
/etc/network/interfaces => for dhcp
/etc/hostname => emty
BuildRules.pl
#!/usr/bin/perl
###########################################################################
# Script to run after setting Clonezilla by drblpush -i, ###################
# to create rules NIS, NFS, for DHCP clients of laboratories. ###################
# Also creates IP_HOST_TABLE ###################
###########################################################################
$dhcpFile = "/etc/dhcp3/dhcpd.conf";
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
$IP_HOST_TABLE_CP = "/home/partimag/scripts/IP_HOST_TABLE";
$exports = "/etc/exports";
$ypservsecurenets = "/etc/ypserv\.securenets";
sub CreateExports
{
$ip = "@_[0]";
print exports"/tftpboot/node_root $ip(ro,async,no_root_squash,no_subtree_check)\n";
print exports"/usr $ip(ro,async,no_root_squash,no_subtree_check)\n";
print exports"/opt $ip(ro,async,no_root_squash,no_subtree_check)\n";
print exports"/home $ip(rw,sync,no_root_squash,no_subtree_check)\n";
print exports"/var/spool/mail $ip(rw,sync,root_squash,no_subtree_check)\n\n";
}
sub CreateYPSecurenets
{
$ip = "@_[0]";
print yp "255.255.255.255 $ip\n";
}
# In order to create rules for the first time we opened the files created by DRBL to overwrite.
@ifconfig= `ifconfig`;
$EvalNext="no";
foreach $line(@ifconfig)
{
@fields = split(/\s+/,$line);
if ( $EvalNext eq "si" )
{
@addr=split(/:/,@fields[2]);
# print "IP: @addr[1]\n";
$EvalNext="no";
print yp "255.255.255@addr[1]\n";
}
if ( @fields[0] =~ eth )
{
$EvalNext="si";
# print "Dev: @fields[0]\n";
}
$next="no";
while (<dhcp>)
{
if ($next eq "si" && !/^#/ && /(\d+\.\d+\.\d+\.\d+)/ )
{
$next="no";
$ip = $&;
&CreateIP_HOST_TABLE("$ip","$host");
&CreateExports("$ip");
&CreateYPSecurenets("$ip");
}
if (/.*host\s.*/) {
$next="si";
@line = split(/ /,$&);
$host = @line[1];
}
}
close(yp);
close(exports);
close(IP_HOST);
close(dhcp);
system("/etc/init.d/nfs-kernel-server restart");
system("/etc/init.d/nfs-common restart");
system("/etc/init.d/nis restart");
You may tell the Clonezilla server that runs a script when you have finished clone (parameter-o1 in
command line).
The run scripts are in the directory /opt/drbl/share/ocs/postrun/ .
The server will run all executable scripts that are in that directory, using the command run-parts of
Linux.
Note: run-parts only run scripts whose names contain uppercase and lowercase letters,
digits, underscores and dashes.
In our case, we have created an executable script called scripts_sh to call another script found in
/home/partimag/scripts / , called scripts.sh.
scripts_sh
____________________________________
#!/bin/bash
/home/partimag/scripts/scripts.sh
____________________________________
scripts.sh
____________________________________
#/bin/bash
The idea is to modify the tasks to be performed after cloning without having to reconfigure the
Clonezilla server. With this system enough to modify the contents of the script scripts.sh.
With those scripts, the template of sysprep.xml (in /home/partimag/sysprep/) file is copied from the
server to the Windows7 partition of client and parsed with the information for the client who is
being cloned.
ParseSysprep.sh
____________________________________
#!/bin/sh
ntfs-3g /dev/sda2 /mnt/ &&
perl /home/partimag/scripts/ParseSysprep.pl &&
umount /mnt
____________________________________
ParseSysprep.pl
____________________________________
#!/usr/bin/perl
$IP_HOST_TABLE = "/home/partimag/scripts/IP_HOST_TABLE";
$SYSPREP = "/home/partimag/sysprep/sysprep.xml";
$SYSPREP_PARCH = "/mnt/Windows/System32/sysprep/sysprep.xml";
$HOST_IP = `hostname`;
$HOST_IP =~ s/-/./g;
$HOST_IP =~ s/\n//g;
open(table_ip, "<$IP_HOST_TABLE");
while (<table_ip>) {
if (/$HOST_IP/) {
$line=$_;
$line =~ s/\s+/ /g;
open(source,"<$SYSPREP");
open(destiny,">$SYSPREP_PARCH");
while(<source>)
{
s/labX-XX/$hostname/g;
print destiny $_;
close(source);
close(destiny);
Tasks Scripts
NewDiskImage.pl
_____________________________________________________________________
#!/usr/bin/perl
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
$exist="no";
while (<IP_HOST>)
{
if (/$host\s/) {
$exist="si";
}
if ( $exist eq "no" ) {
print "The specified computer is not a client of DRBL\n";
exit;
} else {
system("/opt/drbl/sbin/drbl-ocs -b -q2 -j2 -nogui -p poweroff -z1 -i 1000000 -h \"$host\" -l
es_ES.UTF-8 startparts save $lab-img sda1 sda2 sda3");
}
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
$Dir_Img="/home/partimag/";
$host=$ARGV[0];
$lab=$ARGV[1];
$exist="no";
while (<IP_HOST>)
{
if (/$host\s/) {
$exist="si";
}
#!/usr/bin/perl
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
while (<IP_HOST>)
{
if (/\s$lab/) {
@line = split(/\t/,$_);
$IP = @line[0];
# print "$IP\n";
push(@ListIPs,$IP);
}
}
close(IP_HOST);
#!/usr/bin/perl
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
$Dir_Img="/home/partimag/";
$host=$ARGV[0];
$lab=$ARGV[1];
$exist="no";
while (<IP_HOST>)
{
if (/$host\s/) {
$exist="si";
}
}
close(IP_HOST);
#!/usr/bin/perl
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
while (<IP_HOST>)
{
if (/\s$lab/) {
@line = split(/\t/,$_);
$IP = @line[0];
# print "$IP\n";
push(@ListIPs,$IP);
}
}
close(IP_HOST);
#!/usr/bin/perl
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
$Dir_Img="/home/partimag/";
$host=$ARGV[0];
$lab=$ARGV[1];
$exist="no";
while (<IP_HOST>)
{
if (/$host\s/) {
$exist="si";
}
close(IP_HOST);
if ( $exist eq "no" ) {
print "The specified computer $host is not a client of DRBL\n";
exit;
} else {
if (-d "$Dir_Img$aula-img" ) {
system("/opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -x -nogui -r -j2 -o1 -k -p
reboot --clients-to-wait 1 --max-time-to-wait 300 -h \"$host\" -l es_ES.UTF-8 startparts
multicast_restore $lab-img sda1 sda2");
} else {
print "No exist image $Dir_Img$lab-img\n";
exit;
}
}
#!/usr/bin/perl
$IP_HOST_TABLE = "/etc/drbl/IP_HOST_TABLE";
while (<IP_HOST>)
{
if (/\s$lab/) {
@line = split(/\t/,$_);
$IP = @line[0];
# print "$IP\n";
push(@ListIPs,$IP);
}
}
close(IP_HOST);