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.
**For Windows 2008 R2 installations you must set the bootimage via command-line as followed:
wdsutil /set-server /bootprogram:boot\x86\pxelinux.0 /Architecture:x86 wdsutil /set-server /bootprogram:boot\x86\pxelinux.0 /Architecture:x64 wdsutil /set-server /N12bootprogram:boot\x86\pxelinux.0 /Architecture:x86 wdsutil /set-server /N12bootprogram:boot\x86\pxelinux.0 /Architecture:x64 |
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 |
i am trying to acheive PXE boot for XenServer, anyone got this working. i dont seem to be able to get it working
We have configured kickstart in WDS. It boots proprly in pxe but during installation again it asks for ip configuration. Also not taking ks.cfg file.
Excellent guide! It works and straight away too!
Very detailed instructions with the logic.
Thanks a lot.
Very sweet, thanks.
If you plan to use HTTP with IIS to provide your packages, you’ll need to enable Directory Browsing.
I have WDS on Windows 2003 server. When I network boot a device I am not presented with an F12 option (Using pxelinux.0) and boots stratght into the menu
Excellent guide – I got the PXE boot working. I have some issues with the ubuntu installation though.
I am using a kickstart file to install Ubuntu 12.04 but The step Select Software and Install it keep failing.
Did anyone get a fully automated install to work?
hello sir,
i tried configuring your document.
but i got the following error
loading knl/vmlinuz
………………………………………………..
boot failed.press any key to try again or wait to reset
kindly help me
First of all thanks for wonderful tutorial, it helps me a lot.
I am using WDS with Windows server 2008 R2 and configured the PXE Linux for the Linux OS Installation. Also I have automate the Linux OS installation process using kickstart file. Currently I have to select the RedHat6 OS from the PXE menu manually at boot time. I want to automate this step also, is there any way to achieve this?
For windows OS there is a way like we can set the default client unattended file for the prestaged machine using below command:
WDSUTIL /Set-Device /Device:Computer1 /WDSClientUnattend:WDSClientUnattend\Unattend.xml
Thanks in advance, any help on this would really be very helpful.
Pingback: WDS Image Creation at Ohjeah!