Header Shadow Image


LINUX PXE: Installing and Network Booting Windows 7, Linux, Solaris using PXE

In this post we'll configure network booting through PXEPXE stands for Preboot eXecution Environment and has been available for Network Devices (or NIC's) for some time.  Such a network boot setup has many uses in particular in OS setup and deployment.  In this post I'll introduce the steps to quickly set one up.  The only thing required is some patience, persistance and a second NIC (NIC also known as Network or Network Interface Card) card on the second PXE server together with a network cable.  Some of the benefits are:

  1. The target environment where the OS will be installed does not need any external storage devices such as USB or CD/DVD drives.
  2. There is no CD burning.  It is all software based.
  3. Most motherboards and computers support PXE today.
  4. You are not limited to a single file size limit in place on some USB devices.
  5. There's no OS size restrictions.  The amount of data available to the boot software is only limited by the amount of free hard disk space on the PXE server.

These are just a few advantages that PXE has and the cost of setup, as we will see, is only time and a little patience.

For this post, I'll simply list the configuration files in place to be used.  I'll highlight in each the section that can represent the addition of a new entry to the boot menu with a blue color.  The highlighted section would represent the steps to take when adding a new OS to boot.  All items in BLUE below represent the changes that would be needed to add a new OS to the choices after this PXE setup is complete.

Here we also have the option of booting Windows 7 but that will be left for another topic.

PXE SETUP

We'll begin by setting up your Linux workstation as a PXE boot server.

Check for required packages.

Run these or install the latest DHCP, XINETD, HTTPD and TFTP packages for your environment.  Most should already come with your distribution.  If not, below are some examples to use:

# rpm -qa|grep -i dhcp
dhcp-4.1.0p1-13.fc12.i686
# rpm -aq|grep -i tftp
tftp-server-0.49-5.fc12.i686
tftp-0.49-5.fc12.i686

# rpm -aq|grep xinetd
xinetd-2.3.14-32.fc13.i686
# rpm -aq|grep httpd
httpd-2.2.15-1.fc13.i686

 

Install a second network card and configure it.

PXE will need to connect to your server using ethernet.  To that end, you need a second network card and a straight through cable.  For this step you'll need to install the second network card (Preferrably 100Mbits or higher).  The above links also contains instructions on debugging in case you are having problems.  In the end, this is what the configuration we will need looks like and what the contents of ifcfg-eth1 should be before proceeding to the next steps (if you already have ifcfg-eth1 create ifcfg-eth2 instead):

# ifconfig eth1
eth1  Link encap:Ethernet  HWaddr 00:02:E3:17:E1:47 
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::202:e3ff:fe17:e147/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:569836 errors:0 dropped:0 overruns:0 frame:0
          TX packets:799910 errors:6 dropped:0 overruns:6 carrier:6
          collisions:0 txqueuelen:1000
          RX bytes:206818639 (197.2 MiB)  TX bytes:1090171901 (1.0 GiB)
          Interrupt:17 Base address:0×4000

# cd /etc/sysconfig/network-scripts

# cat ifcfg-eth1
# National Semiconductor Corporation DP83815 (MacPhyter) Ethernet Controller
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.1.1
NETMASK=255.255.255.0
HWADDR=00:02:E3:17:E1:47
NM_CONTROLLED=no
USERCTL=no
IPV6INIT=yes
TYPE=Ethernet
DNS1=192.168.0.1
 

NOTE: It is assumed here that eth0 is your primary NIC you already have working and can browse the web with.  This tends to be handy.

Setup DHCP on the second NIC.

Below is the configuration we are going to use so the DHCP server can assign IP addresses to new machines that we will connect:

# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {

        # Set the default gateway / netmask / broadcast to be used by the PC clients
        option routers                  192.168.1.1;
        option broadcast-address        192.168.1.255;
        option subnet-mask              255.255.255.0;

        default-lease-time 43200;
        max-lease-time 86400;

        allow booting;
        allow bootp;
        default-lease-time 21600;
        max-lease-time 43200;

        group {
                next-server 192.168.1.1;
                # This is the pxe bootloader file
                filename "pxelinux.0";
                # One host block per client. This network only has one.
                host stb1 {
                        hardware ethernet 00:11:5b:1c:4b:21;
                        fixed-address 192.168.1.2;
                        filename "FCSystem";
                        option root-path "/tftpboot";
                                                                                        # filename "\\Boot\\WINSystem";
                }
                host stb2 {
                        hardware ethernet 90:e6:ba:c6:7d:35;
                        fixed-address 192.168.1.2;
                        filename "FCSystem";
                        option root-path "/tftpboot";
                }
                host stb3 {
                        hardware ethernet 00:0c:6e:53:9f:a6;
                        fixed-address 192.168.1.2;
                        filename "FCSystem";
                        option root-path "/tftpboot";
                }

                host stb4 {
                        hardware ethernet 1c:6f:65:3f:fc:14;
                        fixed-address 192.168.1.2;
                        filename "FCSystem";
                        option root-path "/tftpboot";
                }
        }

}
 

Issue:

# service dhcpd restart

There are a few important sections in each area:

  1. The hardware ethernet address, is the MAC address of the remote machine that we will connect to this server.  You will need this from the remote server you are configuring.  If unclear on how to obtain this, it could be retrieved either from the first boot attempt: the MAC may show up on the PXE server /var/log/messages file on first attempt, or from the boot up screens of the remote machine.
     
  2. fixed-address: The address that will be assigned to the remote machine when it attempts to connect.
     
  3. FCSystem is, in essence, the base boot system that will be loaded over the network.  It is the kick start boot file chain link that will allow booting everything else.  This file can be copied from the following files on your system.  It can be renamed to whatever you like:

    # ll /usr/share/syslinux/pxelinux.0
    5965619 -rw-r–r– 1 root root 16466 Jan 12  2010 /usr/share/syslinux/pxelinux.0
    # ll /usr/share/syslinux/gpxelinux.0
    5966129 -rw-r–r– 1 root root 75564 Jan 12  2010 /usr/share/syslinux/gpxelinux.0
    #

    The gpfxlinux.0 is the open source gPXE boot loader and what we used here.  I simply copied it as and to /tftpboot/FCsystem.
     

  4. The /tftpboot folder is where all the boot files reside in and where the boot environment will kick things off of.  It can be any path of your naming choice but per convention, /tftpboot is used.

 

Ensure allow bootp and allow booting is also defined as per above.

The /tftpboot menu files. 

Below is a sample of how I setup mine on my own system:

# cat /tftpboot/fcboot.msg (Optional)

?splash.lss
————————————————————————-
 -  To install/upgrade F14(64) type 0f'f14-64'07.
 -  To install/upgrade Scientific Linux (64) type 0f's6.1-64'07.
 -  To install/upgrade Ubuntu 11.04 (64) type 0f'u11.04-64'07.
 -  To install/upgrade Ubuntu 10.04 (i386) type 0f'u10.04-i386'07.
 -  To install/upgrade Solaris 10 type 0f's10'07.
 -  To install/upgrade Windows 7 type 0f'w7'07.
————————————————————————-
 -  You may add additional options such as 0f'askmethod'07 or
    0f'text'07 or 0f'rescue'07 or 0f'dd'07.  For example
    0f'f11 dd xfs text askmethod'07.
——————————————————————————
02/F1-Main/F2-HTTP/F3-Final/F4-Lending/F5-Work 1/F6-Work 2/F7-Friend/07

# cat /tftpboot/pxelinux.cfg/default
# prompt 1
default vesamenu.c32
timeout 600
# display fcboot.msg

menu background splash.jpg
menu title PXE Network Installation Menu (F1 for Help & Details)
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

F1 vesamenu.c32
F2 fcboot.msg
F3 http.msg
F4 final.msg
F5 lending.msg
F6 work-1.msg
F7 work-2.msg
F8 friend.msg

label memtest
        menu label Fedora 14 (64) System Memory Test
        kernel f14-64/isolinux/memtest

label s6.1-64
        menu label Scientific Linux (RHEL) 6.1 (64)
        kernel s6.1-64/isolinux/vmlinuz
        append initrd=s6.1-64/isolinux/initrd.img

label f14-64
        menu label Fedora 14 (64) (Standard)
        kernel f14-64/isolinux/vmlinuz
        append initrd=f14-64/isolinux/initrd.img

