As the age of the netbook arises; the ability to provision Operating Systems over the network becomes highly useful. More and more these days, it’s less common to see CD/DVD ROM drives in laptops. In my particular situation my laptop DVD-ROM drive failed. This prompted me to embark on journey of sleepless nights, sifting through bad information and countless hours of ‘trial & error’ troubleshooting to make Windows 7 install from PXE boot server.
When I first started this project I had no idea what I was getting into or how difficult and poorly documented the PXE remote installation process is. I imagined that I would use some kind RAM disk to load an ISO image of a Windows CD. However, the process to boot an ISO image varies greatly between Operating Systems and Windows versions. So if you plan to install Windows XP or Linux using this tutorial… you will fail. This Tutorial is step by step for installing Windows 7(only) from a Fedora 10 provisioning server. This tutorial assumes you have basic Linux, Windows, and Networking knowledge.
Goals of this post:
– Configure Linux Provisioning Server
– Prepare installation media and installation files
– Boot from PXE to Windows PE 2.0
– Install Windows 7 over Network
Configure Linux Provisioning Server: DNSMasq
In a nutshell PXE is a standard for giving special instructions to computers booting from a network. PXE requires special DHCP options to accomplish this. Typical home(low end) routers do not include this capability in their products. So we will need our own DHCP server with our custom options set for PXE.
Use YUM(or the package manger of your distro) to install the popular DNSMasq/SAMBA software packages. While there are many different open source platfroms for this I chose DNSMasq because it’s easy to configure and provides us with single source for DNS, DHCP and TFTP services. All of which are nessasary to complete our PXE Windows 7 install.
After installation, edit the options in the /etc/dnsmasq.conf file. I removed the original file and created one with just the options we need. Below, we are defining a DHCP range and instructing PXE devices to boot the ‘pxelinux.0’ kernel. Which in turn is used to load the memdisk kernel. Memdisk mounts a remote ISO image located on the TFTP. In this case we are mounting an image of Windows PE 2.0(Pre-Installation Environment). I created a directory called tftpboot in the ‘/var/ftp’ directory. We’ll use this directory for the PXE files and the Windows PE ISO.
Prepare PXE Installation files
Next we need to download and install ‘SYSLINUX’ package and extract the key files. Here is a description of the SYSLINUX project from Syslinux – http://syslinux.zytor.com/wiki/index.php
As of Syslinux 3.84 the memdisk supports mounting ISO images. We’ll use pxelinux.0 and memdisk from the Syslinux package of software to mount an ISO image of Windows PE.
Unzip the files and copy the ‘pxelinux.0’ file from the ‘core’ folder to /var/ftp/tftpboot’. Copy memdisk from the ‘memdisk’ folder to ‘/var/ftp/tftpboot/’.
Create a Windows PE 2.0 ISO image
Now we need a Windows PE ISO image. Download and install the, ‘The Windows Advanced Installation Kit’ to Windows Vista or Windows 7 PC. It includes the necessary tools to partition disks and mount the Samba share with the Windows 7 installation folder. Install the package and follow these instructions to create your Windows PE ISO image at, http://technet.microsoft.com/.
Why does one have to download a special software package to make a boot disk? I don’t know. Windows PE 2.0 usually operates as a bootable CD. We’re booting . It’s absurd that you have to install a separate program to generate a boot CD. To make it worse, Windows PE 2.0 boots to a command prompt without the option of booting to a desktop.
No one that paid for Windows should have to partition a disk from a command prompt in a terminal sitting on a inaccessible windows desktop. That’s Silly. Even Redhat and Knoppix boots to a desktop.
Why doesn’t Microsoft have an easy to download boot CD with a semi-functional desktop? No Idea. That’s why it’s so common to see DOS, Ultimate Boot CD and KNOPPIX disks used by Windows system administrators. It’s like Microsoft wants you use Linux – for at least something…
If wading through Microsoft’s horrid technet site doesn’t work for you. I copied an excerpt from the help file of the Windows PE 2.0 ISO image. I only included the two necessary steps. However, the Windows PE 2.0 image can be created with custom scripts and additional apps.
Set up a Windows PE build environmentIn this step you will create a required directory structure that supports building a Windows PE image.
On your technician computer, click Start, point to All Programs, point to Windows OPK or Windows AIK, and then click Windows PE Tools Command Prompt.
The menu shortcut opens a Command Prompt window and automatically sets environment variables to point to all the necessary tools. By default, all tools are installed at C:\Program Files\<version>\Tools, where <version> can be Windows OPK or Windows AIK.
At the command prompt, run the Copype.cmd script. The script requires two arguments: hardware architecture and destination location. For example,
copype.cmd <arch> <destination>
Where <arch> can be x86, amd64, or ia64 and <destination> is a path to local directory. For example,
copype.cmd x86 c:\winpe_x86
The script creates the following directory structure and copies all the necessary files for that architecture. For example,
Create a bootable CD-ROM
This step describes how to put Windows PE RAM disk onto a CD-ROM. This option requires that you create an .iso file by using the Oscdimg tool.
On your technician computer, create an .iso file with Oscdimg. At a command prompt, type:
oscdimg -n -bc:\winpe_x86\etfsboot.com c:\winpe_x86\ISO c:\winpe_x86\winpe_x86.iso
For ia64 architecture, replace Etfsboot.com with Efisys.bin.
Copy the Windows PE 2.0 ISO image to your, ‘/var/ftp/tftpboot/’ directory. Create a directory called, ‘pxelinux.cfg’. Now your TFTP boot directory should contain the following.
Configure PXE Linux
I took this excerpt from the SYSLinux WiKipage. It gives a brief run down of PXELinux and it’s main configuration file, ‘pxelinux.cfg’. Read the section below, afterward we can move on to some custom example files I created.
On the TFTP server, create the directory “/tftpboot”, and copy pxelinux.0 (from the SYSLINUX distribution) and any kernel or initrd images that you want to boot.
Finally, create the directory “/tftpboot/pxelinux.cfg”. The configuration file (equivalent of syslinux.cfg — see the SYSLINUX FAQ for the options here) will live in this directory. Because more than one system may be booted from the same server, the configuration file name depends on the IP address of the booting machine. PXELINUX will search for its config file on the boot server in the following way:
1) First, it will search for the config file using the hardware type (using its ARP type code) and address, all in lower case hexadecimal with dash separators; for example, for an Ethernet (ARP type 1) with address 88:99:AA:BB:CC:DD it would search for the filename 01-88-99-aa-bb-cc-dd.
2) Next, it will search for the config file using its own IP address in upper case hexadecimal, e.g. 192.0.2.91 -> C000025B (you can use the included progam gethostip to compute the hexadecimal IP address for any host). If that file is not found, it will remove one hex digit and try again. Ultimately, it will try looking for a file named default (in lower case). As an example, if the boot file name is /mybootdir/pxelinux.0, the Ethernet MAC address is `88:99:AA:BB:CC:DD` and the IP address 192.0.2.91, it will try following files (in that order)
Inside the TFTP boot directory is a folder we named pxelinux.cfg. Change to this directory and create a file called, ‘default’. Below is an example of what ‘default’ should contain.
The default file tells pxelinux what boot files the PXE client should receive. In this case we are instructing any PXE client to load memdisk(turns the clients RAM into a virtual disk) and mount the Windows PE 2.0 image(winpe_x86.iso). Remember, you can only mount ISO images to newer versions of memdisk, so download a recent SysLinux package!
For my Samba setup I used the stock Fedora, ‘system-config-samba’. Create a Samba user located in the preferences menu. I created a folder on my Fedora desktop and copied my Windows 7 files directly from the DVD. Add the folder containing the Windows 7 installation files to Samba. Remember to restart Samba.
Boot to Windows PE 2.0 to prepare Windows 7 Installation
Now we are ready to boot our PXE device. I prepared a laptop and a virtual macine as examples. Notice on my laptop there is an option at boot. Your Ethernet controller should have some option in the BIOS to enable this feature. If you do not, your ethernet card may not be capable of a PXE boot.
Start PXE boot. You should see a screen that shows memdisk and PXELinux.0 loading.
and loading… It takes a while don’t despair.
Finally you will get a message to ‘press any key to boot…’. Now Windows PE 2.0 will boot up and provide the envriment to Partition the hard disk. Remember, this tutorial is to help you get your lab going. As mentioned earlier, you can create special Windows unattended installation files to stream line these deployments in a production enviroment.
Windows PE 2.0 – DiskPart tool
Use the diskpart command. Then type help from the ‘Diskpart’ console. Read through the options. See below. Also visit Microsoft technet for further reading. If you are only upgrading from Windows XP this step is not nessasary as your Disk are already partitioned and formatted.
Select the Disk, create a partition and format. There are plenty of online tutorials to help with this(as every person’s setup may very).
Remember to use the ASSIGN command at the end to make the new disk the ‘C:\’.
Mount Samba share and begin Windows 7 installation
Mount the Samba share containing the Windows 7 installation files. I specify to mount the Samba share as the ‘J:’ drive.
That’s it! Your Windows 7 installation will proceed as normal. With a little more work you can take elements of this tutorial and create a cheap linux box that upgrades all your Windows clients in a few hours over the weekend. No need to mess with your production Windows Server. The Linux TFTP provisioning server can simply be turned off when the job is complete and normal DHCP service restored to your router or Windows Domain. Good luck and please share your experiences!