• ARTICLES
SEARCH

How-To Geek

What Is Network Booting (PXE) and How Can You Use It?

Have you ever needed to troubleshoot or diagnose a problematic computer and you forgot where the utility CD is? We’ll show you how to utilize network booting (PXE) with FOG to make that problem a thing of the past.

Image by h.koppdelaney

Overview of PXE

PXE (Pre eXecution Environment), affectionately pronounced Pixie (as in fairy dust), is a method of having an end computer (client) boot using only its network card. This method of booting was created way back in 1999 and as long as the computer in question is connected to the network (and supports this standard), it is possible to circumvent the normal boot procedure (I.E. Power on –> BIOS –> HD/CD) and do some nifty stuff starting from troubleshooting, to using a liveOS and even re-imaging the machine…. but we are getting ahead of our selves lets get back to the beginning.

When using PXE the boot process is changed from the normal order to:

Power on –> BIOS –> Network Card’s PXE stack –> Network Boot Program (NBP) downloaded using TFTP from server to Client’s RAM –> NBP’s responsibility to perform the next step (a.k.a. 2nd stage boot).

Using the “PXElinux” NBP, it is possible to setup the server for more then just one PXE boot program for our clients. In a sense, it is the secret ingredient that enables us to perform all of the above and then some. For a more in depth explanation of the entire process, its history and some of the infrastructure options it and gPXE (which is a more evolved cousin) enable, see this lecture on YouTube from their developers. Also, below is a video of a setup from 2008 that quickly goes over some of the boot possibilities.

Note: In this video, the deprecated UDA project is used as the base for the server, and the annotations were aimed to explain to a friend the (at the time) recent additions made to it.

Goal

This guide will be the first of a series of guides about PXEing. In this guide, we will lay the foundations which we will build upon in future articles.

Recommendations, Assumptions and Prerequisites

  • The client machine you are testing with, supports PXE bootingand you know how to enable it.
  • This guide was written and tested using Debian Squeeze, Ubuntu server 9.10 and Linux Mint10. Therefore it is assumed that you have a Debian based system to work with as well.
  • You may want to have a look at How to Setup Software RAID for a Simple File Server and How to Setup Network Link aggregation (802.3ad), because the disk and network bandwidth demands on this kind of a server can get real high real fast. Building on the foundation of a server with high resiliency for its network and disk subsystems is highly recommended.
  • You will see me use VIM as the editor program, this is just because I’m used to it… you may use any other editor that you’d like.

Installation – The heavy lifting by leveraging FOG

FOG is a free, open source computer cloning solution created by *Chuck Syperski and Jian Zhang. FOG takes regularly available software (like Apache, MySQL and tftpd-hpa to mention a few) and packages them into a free and productized PC Lifecycle management (PCLM) solution. Using this free PCLM it is possible to backup a computers state by imaging it, deploy programs and settings (I.E. Firefox, Office, Printers & etc’) and configuration policies (I.E. automatic logoff and screen saver settings) to mention a few, through one central web interface.
Note: An interview with Chuck and Jian about FOG is available at the Tightwad Tech.

Using FOG as the foundation for your PXE server, is a great shortcut to having all of the necessary parts like TFTP and if required, DHCP in place without having to install and configure them manually, while granting you all of FOG’s functionality as a bonus.