label u10.04-i386
        menu label Ubuntu 10.04 (i386)
        kernel u10.04-i386/casper/vmlinuz
        append initrd=u10.04-i386/casper/initrd.lz

label u11.04-64
        menu label Ubuntu 11.04 (64)
        kernel u11.04-64/casper/vmlinuz
        append initrd=u11.04-64/casper/initrd.lz

LABEL w7
        MENU LABEL Windows 7 (Beta / Pre release)
        KERNEL Boot/startrom.0
 

Explanation for a few things is in order:

  1. These files define the boot menu that will be seen on the remote server.  here we will use the vesamenu.c32, which is a more GUI oriented rather then text oriented.  Just looks better.  :)   The alternative, currently commented, is the fcboot.msg file if a text menu is preferred.
  2. The paths are relative to the /tftpboot folder.
     

The boot menu, when loaded, will look like this:

 

The HTTPD server httpd.conf file. 

The httpd.conf file should contain the locations the installation can retrieve the entire ISO image installation files once selections have been made:

# cat /etc/httpd/conf/httpd.conf|tail -n50

.
.
.
.

<Directory /tftpboot/RHEL4-22B>
   Options Indexes
   AllowOverride None
</Directory>
Alias /rhel4-22b /tftpboot/RHEL4-22B

<Directory /tftpboot/f14-64>
   Options Indexes
   AllowOverride None
</Directory>
Alias /f14-64 /tftpboot/f14-64

<Directory /tftpboot/s6.1-64>
   Options Indexes
   AllowOverride None
</Directory>
Alias /s6.1-64 /tftpboot/s6.1-64

<Directory /tftpboot/u11.04-64>
   Options Indexes
   AllowOverride None
</Directory>
Alias /u11.04-64 /tftpboot/u11.04-64

<Directory /tftpboot/u10.04-i386>
   Options Indexes
   AllowOverride None
</Directory>
Alias /u10.04-i386 /tftpboot/u10.04-i386

In order for the above new definitions to take effect, you'll need to restart the Apache HTTPD daemon:

# service httpd restart

Then test by typing the links below into a browser:

  1. http://192.168.1.1/s6.1-64/
    OR
  2. http://192.168.0.1/s6.1-64/

     

