UCDavis WinXP Setup and Using BITS to Transfer Ghost Images
We wanted to have a easy way to distribute Ghost images to our
PC clients on many different networks. In addition, we wanted to be able to easily install images
onto new PCs. Our solution was to partition all the PC hard drives into
two partitions. This enables us to store the Ghost image on the hard drive
and quickly image the WinXP partition.
First Partition
The first partition is 40GB. It has
FreeDos installed, some Ghost utilites (ghost, ghstwalk, and gdisk) and a copy of the Ghost
image for that PC. Basically the partition is set to automatically ghost
the PC and reboot. So it has Ghost, Gdisk, and Ghostwalker install.
So the autoexec.bat is set to gives your 5 seconds to
cancel out and then runs this script:
c:\ghost -clone,mode=pload,src=$file:1,dst=1:2 -sure -batch -fni -auto
c:\ghstwalk /cn=XXX /bv=1:2 /sid=XXXX /ignore_domain /sure /fni
c:\gdisk 1 /act /p:2 /i
c:\reboot
The restore.bat script it generated by a Perl script in the WinXP partition so it will
have the correct computer name and SID.
Second Partition
The second partition uses the rest of the hard drive and contains WinXP.
We added a few tools to maintain the PC.
-
ActiveSate
ActivePerl
- nnCron LITE (Set to run as a service and edit cron.ini with "AsLoggedUser OFF" so it will run in the background)
-
bitsadmin (Part of Windows XP Service Pack 2 Support Tools)
-
shutdown (I download this one, but you could also use the Microsoft shutdown.)
- robocopy (Part of Windows Server 2003 Resource Kit Tools)
The big question was how to get the mutli-gigabyte ghost image
file to all the PCs. We decided to use the
Background Intelligent Transfer Service (BITS). It allows you to
transfer big files using spare network bandwith in the background while the
PC is still in use. So we have a cron job
that runs bits.pl every half hour. Bits.pl compares the
locally stored ghost image file on the Freedos partition to an image file on a
web server. If they are different, it starts a BITS transaction to copy it
down in the background. When it see the new image file is copied down, it
then moves the image file to the Freedos partition and sends the output to flag
file.
We have a shutdown script for the PC which has the line:
if exist c:\ucd\restore c:\util\gdisk32 1 /act /p:1 /i
So if the new image files have been moved to the FreeDos
partition the PC will make that partition active. So the next reboot will
load the FreeDos partition and then reimage the PC. The shutdown script
runs restore.pl which creates the restore script
in the FreeDos partition with the proper info.
The shutdown script also does some other maintenance stuff: such
as running robocopy to make sure the files on the Freedos partition
are up to date. Since it's a FAT32 partition there are no file
permissions. So we want to make sure what we want there is really there.
So when the PC reboots it runs the restore script and gets
imaged with the new ghost image. Then it reboots into the WinXP partition.
I have a startup script called set_net.pl that gets the
computer name (set by ghostwalker) and then changes the IP address if needed.
It also set a few environment variables used by other scripts.
So in the end, here's the upgrade procedure:
-
I logon to the PC as the special restore users. The logon script has the following:
if %username% == restore goto restore
*** UCDavis specific mapping of network drives here ***
goto end
rem restore the PC
:restore
echo restore > c:\temp\restore
c:\util\sd 4
:end
It recognizes the restore logon, sets a flag file, sets the FreeDos partion active, and reboots (I renamed
the RJL shutdown to sd to avoid conflict with the MS shutdown).
-
The PC will reimage with the current image to get it to a know
clean state.
-
The I logon with an admin account, run Microsoft Updates, and update the virus defs.
The I install whatever application that needs to be installed.
-
The I run freedos.cmd. It sets
a flag file, sets the Freedos parition active, and reboots. As the PC
shuts down the shutdown scripts sees the clean flag and runs
clean.pl to clean up a lot of log files, etc and
runs:
netsh interface ip set address "Local Area Connection" dhcp
to set the IP address to DHCP. This is need so when
all the PCs in a lab reboot after imaging there is not a bunch of IP address
conflicts.
-
When it reboots into Freedos hit a key so it doesn't reimage.
Then run the image.bat script to make the new image.
-
Run windows.bat to switch back to the WinXP
partiton and reboot.
-
After WinXP boots up, copy the image files from the FreeDos
partition up to the web server wiht upload.cmd. (I have the web server share the images directory
using the Microsoft networking as well.) And that's it. Once the image
file is up on the server you just need to move it into place and the other PCs will "see" the new image.
Here's what happens then:
- Cron runs bits.pl on all the PCs in the lab. It sees
that the image file on the server is different and starts the BITS download.
-
Some time later the BITS download it done. bits.pl
copies the new image file to the FreeDos partition and sets the flag
file.
-
When the lab closes in the evening all the PCs are shutdown.
The shutdown script sees the flag file and sets the FreeDos partition as
active.
-
We have the CMOS auto-on setting set to 4am. So are
4am the next morning the PCs turn on, ghost the new image to the WinXP
partition, and reboot.
-
Cron is set to turn off the PCs at 5:30. (Usually
during the 4-5:30 windows the PCs run automatic updates and update their
virus defs. But since the image is brand new there aren't any updates
yet. Hopefully.)
- When the lab opens in the morning all the PCs have the new
image installed. I also get email as each PC gets restored. My
perl startup script includes:
if (-e "$config_dir\\email.pl")
{
do "$config_dir\\email.pl";
unlink("$config_dir\\email.pl");
}
Which runs email.pl the first boot and then deletes it.
Initial Install
For the initial install we use USB Hard Drive. It has FreeDOS installed. It uses ghost to install an image with the FreeDOS partition
and empty 2nd partition to the harddrive. It also created restore.bat and copies image files to FreeDOS partition. Then it reboots to FreeDOS partition and ghosts itself.
We have used two other possiblites for the initial install:
- We used to use a FreeDos boot floppy. But since it's dependent on DOS network drivers we wanted to move
to a more long-term solution. The boot floppy has a perl
script where you enter the lab name and PC number and it modifies the networking
ini files. So the PC connects to the network and uses Ghost to install a
basic disk setup with the FreeDos partition (w/o the image file) and an empty
WinXP partition. Then it sets the FreeDos partition active and reboots.
The FreeDos partition has the same dos based networking stuff. Since it
doesn't have the image file it connects to the network and downloads the file.
The web server is also serving the files via Samba. Since the perl script
sets the IP address (we don't use DHCP) you can quickly go form PC to PC with
the same boot floppy and start the install on lots of PCs. Once the image
file is copied down the PC follows the normal imaging process to install the
image on the WinXP partition.
-
We are also working on bootable flash drive with Linux. It connects to network and downloads image files from web server.
However, Linux creates slighly different partition table than Ghost – so there are some difficulties. But in the long term
we will probably switch to this method.
And that's it. There are some details missing so feel free
to email if you have questions.
Comments: tcleamy@ucdavis.edu
URL: http://lm.ucdavis.edu/people/tim/lab/winxp/
Last reviewed: Tue, 16-Jun-2009
Last updated: Tue, 16-Jun-2009 |
 |