...making Linux just a little more fun!

Installing Windows Server 2003 with Linux + PXE + DHCP + TFTP

By Will Schneider

What and why?

This procedure is for installing Windows Server 2003 over the network. However, I believe I've invented a new way of doing a network installation and wanted to share it with anyone who might find it useful. My quest to install Windows with a PXE/TFTP/DHCP system started after I tinkered around with the Unattended package and I found it lacking. Specifically, it's a giant hacky mess of Perl scripts, and it only handles 32 bit Windows installs. It essentially boots a DOS environment, creates a FAT32 partition, copies the Windows setup files, and then reboots and converts the partition to NTFS before finishing the install. It's a neat way of bootstrapping Windows from a Linux environment, but when I found out that MEMDISK can boot an ISO, I had the crazy idea of mapping an ISO image of the Windows setup CD as a RAMdisk and running the installation from there.

Stuff You Will Need

Getting Dirty

To make the MEMDISK-booted ISO -> RAMdisk -> Windows Setup chain work, we'll need to integrate a driver into the Windows setup image that will enable Windows to use the RAMdisk as an installation source. It's called winvblock, and it enables Windows to use a RAMdisk as a virtual block device.

To insert it into the CD, we'll need to manually modify /i386/txtsetup.sif, the configuration file for the text mode installation portion of Windows setup. The file is divided into separate sections with lists of definitions in the following format:

[Header]
definition 1
definition 2

So, to integrate the driver add the following lines in the appropriate sections:

[SourceDisksFiles]
wvblk32.sys = 1,,,,,,4_,4,1,,,1,4

[SCSI.Load]
wvblk32 = wvblk32.sys,4

[SCSI]
wvblk32 = "WinVBlock RAMdisk driver"

Next, you need to compress the driver; unzip the driver pack and run the following command at a Windows command prompt:

makecab WVBlk32.sys WVBLK32.SY_

Take the compressed driver and place it into the /i386 directory on the setup disk. Note that these instructions are for a 32 bit install image, however the 64 bit process is exactly the same, except for replacing "32" with "64" and placing the driver/modifying txtsetup.sif in the /amd64 directory.

These modifications will allow Windows setup to install from the RAMdisk. Now, there is one more caveat to deal with; this is the reboot after the text mode setup when Windows boots off the local disk that has been pre-populated with some installation files and a bootloader. Rebooting the machine will drop the RAMdisk from memory, and we need it re-mapped to finish the process. Dealing with this quirk is done by manipulating a bootloader hack that resides on the Windows setup CD. The binary /i386/BOOTFIX.BIN is the guy responsible for that annoying message that says "press any key to boot from CD" with a time-out. If the file is present on the disk, the message will appear. If it is removed, there is no prompt and the CD boots immediately with no way to stop that.

There are 2 ways to handle this final quirk I've found. I'm lazy, and don't like waiting around to press a key when the machine has to boot from the CD in the first phase of setup. So I created an ISO without BOOTFIX.BIN and called it "Stage 1". I then created a second ISO with BOOTFIX.BIN and called it "Stage 2". On Stage 2 of the setup, you simply load the ISO from the PXE server and let the prompt time-out, so the machine defaults to booting from the local hard disk with the RAMdisk loaded into memory again.

Wrapping up

At this point, the optional unattended answer file will take over and you can grab a coffee or make fun of the guy with the giant CD book as your net install finishes.

Finally, here are some sample entries for your PXE server (usually set up under /tftpboot/pxelinux.cfg/default):

label Windows 2003 Std x86 Text (stage 1)
 menu label ^Windows 2003 Std x86 Text (stage 1)
 kernel memdisk
 append raw iso
 initrd images/w2k3std_stage1.iso

label Windows 2003 Std x86 Graphical (stage 2)
 menu label ^Windows 2003 Std x86 Graphical (stage 2)
 kernel memdisk
 append raw iso
 initrd images/w2k3std_stage2.iso

I hope that explains the process in enough detail to replicate the setup. I've successfully installed all the i386 and amd64 flavors of Windows 2003 with this setup and I think it's a neat hack. Especially so since it's done with all open-source tools from a Linux server. Take that, RIS/WDS!


Share

Talkback: Discuss this article with The Answer Gang


Bio picture

Will a system engineer working in the webhosting industry. He enjoys automating things in strange ways, or when that fails he installs Gentoo on it.


Copyright © 2010, Will Schneider. Released under the Open Publication License unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 177 of Linux Gazette, August 2010

Tux