As our goal is to add functionality to this already great system, we will not cover how to use FOG itself, nor its installation procedure in depth. FOG’s wiki, with their written & video how-tos is sufficiently robust to get the in depth information, if you want to geek through it. The summarized steps are:

  • sudo mkdir -p /opt/fog-setup
    cd /opt/fog-setup

  • Download the latest FOG packagefrom sourceforge to the directory created in the previous step.
  • Extract the package and start the installation.

    sudo tar -xvzf fog*
    cd fog*
    cd bin
    sudo ./installfog.sh

  • You will be prompted several times by the installer:
    1. What version of Linux would you like to run the installation for? – 2 (again, assuming a Debian based system is used)
    2. What type of installation would you like to do? [N] – Enter
    3. What is the IP address to be used by this FOG Server? [server-IP-detected-on-eth0] – Enter.
    4. Would you like to setup a router address for the DHCP server? [Y/n] – Enter.
    5. Would you like to setup a DNS address for the DHCP server and client boot image? [Y/n] – Enter.
    6. Would you like to change the default network interface from eth0? If you are not sure, select No. [y/N] – Enter.
    7. Would you like to use the FOG server for dhcp service? [Y/n] – *Enter
    8. This version of FOG has internationalization support, would you like to install the additional language packs? [Y/n] – n.
    9. Are you sure you wish to continue (Y/N) – Y.
    10. Acknowledge and follow the on screen instructions for MySQL.
    11. Leave the MySQL password blank for the root account.
    12. Would you like to notify the FOG group about this installation? – Y (recommended)

    Image from the FOG wiki.
  • Go to the Fog address with your browser and follow the on screen instructions.

*Note:  Assuming you do NOT have another DHCP  or that it is not setup to handle PXE. If you want to configure your existing DHCP, see Configure DHCP for PXE.

As far as installing FOG goes, that should be it. Again, while FOG is a great system, using it, is not the focus of this guide, and we encourage you to head over to it’s wiki so you can get a better grasp of FOG’s abilities and how it can help you to manage your clients lifecycle.

If all when well you should be able to PXE boot your client machine (usually F12) and get greeted by FOG’s default menu.

Image captured by Hotfortech.

As a quick “taste of things to come” you may select the “Run Memtest86+” option and get greeted by the Memtest program we covered in our “Diagnose PC Hardware Problems with an Ubuntu Live CD” guide.

File and directory Structures

As stated earlier, our aim is to extend FOG’s abilities and to that end we will need to add some files and directories.

Create the subdirectory structure:

sudo mkdir -p /tftpboot/howtogeek/menus
sudo mkdir -p /tftpboot/howtogeek/linux
sudo mkdir -p /tftpboot/howtogeek/pics
sudo mkdir -p /tftpboot/howtogeek/utils

These sub-directories will serve as templates for all the pictures, programs and configurations we will use to extend FOG.

Adjusting the “default” configuration file

We will build a new main menu, and put all of the FOG functions into their own sub-menu.

Copy the /tftpboot/pxelinux.cfg/default configuration file into howtogeek/menus/fog.cfg

sudo cp /tftpboot/pxelinux.cfg/default /tftpboot/howtogeek/menus/fog.cfg

Now edit the content of the original “default” file:

sudo vim /tftpboot/pxelinux.cfg/default

Make its content look like this:

DEFAULT vesamenu.c32
MENU TITLE FOG 0.32 + HowToGeek's enhancements
MENU INCLUDE /pxelinux.cfg/master.cfg
menu color title 1;36;44 #ff8c00 #00000000 std
LABEL FOG
MENU LABEL Manual FOG
MENU DEFAULT KERNEL vesamenu.c32
APPEND howtogeek/menus/fog.cfg

LABEL Utils MENU
LABEL Utilities
KERNEL vesamenu.c32
APPEND howtogeek/menus/utils.cfg

LABEL Linux
MENU LABEL Linux stuff
KERNEL vesamenu.c32
APPEND howtogeek/menus/linux.cfg
LABEL fog.local
localboot 0
MENU LABEL Boot from hard disk
TEXT HELP Boot from the local hard drive. If you are unsure, select this option.
ENDTEXT
PROMPT 0 TIMEOUT 300
ONTIMEOUT fog.local

When we finish, this configuration will give you 3 sub-menus: “Utilities”, “Manual FOGing”, “Linux stuff”.

Create the “master” file

The master file allows us to make global changes to the look and feel of the menus without reentering them individually over and over. Things like the default background picture, border stile, position Etc’, will all be consolidated in this master.cfg file.

Create the file:

sudo vim /tftpboot/pxelinux.cfg/master.cfg

Make it’s content look like:

