PXE boot WinPE 2 (Vista) using Linux as the PXE Server

Spent a little while trying to get WinPE2 (Vista) to boot via PXE from a linux server and thought it could be useful to someone. We already had our Red Hat stuff booting from there and it seemed like a good idea to keep it in one place!

Some of the stuff could be useful for booting via PXE from a Windows box too

Windows XP was used for WAIK stuff
Fedora Core 6 was used for PXE Server
Both running on VMWare Server along with a blank VMWare machine as the PXE client
* Note - there’s a bug in RHEL5 that’s stop’s the tftpd.remap file working. Not sure how many versions this affects

Install a Linux Server
I’m using a NAT VM to keep the DHCP server off of the LAN
Do a minimum install - we will install the required packages later
I’m using DHCP to give the server an IP address for testing but will need a static IP address assigning

I’m not using a firewall or SELinux - you might need to alter your install to accommodate them

On your linux PXE server

Ensure that the DHCP server is installed

yum install dhcp

Edit /etc/dhcpd.conf for your environment. Here’s mine -

ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 172.16.54.128;
filename "Boot/pxelinux.0";
}
subnet 172.16.54.0 netmask 255.255.255.0 {
option routers 172.16.54.2;
range dynamic-bootp 172.16.54.10 172.16.54.15;
default-lease-time 600;
max-lease-time 7200;
}

Install tftp-server

yum install tftp-server

Install syslinux

yum install syslinux

Copy pxelinux.0 from the syslinux install to /tftpboot

cp /usr/lib/syslinux/pxelinux.0 /tftpboot

Create a folder to hold the PXE config file

mkdir pxelinux.cfg

Create a PXE config file - /tftpboot/pxelinux.cfg/default - Here’s mine -

default 1
timeout 100
prompt 1
label 1
kernel Boot/startrom.0
append -

Create a tftp remap file. This is used to translate back slashes to forward slashes. /tftpboot/tftpd.remap. This should just contain a single line

gr \\ /

Enable the tftp server by editing the following file - /etc/xinitd.d/tftp. Also make it use the remap file. The -vvv is optional but it could definitely help later on! Here’s mine -

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot -m /tftpboot/tftpd.remap -vvv
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

Start the DHCP server

service dhcpd restart

Start the TFTP server

service xinetd restart

Download the Windows Automated Installation Kit - http://www.microsoft.com/downloads/details.aspx?FamilyID=c7d4bc6d-15f3-4284-9123-679830d629f2&DisplayLang=en

The file is an ISO file so can be renamed to .iso and mounted using either vmware or one of the free tools (magiciso?) so that the install can be run

On to a Windows XP machine now …

From the install CD you just downloaded

Install the .NET Framework Setup

Install the MSXML 6.0 Setup

Install the Windows AIK Personally I did it to c:\waik to save typing too much!

Run the copype command to create your PE folder

cd \waik\tools\petools\
copype.cmd x86 c:\vistape

Mount the .wim image

cd \vistape
imagex /mountrw winpe.wim 1 mount

Create a folder to store the PXE stuff

mkdir c:\pxe

Copy the PXE stuff to the pxe folder

cd \vistape\mount\windows\boot\pxe
copy * \pxe
cd \vistape\mount\windows\boot\fonts
copy wgl4_boot.ttf \pxe
cd \waik\tools\petools\x86\boot
copy boot.sdi \pxe
cd \vistape
copy winpe.wim \pxe

OK - now the fun bit. Create the BCD file. This is a replacement for the boot.ini

cd vistape\mount\windows\system32
bcdedit /createstore \pxe\BCD
bcdedit /store \pxe\bcd /create {ramdiskoptions} /d "Ramdisk options"
bcdedit /store \pxe\bcd /set {ramdiskoptions} ramdisksdidevice boot
bcdedit /store \pxe\BCD /set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
bcdedit /store \pxe\BCD /create /d "MyWinPE Boot Image" /application osloader

You should get a GUID returned - not sure what you need to do if not I’m afraid! Replace the GUIDs below with the GUID you get back
The entry {ed26a7d4-0ed5-11dc-9d1a-000c29ea1605} was successfully created.

bcdedit /store \pxe\BCD /set {ed26a7d4-0ed5-11dc-9d1a-000c29ea1605} systemroot \Windows
bcdedit /store \pxe\BCD /set {ed26a7d4-0ed5-11dc-9d1a-000c29ea1605} detecthal Yes
bcdedit /store \pxe\BCD /set {ed26a7d4-0ed5-11dc-9d1a-000c29ea1605} winpe Yes
bcdedit /store \pxe\BCD /set {ed26a7d4-0ed5-11dc-9d1a-000c29ea1605} osdevice ramdisk=[boot]\Boot\WinPE.wim,{ramdiskoptions}
bcdedit /store \pxe\BCD /set {ed26a7d4-0ed5-11dc-9d1a-000c29ea1605} device ramdisk=[boot]\Boot\WinPE.wim,{ramdiskoptions}
bcdedit /store \pxe\BCD /create {bootmgr} /d "Windows VISTA BootManager"
bcdedit /store \pxe\BCD /set {bootmgr} timeout 30
bcdedit /store \pxe\BCD /displayorder {ed26a7d4-0ed5-11dc-9d1a-000c29ea1605}

