Replacing ghost with tools for real men. Part2: Ghosting an full computer
Here we are, I've choosen NFS for my tests: mounted RW, I can read/write data in both directions without problem. It's time to save and restore a computer
Booting the Client
Yeah, it was at the end when I automated ghost. now, I'll go first with that to see what's available.
sysrescuecd: I've opted for this project: an live-CD with tools for reals men: zsh, netcat, man, mount.ntfs3g, nfs, ... Really the best rescue CD I've ever tested, and it's only the beginning!. First, it can be booted througt PXE (sic! for a live-CD). drop the initrd "initram.igz" and the kernel named "rescuecd" (available on the CD) onto the tftp directory from the pxe server and add a line in the "default" config file from pxelinux.cfg (I use isc-dhcpd (v3) and atftp).
label rescuecd kernel systemrescue/rescuecd append initrd=systemrescue/initram.igz scandelay=5 dodhcp setkmap=fr netboot=http://www.domain.tld/sysrcd.dat
The syscd.dat is the iso image, in a special format (available on sysrescuecd website). the location is on http, but can be set to an tftp server. unfortunaly the file is too big for my tftp server.
This makes the client computer boot an system. End of first try.
Backup the client
The client is supposed to be ready to be cloned: syspref runned on windows
I have made nothing new here, after booting the client through PXE on sysrescuecd:
- backuped the partition table: sfdisk /dev/sda -o /mnt/nfs/sda.sfdisk
- backuped the mbr dd if=/dev/sda of=/mnt/nfs/sda.mbr bs=512 count=1
- cloned the NTFS partition: ntfsclone -s -o - /dev/sda1 | gzip | split -b 2047m - /mnt/nfs/sda1.ntfs.img.gz_ (This will result in seraval files from 2Go compressed)
- tar-red the linux partition (I didn't take care of acl): mount /dev/sda6 /mnt/linux; cd /mnt/linux; tar cf - . | gzip | split -b 2047m - /mnt/nfs/sda6.linux.img.gz_
Easy. So eeeasy. Even Garfield could do that on Monday.
After making some tests it was too mont to always type same commands. sysrescuecd came to rescue: At boot, an script can be specified:
append initrd=systemrescue/initram.igz scandelay=5 dodhcp setkmap=fr netboot=http://www.domain.tld/sysrcd.dat ar_source=http://www.domain.tld/install/
The file named autorun will be downloaded in the directory ar_source, and run. What more wanted? Lasagnes?
Here a first version from my autorun script:
Some explanations on what's done:
- set the date/time otherwise, tar will make some problems
- mount the nfs server
- find out ip and hostname of the client
- restore the partition and the mbr
- restore the ntfs partition, and create the second ntfs partition if needed( I have computers with severa NTFS partition, but only an image for the first)
- make the linux swap
- untar the linux partition
- fix UUID numering: Mandriva uses now UUID with are created when making the filesystem. /etc/fstab, and bootloader should be modified. grub should rerun later.
- fix some udev specific stuff: the MAC was stored in the 621-net_persistent.rules
The Great Part is the change in SYSPREP: I was unable to find a solution for asking the computer to use its SHORTNAME as NETBIOSNAME to join the domain. Now, thanks to sysrescuecd with profile ntfs.3g, I can mount the partition to change some parameters in sysprep.inf
I've tested this setup in a classroom. With a single gigabit connection, a PC can be restored in 7mn. but takes up to 15mn in 100M, and for a full classroom of 16 computer, it takes several hours. Too long, compared to the old Ghost, which was ghosting a single computer or a full classroot in multicast in 25mn