MENU BACKGROUND fog/genie.png
menu color screen 37;40 #80ffffff #00000000 std
menu color border 30;44 #9370db #00000000 std
menu color title 1;36;44 #ff8c00 #00000000 std
menu color unsel 37;44 #ffffffff #00000000 std
menu color hotkey 1;37;44 #ffffffff #00000000 std
menu color sel 7;37;40 #4eee94 #9370db all
menu color hotsel 1;7;37;40 #e0400000 #20ff8000 all
menu color disabled 1;30;44 #60cccccc #00000000 std
menu color scrollbar 30;44 #40000000 #00000000 std
menu color tabmsg 31;40 #90ffff00 #00000000 std
menu color cmdmark 1;36;40 #c000ffff #00000000 std
menu color cmdline 37;40 #c0ffffff #00000000 std
menu color pwdborder 30;47 #80ffffff #20ffffff std
menu color pwdheader 31;47 #80ff8080 #20ffffff std
menu color pwdentry 30;47 #80ffffff #20ffffff std
menu color timeout_msg 37;40 #80ffffff #00000000 std
menu color timeout 1;37;40 #c0ffffff #00000000 std
menu color help 37;40 #c0ffffff #00000000 std
menu color msg07 37;40 #90ffffff #00000000 std

MENU MARGIN 0
MENU PASSWORDMARGIN 3
MENU ROWS 15
MENU TABMSGROW 21
MENU CMDLINEROW 20
MENU PASSWORDROW 11
MENU TIMEOUTROW 20
MENU HSHIFT 0
MENU VSHIFT 0

The configuration above, will create the purple borders and highlighting, if you whish to have a different look and feel, simply change the values.
To set a background picture, put a picture in the “/tftproot” directory and point the “MENU BACKGROUND” to the picture’s relative path (we recommend using pictures with resolution of 640*480). For example the full path for the above configured picture would be: “/tftproot/fog/bg.png“.

Connect the FOG sub-menu to the main menu

Because we made a simple copy of the original configuration file into the menus sub-directory (keeping its color schema, timeouts and alike), if you go into this sub-menu now from the PXE booted client, it would work, but you will not be able to return to the main menu without rebooting the machine.

So edit the /tftpboot/howtogeek/menus/fog.cfg file:

sudo vim /tftpboot/howtogeek/menus/fog.cfg

Add this entry after the “menu color title” entry and before the FOG functions:

LABEL back
MENU LABEL ..
KERNEL vesamenu.c32
APPEND pxelinux.cfg/default

Create the sub menu skeletons

We have created 4 sub-menus, three of them are up to us to fill. To do so, lets create the template that we will be building on.

Create the template file:

sudo vim /tftpboot/howtogeek/menus/template.cfg

Make this its content:


MENU INCLUDE /pxelinux.cfg/master.cfg
#MENU BACKGROUND howtogeek/pics/fog-sub.jpg
LABEL back MENU LABEL ..
KERNEL vesamenu.c32
APPEND pxelinux.cfg/default

Lets set the stage for additional sub-menus, which will be covered in future guides:


cd /tftpboot/howtogeek/menus/
sudo cp template.cfg ./utils.cfg
sudo cp template.cfg ./linux.cfg

That’s it, the basic layout is now ready and from now on, we only need to build upon it, which we will in future guides. Until these future guides arrive, you are encouraged to get familiar with FOG as it is an exciting ride upon it’s self.

Update: The future is here :)

How To Network Boot (PXE) The Ubuntu LiveCD
How to Network Boot the BitDefender Rescue CD (PXE)
How to Setup Network Bootable Utility Discs Using PXE


Go FOG yourself