Either link should produce a list of files for the distribution.  (You'll need to mount the ISO if nothing shows up.  See further down for this.  The below links even worked for me so would be a good test for your installation if everything is wroking correctly.)
 

[DIR] Parent Directory   -  
[DIR] EFI/ 27-Jul-2011 16:52 -  
[TXT] GPL 27-Jul-2011 16:53 18K  
[DIR] Packages/ 27-Jul-2011 16:31 -  
[   ] RPM-GPG-KEY-sl 27-Jul-2011 16:53 1.8K  
[   ] RPM-GPG-KEY-sl3 27-Jul-2011 16:53 1.9K  
[   ] RPM-GPG-KEY-sl4 27-Jul-2011 16:53 1.9K  
[   ] RPM-GPG-KEY-sl5 27-Jul-2011 16:53 1.9K  
[   ] RPM-GPG-KEY-sl6 27-Jul-2011 16:53 1.9K  
[   ] TRANS.TBL 27-Jul-2011 17:00 2.8K  
[DIR] images/ 27-Jul-2011 16:53 -  
[DIR] isolinux/ 27-Jul-2011 16:52 -  
[DIR] repodata/ 27-Jul-2011 16:34 -  

Check the /var/log/httpd/ folder and files for any error messages if it is not working for you.  Potentially, the firewall, if you have one, may be blocking content.  Adjust it accordingly.  You may also need to define which ports and interfaces the Apache HTTPD server listens on:

Change /etc/httpd/conf/httpd.conf

FROM

Listen 80

TO

Listen 80
Listen 192.168.1.1:80

By default, httpd may already listen on all interfaces defined.

Check the /etc/xinetd.d/tftp config file. 

Ensure that your tftp xinetd file is setup correctly.  By default, it should already be defined as per below or similar so no changes should be necessary.  Below is a sample configuration that worked with the setup in this post.  Adjust accordingly to your tastes:

# cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot -vvvvvvvv –verbosity 10 -m /etc/tftpd.map
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

To ensure the file is taken into effect, issue:

# service xinetd restart

Pay close attention to the output messages to ensure everything has restarted and is working correctly.

Download and mount the ISO's you defined menu options for above.

For this step, I created a short script to mount my ISO's from various sources.  I mounted them all under the /tftpboot but stored the ISO's elsewhere on the system:

# cat /tftpboot/mount.ksh
#!/bin/ksh

mount -o loop /Files/Ubuntu/ubuntu-11.04-desktop-amd64.iso /tftpboot/u11.04-64/
mount -o loop /home/Files/u10.04.i386/ubuntu-10.04-desktop-i386.iso /tftpboot/u10.04-i386
mount -o loop /home/Files/F14-64/Fedora-14-x86_64-DVD.iso /tftpboot/f14-64/
mount -o loop /home/Files/S6.1/SL-61-x86_64-2011-07-27-Install-DVD.iso /tftpboot/s6.1-64

You'll need to create each of the mount points (BOLD BLACK) to each of the downloaded ISO's (BOLD GREEN) you would like to use.  All are mounted using the loopback device (-o loop).

Add .msg files to make for a user friendly informative menu. (Optional)

Below is a sample of a .msg file, /tftpboot/http.msg.  The ^ NNN characters are special codes that highlight.  They can be generated by pressing the CTRL (see below):

^L
Once you start the installation, you can choose ^O0f'HTTP'^O07 as the install method.
Doing so the installation will prompt you for network parameters.  Use the
following:

^O0fIP            : 192.168.1.2^O07
^O0fMASK          : 255.255.255.0^O07
^O0fGATEWAY       : 192.168.1.1^O07
^O0fFIRST DNS     : 192.168.1.1^O07

Following this, the system will ask you for the location of the files.  Use the
following:
^O0fHOST          : 192.168.1.2^O07
^O0fLOCATION      : /<FOLDER>^O07

where

^O0f<FOLDER>^O07 is the same option that you selected on the opening screen such as
^O0f'fc4'^O07 or ^O0f'rhel4-22'^O07
——————————————————————————
^O02/F1-Main/F2-HTTP/F3-Final/F4-Lending/F5-Work 1/F6-Work 2/F7-Friend/^O07

CUSTOMIZING THE .MSG FILES

There are a couple of characters in the .msg files you may be interested in (Press and hold all three down together or press O while holding ctrl-v down):

CTRL-V-O
CTRL-V-L

The ctrl-v-o is followed by '07' or '0f' etc.  In fcboot.msg, to display the splash.lss file, use:

^L
^Xsplash.lss
(The rest of the message here)
.
.

This will create a customized boot menu for you with an image.

On the remote machine, enable PXE boot in the boot menu. Visit your PC or Motherboard manual to enable PXE or pre boot execution on the machine. 
Connect and test. Ensure your new PC/Server is connected on it's primary NIC to the secondary NIC on your newly configured PXE server.

 

When given a choice where to obtain installation files from, select HTTP then use one of the HTTP URL's you defined above, and tested with, in the httpd.conf part of the configuration.

Inevitably, there is always problems with initial setup or any setup.  The next page deals with some things you may encounter and their solutions. (Work In Progress)

Cheers!
TK

4 Responses to “LINUX PXE: Installing and Network Booting Windows 7, Linux, Solaris using PXE”

  1. I dont see any entry for Solaris. Can you help me with setting up PXE server having Solaris and Linux Machines

  2. Hey TuxFreak,

    Thank you. Appreciate the feedback. I’d have to write it up from my notes. It’s been on my long to do list for a while. :)

    Cheers!,
    TK

    P.S. Great name!

  3. [...] bit belated but …. a bit of PXE on a mobile platform to try different LVM versions in case one doesn’t work and LVM Recovery in [...]

  4. udhaya ganesh.k on February 22nd, 2012 at 8:14 am

    Hello,
    Now am doing a project.the title is universal remote boot and administration service. The concept is booting operating systems over wider area network.It overcomes the traditional PXE/DHCP/TFTP restrictions….Here the traditional PXE is replaced by PBL(preboot linux) and WBM(wan boot manager)…

    where can i get these two exact components?
    Also i need the system requirements to do this project..
    link for this project: http://ieeexplore.ieee.org/xpls/abs_…=6102270&tag=1
    thank you…

Leave a Reply

 


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License