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.
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
- 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*
- 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:
MENU TITLE FOG 0.32 + HowToGeek's enhancements
MENU INCLUDE /pxelinux.cfg/master.cfg
menu color title 1;36;44 #ff8c00 #00000000 std
MENU LABEL Manual FOG
LABEL Utils MENU
MENU LABEL Linux stuff
MENU LABEL Boot from hard disk
TEXT HELP Boot from the local hard drive. If you are unsure, select this option.
PROMPT 0 TIMEOUT 300
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:
MENU LABEL ..
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 ..
Lets set the stage for additional sub-menus, which will be covered in future guides:
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 :)
Go FOG yourself