Comments (18)

  1. Ashish Jain

    Hello,

    Great article,
    I am working on developing a deployment solution ( a free ware utility) that will help in capturing/deploying images, rolling out OS installation. On single machine or the machine which are in production this works great. but now i am looking for a windows based TFTP solution.
    Is there any free windows based TFTP software, which i can directly call and boot machine in PXE.

    Thanks.

  2. Har

    Cool dandelion :3

  3. Aviad

    @Ashish Jain
    Yes, you can use either TFTPD32 or hack the windows WDS service…

  4. Ashish Jain

    Thanks Aviad for the quick reply.

  5. hoanglan

    Thanks for your great article. I used dnsmasq and samba file server to install windows via LAN, read this link: http://www.savelono.com/linux/how-to-install-windows-7-over-a-network-using-linux-pxe-dnsmasq-and-samba.html

  6. Aviad

    @Cerveza
    Making the images you deploy hardware agnostic, is an inherent problem of all imaging mechanisms…. FOG isn’t meant to change that and there for will not help with your specific problem.
    What FOG does excel in, is the fact that it’s “deployment agent” is as close to hardware agnostic as possible and gets updated by the community to keep it at that level.

  7. Dan

    Good stuff. I’m using PXE for any of my machines. Boot from disk, you get a typical Windows/Linux desktop. Boot from network, you get XBMC. Sweet.

  8. Jon

    why are you not talking? I can here you touching your keyboard

  9. Aviad

    @Jon
    hhh, this video was never meant to be published… it was just a quick show for my friend… :)

  10. stan cartwright

    I use macrium reflect free and a usb hd.works with the linux restore disk snd bartpe.Is this backup a better solution?stan

  11. Aviad

    @stan cartwright
    with FOG and PXE you can centrally manage machines backup & restores, over the network without having to go to the workstation with an external HD.
    with that said, FOG doesn’t grant you the ability to do file level backup and restore, if that is what you are looking for.

    hope that answered your question

  12. Bobby

    Thank you, thank you, thank you, thank you!!!!!!!!!!!!!!!!!!

    Also, any way to do a future guide on implementing Hirens into the PXE. That would be so badass!!

  13. Aviad

    @Bobby

    you’re welcome, welcome, welcome ^_^
    as for Hirens, at the very least it was possible to implement it into this PXE setup… (last time i checked it was just a matter of taking the floppy img files from the CD and running them from the TFTP) but in all honesty, why would we even bother?

    can you tell me of a single function Hiren has that Ubuntu can’t address?

  14. Bobby

    http://www.hiren.info/pages/bootcd < I am in a windows environment at work and it would be cool for a lab to have access to these utilities without having to pop a cd/usb in. Convenience more than anything… there are a lot of antivirus utilities, firmware updates for various devices, password reset tools, acronis is built into the mix as well as norton ghost. … also Mini Linux and Mini XP are kinda cool to use.

    Really, why do you need 4,000 different utilities on a swiss army knife? …because the more "stuff" you have on it the better :)

  15. Aviad

    well… lets just say that i was thinking like you when i made the movie at the beginning of the article… since then I’ve changed my mind, because i think it is better to have the “one” goto utility then 10K small ones that don’t always work.

    so i think we’ll agree to disagree on that point.
    with that said, i’ll try to swing a word on how to do this in a future article.

    as for Acronis, there is a way to boot it directly… that is why we created a sub-menu for it…. that article is coming.

  16. Abdul

    Ok what am i missing here. I installed fog, and then your tute says to:

    “sudo cp /tftpboot/pxelinux.cfg/default /tftpboot/howtogeek/menus/fog.cfg”

    aka copy a file that doesn’t exist to a location i just created. Im sure its a pebkac error but im just not seeing it.

  17. Aviad

    @Abdul
    i don’t know why you don’t see the “default” file in the “pxelinux.cfg” directory, as the FOG installer puts it there.

    the command above “sudo mkdir -p /tftpboot/howtogeek/menus” creates the directory your copying to, and the “fog.cfg” is the new name of the file as to distinguish it from the original file name in the menus configuration files (for readability, not usability).

    my only guess is that you’ve missed a step…
    sorry i could be of more help.

  18. Maurice

    Is there a way to pull a ghost image called xxx.gho from a fog server using a ghost.exe file. How can I go about setting this up.

Aviad Raviv, is an agile IT implementer that has reached the level of IT Bankai :)

  • Published 04/14/11

RECOMMENDED POSTS