ok - nearly all done now. You need to copy all the files from your \pxe folder to your linux PXE server. I use winscp. Copy the files to a folder call /tftpserver/Boot (case is important!) I had some fun trying to do this with Vmware but that could have been a problem unique to me!

Back on the linux server … Just got to rename a few files

cd /tftpboot/Boot
mv pxeboot.n12 startrom.0
mv bootmgr.exe ..
mv winpe.wim WinPE.wim

Now PXE boot a machine and press 1 (obviously you can make syslinux look much nicer with some menus and things!). Fingers crossed you should get a Windows PE 2 console.

A few extra bits …

If you want to boot a Vmware machine via PXE and connect to the network you’ll need the Vmware network drivers in your .wim file. This is surprisingly easy to do thanks to being able to edit the .wim file easily.

From your Windows XP Vmware client (or you’ll need to find the vm network drivers from somewhere)

cd \vistape
imagex /mountrw winpe.wim 1 mount (you may have this done from above already)
peimg /inf="C:\Program Files\VMware\VMware Tools\Drivers\vmxnet\vmware-nic.inf" \vistape\mount
peimg /inf="C:\Program Files\VMware\VMware Tools\Drivers\vmxnet\vmxnet.inf" \vistape\mount
imagex /unmount /commit \vistape\mount

Now you can copy your winpe.wim file to your PXE server and overwrite the old one. Make sure you change the case of the file again to WinPE.wim

Hopefully this is going to work for all sorts of drivers - raid, network, etc Also, you can obviously put anything else that you need in the .wim file.




Related posts:

  1. 10 steps to a Xen domU
  2. Where’s all my disk space gone! - linux
  3. What is a Virtual Private Server (VPS)?


11 Comments

  1. Hemlock:

    Thanks for your article. Great Job.
    One thing to mention:
    The filename line in dhcpd.conf should read:

    filename “pxelinux.0″;

    and not

    filename “Boot/pxelinux.0″

    This is what I needed for Debian and dhcp3-server.
    All worked great after that.

    Cheers!

  2. Nick:

    Hi,

    Thanks for such a nice article. I am getting 1 error .. can you help.
    while doing pxe boot it says

    WINDOWS FAILED to start .. this might be due to recent change in hardware or software.
    1. insert disk and try.
    2. select languare and ..
    3. …

    File BCD

    unable to read Boot configuration file data.

  3. matt:

    Hi Nick,

    Did you make sure that you kept the filename BCD in upper case?

    The only other thing I can think is to turn on logging on the TFTP server (I did this when I was testing - it made tracking down problems a lot easier) At least then you’ll be able to see what file the client is asking for and what the error is.

    Matt

  4. Bob:

    This left me with a “BlInitializeLibrary failed 0xc0000001″ error after downloading bootmgr.exe. Ever see that?

  5. matt:

    Hi Bob,

    I’ve not seen that before I’m afraid. Is this on hardware that Vista will normally install on?

    Matt

  6. Pascal Vandeputte:

    I got exactly the same error messages as Nick, my mistake was that I was deploying WinPE on a tftp/netboot server I’ve been maintaining for a couple of years now and I hadn’t noticed that I had to add the “-m /var/lib/tftpboot/tftpd.remap” part to my inetd.conf file.

    For that reason the BCD file was never found because the remapping didn’t work.

    Another note: my setup seems to be looking for wgl4_boot.ttf in \Boot\Fonts , not in \Boot (which is where it ends up if you follow your instructions exactly).

    Anyway, thanks a LOT for your clear instructions, they were a huge help in getting this right!

  7. matt:

    Hi Pascal,

    Many thanks for the comments - they are very useful. There’s certainly a lot of different bits to get it all working together and any tips are definitely welcomed :-)

    I’m glad the post helped some. Matt

  8. luk:

    very clear instructions

    great help

    Thanks!

  9. Kashif:

    your screen shots are missing for some reason, did you move them?

  10. matt:

    Thanks Kashif. A wordpress plugin update had messed something up. Hopefully you can see them now. Matt.

  11. harm:

    nice howto, but after a quick-run im a bit confused on where to actually put the vista-dvd files and the unattended.xml file? Also, the pxe boot seems to hang and eventually reboot when running with 512mb ram. Im testing in ESXi and upgrading the Vista VM to 1GB ram gave a nice vista background with a dosbox stating ‘wpeinit’.

Leave a comment