PXE Boot |
created:17 Aug 2008 @ 02:00 am edited:02 Dec 2009 @ 01:08 pm |
What the...
Basically PXE stands for Pre-boot eXecution Environment. Its a tiny linux environment stored on most network cards that you can use to boot a computer from!It is really useful for debugging dead systems, diagnostics, or those times that you need a floppy and either your fancy new computer hasnt got one, you can't find one or all the ones you can find DON'T ******* WORK!!!
What is needed?
You'll need the following to get things working:- PXE compatiable network card
- DHCP server
- TFTP (Trivial File Transfer Protocol) server
- Another normal computer with a network card (or a server)
- Either:
- Crossover Cable
- Hub / Switch and 2 cables
1. PXE compatiable network card
These are easy to come by. Most network cards today have the ROM, and if you have onboard LAN or a laptop, then it will almost definately have it.2. DHCP server
Well now, the DHCP server in your All-in-1 router / wireless access point / firewally thingy will almost definately not help us here. Thats mainly why I suggested you get your hands on a crossover cable or a hub (See below for more info). If however, you are running a larger network with a proper DHCP server (Windows Server 2k3, Linux etc...) then that will help out.Basically you need to setup a couple variables. The bootfile and the bootserver. More on that later.
3. TFTP Server
Once the computer has got its IP address from the DHCP server, it will try to connect to the bootserver, and then retrieve the bootfile. The protocol, I hope you have guessed is TFTP, hence the TFTP server... The bootfile is basically a little linux kernel '4. Another normal computer with a network card (or a server)
This required to act as the DHCP and TFTP server. It will hold all the boot files etc...5. Crossover cable / switch WARNING: In my experience, crossover cables are like gold dust. If you have one, mark it and OWN IT!
One or other of these are required. They allow the client to connect to the server.If you are using a crossover cable, you plug the computers directly into each other. Crossover cables are different to noraml cables, as shown below:
As you can see, there is a subtle difference in the wiring of a crossover cable and a straight cable.
If you are on the otherhand using a hub or switch, then you need 2 cables (most switches are auto sensing, meaning that you can use crossover or straight cables). One cable from the server to the switch, and one from the switch to the client.
How? How? HOW!?
This tutorial is for doing this trick with windows, so im afraid all linux fans look away now...TFTPD32
A quick note of caution: if you are already running a DHCP server on the network, you may well be unable to get this working, as the client computer might be using the information provided by that other server!We will be using a program called tftpd32. Its a great little app that has both a DHCP and TFTP server built in, allowing you to just fire it up and go.
You can download it from their site here
You need to follow these steps to get tftpd32 up and running:
- Hopefully common sence, but download :)
- Put the files in a folder, and create a folder next to them called "TFTP-Root"
- Start up tftpd32.exe
- Click settings
- Set the base directory to "./TFTP-Root"
- In the global settings, select only TFTP Server, and DHCP Server
- In advanced TFTP options, tick the "PXE Compatibility" box, some others will change, thats ok
- Press OK and restart tftpd32.exe
- Goto the DHCP Server tab and set the following:
- IP Pool Starting Address: 10.0.0.1
- Size of pool: 32
- Boot File: ./pxelinux.0
- If you are going to be needing a gateway, and actually have one setup, then enter its IP
- Mask: 255.255.255.0
- Press Save
- All done!
PXE Linux
To get the computer to boot, you need to provide it with something very crucial. The linux kernel.First things first. Download it from here
pxelinux.0 is included in the syslinux package. Most of you are hopefully familliar with Zip files. If you have something like 7-zip then you will be able to save time by downloading the *.tar.bz2 file as it's smaller.
Once you have that, dive into the archive, and grab the following files and put them in your TFTP-Root folder.
- pxelinux.0
- memdisk/memdisk
PXE Linux - Config
In your TFTP-Root folder, create a folder called "pxelinux.cfg".Inside there make a file called "default".
In there we put the following:
TIMEOUT 100 DEFAULT 0 PROMPT 1 VGA 792 DISPLAY msgs/boot.msg LABEL 0 localboot 0 LABEL 1 KERNEL memdisk APPEND initrd=images/memtest.imgThis tells PXE Linux many things.
Firstly, to display "msgs/boot.msg" at startup:
DISPLAY msgs/boot.msgThen, if the user leaves the computer for 10 seconds, to continue to the next boot device:
TIMEOUT 100 DEFAULT 0 ... LABEL 0 localboot 0And finally, if we enter 1 and press return, load Memtest86 :
LABEL 1 KERNEL memdisk APPEND initrd=images/memtest.imgMemtest86 is a great little tool for finding dodgy RAM. The site is: www.memtest.org. Unfortunately they provide the floppy image as a .bin file. This does not work if we try to boot from it (I've tried). I have written it to a floppy and left the image here for you.
PXE Linux - Message File
You now need to make the mentioned boot.msg file. In your TFTP-Root folder, create a folder called "msgs", and in it make a file called boot.msg.The screen is 25 lines high. Knowing this, allows us to put the prompt at the bottom of the screen. In a similar way, it is also useful for you to know that the screen is 81 characters wide. Type the following into the file
Welcome to my PXE Boot menu! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please select an action from below: 0. Next boot device (default) 1. Memtest86I said before that the screen is 81 characters wide, but be careful. The new line character takes up a slot, so if you have 81 '-'s then your line will continue, and push the rest down 1 line. Simple work around:
Welcome to my PXE Boot menu! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Please select an action: 0. Next boot device (default) 1. Memtest86Will display the following, with the tildes touching both edges of the screen.
Welcome to my PXE Boot menu! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please select an action: 0. Next boot device (default) 1. Memtest86Dont forget, the message file contains ONLY the message, no config. If you put "2. Boot xyz" it wont work.
PXE Linux - The Disk Images
PXE Linux can boot zipped floppy images, ISOs and lots more.We need a folder to store the images, so in your TFTP-Root folder make the folder "images", and in there for the moment put the memtext image I'm hosting for you (here).
Incase you are interested, I found bit of software called VFD. It really is great, floppy drives that write just like that, and don't go... Mmmmm... Computer says no.... All my praises to the author. This is what I used to make the Memtest image, and dont forget. You can put the .img files into a zip file to keep the file size down (faster boot), just dont forget to change the filename.
All Done
That should all now be finished. If you wander over to your other computer, and make it boot from the network, see what happens :D.More on the Message Files...
If you are sat there thinking... "What about color?" then your in luck :)Color is an easy one. Color takes effect from the special character, and it continues until you change it.
You need to be using something other than notepad for this. I suggest Notepad++
To make the special character put the cursor where you want it, hold ALT, type '015', and release ALT. If you are using notepad++ a SI surrounded in black will appear if you have done it correctly. The next 2 hexidecimal (0-9, A-F) characters are crucial. The first is the background color, the second is the foreground color. Below is a table with the relevant colors for the Hex.
| Hex | As BG | As FG |
| 0 | Black | Black |
| 1 | Blue | Dark Blue |
| 2 | Green | Dark Green |
| 3 | Aqua | Dark Aqua |
| 4 | Red | Dark Red |
| 5 | Purple | Dark Purple |
| 6 | Orange | Orange |
| 7 | Grey | Light Grey |
| 8 | Black * | Dark Grey |
| 9 | Blue * | Light Blue |
| A | Green * | Light Green |
| B | Aqua * | Light Aqua |
| C | Red * | Light Red |
| D | Purple * | Pink |
| E | Orange * | Yellow |
| F | Grey * | White |
* These values, will make the foreground blink between the background color and the foreground color, allowing you to make text or ASCII art flash!
More on the config file
Of course there is more you can do with the config file. Like boot a linux disk, keep the network card drivers loaded. But I'm going to leave these features up to you and your research for the moment.Downloads
- My TFTP-Root folder (8.65 MB)
- memtest.img
