PXE and Kickstart, Automated Installations for Linux via WDS
Today I decided to setup automated installations for Linux distros (RHEL, Fedora, CentOS), similar to how we deploy our Windows installations via PXE. Since we already had WDS running for installing Windows, it was just a matter of reconfiguring WDS, setting up the necessary structure and kickstart files for our automated Linux installations. While I do not cover the initial WDS installation process, I will attempt to go over the steps performed after the basic WDS install (native or mixed).
What you will need:
- Windows server running WDS (and working via DHCP).
- A recent copy of SYSLINUX (extracted to a folder somewhere on the WDS server).
- An HTTP or anonymous FTP server to hold your installation media.
Currently when I boot my computer with PXE enabled, I am prompted to hit F12 for network boot. When I press F12, I am prompted by “Windows Boot Manager” to select my boot images that I setup in WDS. Since I can’t install Linux images directly using the WDS interface, an alternative boot image is necessary. That is where SYSLINUX/PXELINUX takes over.
Pre-Setup
- Create the necessary directory structure inside the WDS RemoteInstall directory (this was specified during the WDS installation).
- Inside the x86 folder (RemoteInstall\Boot\x86\), create the following folders (including pxelinux.cfg):
- conf
- img
- knl
- pxelinux.cfg
- Inside the x86 folder (RemoteInstall\Boot\x86\), create the following folders (including pxelinux.cfg):
Preparing Installation Media
- Setup an FTP server to hold your installation media (HTTP works also): Currently the average size of a Red Hat distribution is about 5GB, so make sure the server you select will have the necessary disk space. You will need separate installation media for both distribution specific 32bit and 64bit installs. If you want Fedora 9, CentOS 5.2, and RHEL 5.2 images (both 32bit and 64bit), that will be about 30GB. As long as you’re not archiving old distributions, this should not be an issue.
- On my FTP server in the root/path, I created a directory for each of my installation media. Also, creating a standard naming convention will help with editing the configuration files later and any case sensitivity issues. Example: My directory names are DistroVersion_arc (Fedora9_32bit), as you will see later on.
- Copy the entire installation dvd media to the corresponding directories you created (not the .iso, extract its entire contents).
- In the FTP root directory for the media you copied, create a kickstart file (ks.cfg). (Example: ftp://ftpserver.domain.com/Fedora9_32bit/ks.cfg) I have included example kickstart files at the bottom of this article.
- Once you have copied the installation media for a distro to your FTP server, you need to copy 2 files from that specific distro media to your WDS server.
- From the (installation media\images\pxeboot) directory, copy the following:
- Copy vmlinuz to the following directory on the WDS server (RemoteInstall\Boot\x86\knl\). Rename the file to an identifying name such as vmlinuz-fedora9-32bit.
- Copy initrd.img to the following directory on the WDS server (RemoteInstall\Boot\x86\img\). Rename the file to an identifying name such as initrd-fedora9-32bit.
- From the (installation media\images\pxeboot) directory, copy the following:
When it comes time to configure your option menus, you will need to specify these files for each version/distro you plan on making available.
Configuring WDS
- From inside the downloaded SYSLINUX archive, copy the following files:
- pxelinux.0 from the (syslinux\core) directory to your (RemoteInstall\Boot\x86\) directory on the WDS server.
- menu.c32 and vesamenu.c32 from the (syslinux\com32\menu) directory to your (RemoteInstall\Boot\x86\) directory on the WDS server.
- Inside the (RemoteInstall\Boot\x86\) directory, create copies of the following files, rename them accordingly (you can copy paste then rename):
- Make a copy of pxeboot.n12, save it as pxeboot.0
- Make a copy of abortpxe.com, save it as abortpxe.0
- Inside (RemoteInstall\Boot\x86\pxelinux.cfg\), create a file called default. This will be the initial menu you see during PXE boot, edit the file and give it the following contents:
# File: wdspath\RemoteInstall\Boot\x86\pxelinux.cfg\default # Default boot option to use DEFAULT menu.c32 TIMEOUT 50 # Prompt user for selection PROMPT 0 # Menu Configuration MENU WIDTH 80 MENU MARGIN 10 MENU PASSWORDMARGIN 3 MENU ROWS 12 MENU TABMSGROW 18 MENU CMDLINEROW 18 MENU ENDROW 24 MENU PASSWORDROW 11 MENU TIMEOUTROW 20 MENU TITLE Main Menu # Menus # Windows LABEL Windows MENU LABEL Windows Installer KERNEL pxeboot.0 # x86 LABEL x86 MENU LABEL Linux 32bit Installs (x86) KERNEL menu.c32 APPEND conf/x86.conf # x64 LABEL x64 MENU LABEL Linux 64bit Installs (x64) KERNEL menu.c32 APPEND conf/x64.conf # Windows LABEL Exit MENU LABEL Exit KERNEL abortpxe.0
- Now you need to create the sub-menu configuration files for your 32 and 64 bit installs that you specified in your default file (RemoteInstall\Boot\x86\conf\x86.conf and RemoteInstall\Boot\x86\conf\x64.conf respectively). These files will list the available distros to install, and the path to your copied kernel\image files, including your kickstart file which contains the path for your FTP or HTTP installation media. Each option needs to point to the specific kernel and image that was created from the installation media earlier.
# File: wdspath\RemoteInstall\Boot\x86\conf\x86.conf # Default boot option to use DEFAULT menu.c32 # Prompt user for selection PROMPT 0 # Menu Configuration MENU WIDTH 80 MENU MARGIN 10 MENU PASSWORDMARGIN 3 MENU ROWS 12 MENU TABMSGROW 18 MENU CMDLINEROW 18 MENU ENDROW 24 MENU PASSWORDROW 11 MENU TIMEOUTROW 20 MENU TITLE Linux32Bit (x86) OS Selection # Return to Main Menu LABEL MainMenu MENU DEFAULT MENU LABEL ^Main Menu KERNEL menu.c32 # # Blank boots # LABEL Fedora 9 32bit MENU LABEL Fedora 9 32bit KERNEL knl/vmlinuz-fedora9-x86 APPEND initrd=img/initrd-fedora9-x86.img ks=ftp://ftpserver.mydomain.com/Fedora9_32bit/ks.cfg
# File: wdspath\RemoteInstall\Boot\x86\conf\x64.conf # Default boot option to use DEFAULT menu.c32 # Prompt user for selection PROMPT 0 # Menu Configuration MENU WIDTH 80 MENU MARGIN 10 MENU PASSWORDMARGIN 3 MENU ROWS 12 MENU TABMSGROW 18 MENU CMDLINEROW 18 MENU ENDROW 24 MENU PASSWORDROW 11 MENU TIMEOUTROW 20 MENU TITLE 64Bit (x64) OS Choice # Return to Main Menu LABEL MainMenu MENU DEFAULT MENU LABEL ^Main Menu KERNEL menu.c32 # # Blank boots # LABEL CentOS 5.2 64bit MENU LABEL CentOS 5.2 64bit KERNEL knl/vmlinuz-centos52-x64 APPEND initrd=img/initrd-centos52-x64.img ks=ftp://ftpserver.mydomain.com/CentOS52_64bit/ks.cfg LABEL Fedora 9 64bit MENU LABEL Fedora 9 64bit KERNEL knl/vmlinuz-fedora9-x64 APPEND initrd=img/initrd-fedora9-x64.img ks=ftp://ftpserver.mydomain.com/Fedora9_64bit/ks.cfg LABEL RHEL 5.2 64bit MENU LABEL RHEL 5.2 64bit KERNEL knl/vmlinuz-rhel52-x64 APPEND initrd=img/initrd-rhel52-x64.img ks=ftp://ftpserver.mydomain.com/RHEL52_64bit/ks.cfg
- Lastly, set WDS to use the pxelinux.0 boot image. If you need to get to the normal WDS boot image, you can use the Windows Installer option created in your default menu.
- Open Windows Deployment Services on your WDS server. Right click your server -> Properties. Under the Boot tab, set the Default boot program for x86 architecture (Boot\x86\pxelinux.0), or browse to the pxelinux.0 file we created earlier. You may leave the other architectures alone or change as you see fit.
Finished Result
http://www.ohjeah.net/wp-content/uploads/2008/10/linux_pxe.swf
Example Kickstart File
Here is an example kickstart file for Fedora 9. For each new distro I normally perform a cd install with my desired options, then use the resulting /root/anaconda-cfg.ks for assistance. Note that the kickstart file specifies the FTP path of your installation media that you created in the beginning of this article.
#Version=F9 #32bit install text url --url ftp://ftpserver.mydomain.com/Fedora9_32bit lang en_US.UTF-8 keyboard us network --device eth0 --bootproto dhcp rootpw --iscrypted $1$X.qPQYdk$L.YRbuORBd30 firewall --disabled authconfig --enableshadow --enablemd5 --passalgo=sha512 selinux --disabled timezone America/Chicago bootloader --location=mbr --driveorder=sda --append="rhgb quiet" clearpart --all --drives=sda part /boot --fstype ext3 --size=1000 part swap --size=2048 part / --fstype ext3 --size=1 --grow %packages @editors @development-tools @text-internet @core @base @hardware-support @admin-tools grub openldap openldap-devel openldap-client net-snmp* ntp

Did you do this on Win 2008 SVR with WDS?
Chadley
21 Oct 08 at 5:18 am
How can I customize the background displayed in the vesamenu.32?
Chadley
21 Oct 08 at 7:39 am
By the way thanks a million for this this it works briliantly, and I have learnt a whole lot from you.
I really appreciate the effort you have put in this how-to.
Chadley
21 Oct 08 at 7:42 am
This was on 2003 Server with WDS, though I would assume 2008 would be no different. I will probably end up trying it on 2008 in the future when it comes time to migrate to 2008 Server.
As for adjusting the background, they have some examples on the PXELINUX site, located at: http://syslinux.zytor.com/wiki/index.php/PXELINUX
jro
3 Nov 08 at 3:47 pm
save to my Bookmarks
alex
9 Dec 08 at 10:05 pm
This works fantastic on Server 2008/WDS. Thanks for the walkthrough…was going to make one myself but found his on Google first!
Now we can boot our HP firmware maintenance CD’s via PXE. Woohoo
(for anyone interested in that, you need to use the script found here http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1234547654850+28353475&threadId=1007139)
Preston Gallwas
13 Feb 09 at 2:52 pm
Good find, thanks for the info
jro
16 Feb 09 at 9:01 am
Unbelievable! It works and straight away too!
Very detailed instructions with the logic. Awesome!
10 out of 10.
Thanks a lot.
Jiljith C.P
19 Mar 09 at 8:28 am
This is exactly what I was trying to do…thank you! However, I followed the instructions exactly (WDS is on WS2008 64-bit, so I copied all of the above files into the x64 directory as well as x86, and adjusted the boot menu in the last step for that as well) and yet it’s behaving exactly as before – going straight into Windows install. If you have any thoughts, I’d greatly appreciate it. Otherwise, thanks again for the walkthrough, and hopefully I can figure out what I need to do to get it to work!
teleute
3 Sep 09 at 11:02 am
Did you try the setup just using the x86 directory/paths as I described? Or did you have an issue with that first and that is why you tried the x64 dir?
jro
3 Sep 09 at 11:19 am
I did just the x86 first, then added the x64 when that didn’t work (and the ia64 when *that* didn’t work).
teleute
3 Sep 09 at 11:56 am
When you say going straightinto Windows install, you’re saying it’s going straight into RIS?
jro
3 Sep 09 at 12:10 pm
Yes. I tell the machine I’m trying to install to to PXE boot. It waits about 5 seconds, then does exactly what it did before – shows “Windows is loading files” and the IP of the WDS server. And then it starts the Windows installation procedure. (It’s not RIS anymore in 2008, IIRC)
teleute
3 Sep 09 at 12:23 pm
Hmmm, I could see this happening if you were pointing the default boot program to pxeboot.0 instead of pxelinux.0, or if it was somehow replaced during the process. Try re-copying pxelinux.0 from the syslinux download and verify you are pointing to it in the WDS configuration: http://farm3.static.flickr.com/2086/2888619618_5404f127bc.jpg
jro
3 Sep 09 at 12:28 pm
Hmmm…I did have that, but I wiped it out and tried again, and restarted. Now I get the error “Windows failed to start. A recent hardware or software change might be the cause” etc…
File: \windows\system32\winload.efi
Status: 0xc0000225
Info: The selected entry could not be loaded because the application is missing or corrupt.
teleute
3 Sep 09 at 3:08 pm
Well…*sigh* I tested this just now when trying to deploy to a non-EFI machine and it’s fine (well, haven’t tweaked all the options, but the general framework is good). Most of the machines I have to deploy to are EFI, though. EFI’s caused me a bunch of issues in other areas, too…
I’m really grateful for your help to this point, and this great walkthrough. If you have any thoughts on the EFI issue that’d be amazing, but I don’t expect a thing.
teleute
3 Sep 09 at 3:31 pm
Are you running your WDS install in native or mixed mode? I know 2008 has some support for EFI though I’ve never attempted it myself. Pretty sure it has to be in native mode though.
jro
3 Sep 09 at 3:37 pm
It’s native mode.
teleute
3 Sep 09 at 3:39 pm
Oh, and the Windows deployment from this server to the EFI machines worked fine before trying to add the Linux stuff. So it’s probably the linux boot loader conflicting somehow, I’d think…
teleute
3 Sep 09 at 3:40 pm
Are you trying to boot Itanium/Macs or? Unfortunately I have no EFI systems to try this with 8(
jro
3 Sep 09 at 4:47 pm
It’s a Bladecentre HS22. Also, I rebooted and tried again, and now it’s back to just booting straight into the WDS and ignoring the existence of Linux altogether. *sigh* These Blades are a nightmare with Linux…
teleute
3 Sep 09 at 4:51 pm
I wish I had one to play with but unfortunately we’ve gone more of the Virtualization route
I’ll keep poking around, let me know if you figure it out!
jro
3 Sep 09 at 4:55 pm
Will do! Thanks so much.
One more quick question, if you’re not sick of me…;-) And this one might actually be helpful to other future readers. Can the paths to the image, kickstart file, etc… be paths local to the WDS machine, rather than ftp?
teleute
3 Sep 09 at 5:04 pm
nm on the path issue, btw.
Still hacking away at getting the EFI machines on board. I think the error message was a red herring – every other time it’s booted straight into WDS. So for some reason it’s just not seeing the Linux stuff at all. Anyway, I’ll let you know if I find anything more out.
teleute
3 Sep 09 at 6:06 pm
Yea, pxelinux won’t work for efi images. Everything I’ve read seems to recommend elilo.efi for the boot image. Might want to give that a try.
These links might be helpful:
http://syslinux.zytor.com/archives/2003-September/002468.html
http://listman.redhat.com/archives/kickstart-list/2003-July/msg00115.html
http://fedoraproject.org/wiki/QA:Testcase_UEFI_pxeboot
http://www.klabs.be/~fpiat/linux/debian/di-netboot-assistant/
http://www.gossamer-threads.com/lists/engine?do=post_view_printable;post=9223;list=syslinux
Guess I’ll have to add a elilo section once I pickup a efi machine.
jro
4 Sep 09 at 1:18 pm
Sweet…thank you so much! I wasn’t searching for IA64 because technically these aren’t IA machines, but hopefully the same thing will work for them. With any luck I’ll get around to trying this today, and I’ll let you know.
teleute
8 Sep 09 at 9:54 am
I’m not sure if I can describe this right, but I’ll try. I don’t think the Blade is even looking for a boot image at all. I put the elilo.efi image as the setting for ia64 machines, and still the Blade went straight to Windows. Then put it for all of them, and the Blade went straight to Windows. A non-Blade went to elilo.efi, so it’s definitely in there and being read in general. In fact, if I put in a non-existent path, the other machines all show that they’re trying to read garbage.com or whatever I’ve put in there, and they hang. The Blade just goes to Windows every single time. I’m writing IBM today, but I’m not holding my breath on them supporting this…*sigh*
teleute
9 Sep 09 at 11:22 am
Well, you’ll be happy to know I’ve given up on EFI.
There’s a slightly buried option when you set the boot order called “legacy only”. I say buried because it didn’t actually appear – I had to go into “Add Boot Option” and scroll through a tonne of stuff to see it. Anyway, put that first and then everything works fine, and that’s how I’m leaving it. Thanks for all your help!
teleute
15 Sep 09 at 6:21 pm
The Above steps I have tried on Microsoft WDS 2008 and its works!!!!, but I have small issue when I select EXIT menu to abortpxe.0 it wont go to next boot, it hangs there.. I have copied the abortpxe.com to abortpxe.0
jack
24 Sep 09 at 9:04 am
Hello,
First of all, very nice tutorial!
im trying with the debian netinstall(debian-503-i386-netinst.iso), extracted the iso to my apache http server (wich is reachable)
in conf/x86.conf i have:
LABEL Debian Lenny new 2.6.26.2 32bit
MENU LABEL Debian Lenny new 2.6.26.2 32bit
KERNEL knl/vmlinuz
APPEND initrd=img/initrd.img ks=http://10.4.3.72/debian-503-i386-netinst/preseed.cfg
i use the pxe boot and i can choose for that version, it loads vmlinux and initrd.img and it starts with the debian setup. But it isnt going automatically! and i dont know what im doing wrong.. plus when i go tru the setup it suddenly ask for mounting cdrom, but its a netinstall! those 2 problems i have wich i dont know how to fix.
this is the layout of my preseed.cfg (also tried to name is ks.cfg)
#### Contents of the preconfiguration file (for lenny)
### Localization
# Locale sets language and country.
d-i debian-installer/locale string en_US
# Keyboard selection.
#d-i console-tools/archs select at
d-i console-keymaps-at/keymap select us
# Example for a different keyboard architecture
#d-i console-keymaps-usb/keymap select mac-usb-us
### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
# To pick a particular interface instead:
#d-i netcfg/choose_interface select eth1
# If you have a slow dhcp server and the installer times out waiting for
# it, this might be useful.
d-i netcfg/dhcp_timeout string 60
# If you prefer to configure the network manually, uncomment this line and
# the static network configuration below.
#d-i netcfg/disable_dhcp boolean true
# If you want the preconfiguration file to work on systems both with and
# without a dhcp server, uncomment these lines and the static network
# configuration below.
#d-i netcfg/dhcp_failed note
#d-i netcfg/dhcp_options select Configure network manually
# Static network configuration.
#d-i netcfg/get_nameservers string 192.168.1.1
#d-i netcfg/get_ipaddress string 192.168.1.42
#d-i netcfg/get_netmask string 255.255.255.0
#d-i netcfg/get_gateway string 192.168.1.1
#d-i netcfg/confirm_static boolean true
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
# The wacky dhcp hostname that some ISPs use as a password of sorts.
#d-i netcfg/dhcp_hostname string radish
# If non-free firmware is needed for the network or other hardware, you can
# configure the installer to always try to load it, without prompting. Or
# change to false to disable asking.
#d-i hw-detect/load_firmware boolean true
### Network console
# Use the following settings if you wish to make use of the network-console
# component for remote installation over SSH. This only makes sense if you
# intend to perform the remainder of the installation manually.
#d-i anna/choose_modules string network-console
#d-i network-console/password password r00tme
#d-i network-console/password-again password r00tme
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
d-i mirror/protocol string ftp
# d-i mirror/country string manual
d-i mirror/http/hostname string http.us.debian.org
etc…
Anyone who can help me? (i followed the tuturial three times, just to be sure!)
Niels
11 Dec 09 at 11:58 am
Right, followed all the steps and fell at the last hurdle.. canot change the boot option on wds to use the pxelinux.0 boot image. Can change the default boot image, when I click select there are none listed. Under Boot images folder I can only add the wim type.
Does this work on 2008 R2? Fresh install in it’s own domain, PXE boot works fine but only windows.
Help!
Cheers, Jim
Jimbo
27 Jan 10 at 11:05 am
Is it not letting you change the field at all or just not letting you select the pbxlinux.0 image?
jro
27 Jan 10 at 11:12 am