Adding Windows 7 to my PXE boot server…

I would have thought this would be difficult, but I found this Install Windows 7 over PXE from Linux without WAIK guide. I will document what I had to do differently (since that guide is designed for CentOS 5.3).

The first major change I needed to make was in the /etc/init.d/binl script; it called some things (e.g. /etc/sysconfig/network) which just doesn’t exist in Debian. I had to rip out all of the CentOS/Red Hat bits, and replace them with Debian ones. I also had to edit the binlsrv2.py file, since it had the tftp root path hardcoded in it.

Since tftpd-hpa was already set up (see my previous posts on the PXE boot subject), I just needed to add a remap file to /srv/tftp/windows/remap. This will cause tftpd-hpa to remap backslashes (‘\’) to slashes (‘/’). Setting up samba was pretty simple. I created the [REMINST] share as instructed, and mounted the Windows 7 x64 ISO to that share.

Importing the default boot files was straightforward, just used the wimextract tool found in the win7pxelinux.tgz distributed by the author of the ultimatedeployment.org site. I placed all of the executable files in /usr/local/bin, so I wouldn’t have to adjust my $PATH variable. I ran into an issue generating the winpe.wim Windows image (kept giving me an error that //windows/system32 couldn’t be found). To work around this problem, I added a “mkdir //windows/system32” command to the actionfile.txt, and it worked. Well, at least it didn’t give me an error.

The next step was to run a Perl script called bcdedit.pl. For this I had to install libhivex-bin, so I could run hivexsh (executed by bcdedit.pl). There was a problem, though. The hivexsh script generated a large number of errors. As far as I could figure out, hivexsh is slightly different between the Red Hat way and Debian way. In Debian, the -w option does not take an argument, whereas in Red Hat/CentOS the argument is the hive (Windows registry) file. Correcting this in bcdedit.pl was just a matter of moving the $bcd variable to the end of the command, rather than directly after the -w option.

Now was time to test it out. It looks like it launches, but it can’t seem to pull the files it needs from TFTP. It looks like it’s trying, just can’t find the files it wants:

…after some trial and error I notice that the WinPE client can’t find ‘hiberfil.sys’, a file created by Windows 7 when it hibernates. Thus the installation halts. Just touching the file isn’t enough. I can’t even make one in my Windows 7 virtual machine, since the guest firmware doesn’t support hibernation (not that it really needs to). So I’m stuck trying to figure out where I can grab that file from. I think it’s in the BCD I generated, but I don’t know where. Using the wimextract command from the toolset requires you to know where it is in the path. wimlib, which comes with an implementation of Windows’ imagex. I will have to start a new blog post for that, since I’ll have to start from scratch.

Adding Fedora 18 to my PXE boot server…

I covered setting up a Debian PXE boot server, and how to set up multiple OSes (well, multiple versions of Debian). This time I added Fedora 18 to the mix. Here’s my pxelinux.cfg/default menu file as it stands now:

default pxelinux.cfg/vesamenu.c32 menu background pxelinux.cfg/main.png prompt 0 timeout 0 ontimeout BootLocal noescape 1 label BootLocal localboot 0 text help Boot to local hard disk endtext menu begin Debian menu title Debian label Previous text help Return to previous menu endtext menu exit menu separator menu include debian/menu.cfg menu end menu begin Fedora menu title Fedora label Previous text help Return to previous menu endtext menu exit menu separator menu include fedora/menu.cfg menu end

All I did was copy the Debian section, and replace “Debian” with “Fedora.” I created the /srv/tftp/fedora/18 directory hierarchy, and pulled the vmlinuz and initrd.img from the linux/releases/18/Fedora/x86_64/iso/isolinux/ directory of the Fedora 18 netinst ISO. I created the /srv/tftp/fedora/menu.cfg file:

menu background fedora/splash.png label fedora18 menu label Fedora 18 - Install or Upgrade kernel fedora/18/vmlinuz append initrd=fedora/18/initrd.img repo=http://shevek.ceti/fedora/linux/releases/18/Fedora/x86_64/iso/ \ stage2=http://dl.fedoraproject.org/pub/fedora/linux/releases/18/Fedora/x86_64/os/ label fedora18vesa menu label Fedora 18 - Install or Upgrade (basic video driver) kernel fedora/18/vmlinuz append initrd=fedora/18/initrd.img xdriver=vesa nomodeset repo=http://shevek.ceti/fedora/linux/releases/18/Fedora/x86_64/iso/ \ stage2=http://dl.fedoraproject.org/pub/fedora/linux/releases/18/Fedora/x86_64/os/

(shevek.ceti is my workstation/PXE boot server). At first I just used the public mirror (repo only, not stage2), but since I was hosting the netinst image, I decided to use the stage2 install. My test VM is currently installing Fedora 18, I’d consider it a success!

Adding multiple Linux OSes to PXE boot…

In a followup to this post, I figured out how to add other versions of Debian to my PXE boot server. I followed two guides for doing so (PXE install on Debian Lenny, and Ubuntu Help’s Multi-Distro PXE Install Guide).

  1. After getting the single-distro (Debian Sid) working, I renamed the debian-installer directory (in /srv/tftp) to ‘sid’, created the ‘debian’ directory, and moved the ‘sid’ directory into ‘debian’:
    
    cd /srv/tftp
    mv debian-installer sid
    mkdir debian
    mv sid debian/
    
    
  2. Next, I needed to edit /srv/tftp/debian/sid/amd64/boot-screens/menu.cfg, and replace all instances of ‘debian-installer’ with ‘debian/sid’. I used vim to do it, but this simple sed command should also have done the trick:
    
    sed -i 's,debian-installer,debian/sid,g' /srv/tftp/debian/sid/amd64/boot-screens/menu.cfg
    
    

    Note that I will repeat this process for each Linux distro and arch added.

  3. I then added my next distro, Debian Wheezy amd64:
    
    cp -R /var/spool/mirror/dists/wheezy/main/installer-amd64/current/images/netboot/debian-installer/* /srv/tftp/debian/wheezy
    
    

    I made the same change as (2) above, changing ‘debian-installer’ in menu.cfg to ‘debian/wheezy’.

  4. Next I modified /srv/tftp/pxelinux.cfg/default:
    
    default pxelinux.cfg/vesamenu.c32
    prompt 0
    timeout 0
    ontimeout BootLocal
    noescape 1
    
    label BootLocal
            localboot 0
            text help
            Boot to local hard disk
            endtext
    
    menu begin Debian
    menu title Debian
            label Previous
            text help
            Return to previous menu
            endtext
            menu exit
            menu separator
            menu include debian/menu.cfg
    menu end
    
    
  5. I copied the syslinux file vesamenu.c32 to the pxelinux.cfg/ directory,

    cp /var/spool/mirror/dists/sid/main/installer-amd64/current/images/netboot/debian-installer/amd64/boot-screens/vesamenu.c32 /srv/tftp/pxelinux.cfg/

  6. Next, I created the file /srv/tftp/debian/menu.cfg
    
    menu background debian/splash.png
    menu begin Sid (amd64)
    menu title Sid (amd64)
            label Previous
            text help
            Return to previous menu
            endtext
            menu exit
            menu separator
            menu include debian/sid/amd64/boot-screens/menu.cfg
    menu end
    
    menu begin Sid (i386)
    menu title Sid (i386)
            label Previous
            text help
            Return to previous menu
            endtext
            menu exit
            menu separator
            menu include debian/sid/i386/boot-screens/menu.cfg
    menu end
    
    menu begin Wheezy (amd64)
    menu title Wheezy (amd64)
            label Previous
            text help
            Return to previous menu
            endtext
            menu exit
            menu separator
            menu include debian/wheezy/amd64/boot-screens/menu.cfg
    menu end
    
    
    
  7. I copied sid’s dists/sid/main/installer-amd64/current/images/netboot/debian-installer/amd64/boot-screens/splash.png to /srv/tftp/splash.png. That way, each distro family can have its own splash image!

After that, I added the other Sid distro (i386), following the same procedure. Here are some screenshots of the process (taken from my hosting workstation):

Next steps:

  • Add a foreign distro to the mix (e.g. Fedora 18, Arch)
  • Figure out how to boot and install a Windows image from this setup (probably very difficult).
    • Start with an old copy of Windows XP
    • Then go with Windows 7 (if I even have an ISO for it).

Set up Debian PXE boot server

I have always wanted to set up a Debian PXE (Pre-eXecution Environment) server, so I could have machines boot from the network and select an OS to install. Ultimately I expect to be able to do this with any OS, but at first I will have it boot various versions of Debian, from my local partial Debian mirror (maintained with debmirror).

    Right now I’m downloading the Debian installer images with debmirror. For the PXE boot server, I will be following this Debian Administration guide:

  1. The first thing it has me install is tftpd-hpa, which is easy enough:
    
    aptitude install tftpd-hpa
    
    

    This automatically started the tftpd-hpa daemon. The guide suggested I need to edit /etc/default/tftpd-hpa:

    
    # /etc/default/tftpd-hpa
    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/srv/tftp"
    TFTP_ADDRESS="0.0.0.0:69"
    TFTP_OPTIONS="--secure"
    
    

    The above are the defaults, and since those looked alright to me, I didn’t modify them. The directory /srv/tftp already existed on my system (probably from an earlier attempt at setting up PXE boot), and was empty.

  2. Next, I needed to set up my DHCP server. This is provided by my custom-built router/firewall, running pfSense. Many home routers don’t allow one to set DHCP options, but pfSense ain’t no ordinairy router. (-; I added my worksation/tftp server’s IP address (hostname did NOT work), put “pxelinux.0” as the filename, and that seemed to be it.
  3. The next step was to configure the PXE boot. I copied the pxelinux files, and debian-installer directory from my local debmirror:
    
    cp -R /var/spool/mirror/dists/sid/main/installer-amd64/current/images/pxelinux.* /srv/tftp/
    cp -R /var/spool/mirror/dists/sid/main/installer-amd64/current/images/netboot/debian-installer /srv/tftp/
    
    
  4. The final step was to test it. Once I configured my VirtualBox test machine, it booted into PXE, saw my server/workstation, and it is now installing Debian Sid!

Where to go from here?

  • Figure out the best way to list multiple Linux distributions
  • Figure out a way to have this boot Windows images

Neither of the above look trivial.