|
|
楼主 |
发表于 2012-10-15 01:08:08
|
显示全部楼层
- Now we just need to restart the inetd and tftp services with:$ sudo service inetutils-inetd restart$ sudo service tftpd-hpa restart
- So that’s the TFTP daemon ready to serve files to a PXE agent. Now we need to create the directory where we will be putting all our PXE goodness into:$ sudo mkdir -p /srv/tftp
- We now need to copy some files off the Ubuntu Alternate Install CD that make up the PXE boot files and the menu config files. I will use the 32-bit disc in this example, though the files are the same on the 64-bit disc for this step. Insert the CD or mount the downloaded Ubuntu Alternate Install CD ISO. In this case I will assume you have a physical CD mounted at /media/cdrom.$ sudo cp /media/cdrom/install/netboot/pxelinux.0 /srv/tftp$ sudo mkdir -p /srv/tftp/ubuntu-installer/i386$ cd /media/cdrom/install/netboot/ubuntu-installer/i386$ sudo cp -R boot-screens /srv/tftp/ubuntu-installer/i386$ sudo cp initrd.gz linux /srv/tftp/ubuntu-installer/i386(if you’re using the 64-bit CD, substitute all instances of “i386″ above with “amd64″ instead.)
.
- Now we need to setup the initial PXE boot process:$ sudo mkdir /srv/tftp/pxelinux.cfg$ sudo nano /srv/tftp/pxelinux.cfg/default
- You will now be looking at a blank text editor. In this, type the following:include mybootmenu.cfgdefault ubuntu-installer/i386/boot-screens/vesamenu.c32prompt 0timeout 100The timeout 100 line will provide a 10 second countdown before it automatically chooses the default PXE menu option when you boot into it. If you do not want a timeout, then change this to timeout 0 instead.
- Press CTRL+X and then “Y” and then Enter to save your changes.
. - Now let’s setup our actual boot menu that we’ll be choosing options from:$ sudo nano /srv/tftp/mybootmenu.cfg
- Again you’ll be looking at a blank text editor. Type (or copy & paste) in the following. Indenting text is not important, but makes it more readable:menu hshift 13menu width 49menu margin 8menu title My Customised Network Boot Menuinclude ubuntu-installer/i386/boot-screens/stdmenu.cfgmenu begin Cool options default myfirstoption label myfirstoption menu label This is a menu item label mysecondoption menu label This is another optionmenu end
- Press CTRL+X, then press “Y” and then Enter to save your changes.
. - Finally, we need to change the permissions of all files concerned because TFTP will not read any files unless they are set to full access:$ sudo chmod 777 -R /srv
- That’s PXE server side ready to go. Now we need to tell PXE clients where to find the PXE boot server. If you are NOT using Ubuntu as your DHCP server, then skip to step 23, otherwise do the following:
$ sudo nano /etc/dhcp3/dhcpd.conf - This opens up the DHCP config file into your text editor. Assuming your PXE server is at 192.168.0.10, scroll right to the very bottom of this file and add the following:next-server 192.168.0.10;filename "pxelinux.0";(note the semi-colon on the end)
.
- Press CTRL+X, then “Y” and then Enter to save your changes.
. - Restart the DHCP daemon with:
$ sudo service dhcp3-server restart - If you’re using a non-Ubuntu DHCP server, then look for any “network boot” options and specify the PXE boot server’s IP address and path to the pxelinux.0 file there. For example, in Smoothwall, you would go to Services->DHCP and then check the “Network boot enabled” checkbox, then specify “192.168.0.10″ (to suit our tutorial) into the “Boot server” box and “pxelinux.0″ in the “Boot filename” box and “/srv/tftp” in the “Root path” box.

. - We should now be ready to try out our PXE boot server! On your test workstation or VM, enable booting off the network (in the case of PXE booting a Virtualbox VM, you must ensure that the network adapter is set to “bridged mode” instead of “NAT”) and fire away. You should first see your PC launch its PXE agent, looking for a DHCP server to tell it where the PXE server is:
 - If your PXE server is working, within a few seconds you will see your boot menu!
.
…and if you hit Enter on “cool options” you will now see a sub-menu showing your two options that we created.
. - Well this is all well and good, but the menu currently doesn’t actually DO anything other than show us a bunch of options. How about we provide something, say the Memory Test application from the Ubuntu Alternate Install CD? Plus we’ll add an option to boot from the first HDD in your system. If your CD is still mounted on the server, then go back into the terminal you’ve been working in and copy over the MemTest app as follows:$ sudo cp /media/cdrom/install/mt86plus /srv/tftp
- Now let’s add a menu entry for it:$ sudo nano /srv/tftp/mybootmenu.cfg
- Modify the file so that it now looks like the following (add just the bolded lines):menu hshift 13menu width 49menu margin 8menu title My Customised Network Boot Menuinclude ubuntu-installer/i386/boot-screens/stdmenu.cfglabel Boot from the first HDD localboot 0label Memory Tester kernel mt86plusmenu begin Cool options default myfirstoption label myfirstoption menu label This is a menu item label mysecondoption menu label This is another optionmenu end
- Save your changes and exit.
. - Ensure the permissions of everything, including our newly copied files, have the correct permissions for TFTP to work:$ sudo chmod 777 -R /srv
- Reboot your test PC via PXE and this time you will see your menu sports the new menu options at the top (you could have equally placed them at the bottom too):
 - Choosing “Memory Tester” from the menu will launch the MemTest app straight away, just like off the CD. But by now you are probably wondering “Aren’t we building off Ubuntu 10.04? Why does the menu have the old logo on it? Can we change it?” Sure, we can!
. - The Ubuntu 10.04 installer CD has got the new Ubuntu logo, but for some reason it’s only saved as a PCX file which won’t work for the PXE boot menu. We can fix this by simply re-saving the PCX file as a PNG file. To start with, get a copy of the splash.pcx file from the /isolinux directory on the Ubuntu CD. This is the new Ubuntu logo that you normally see on the CD’s boot menu.
. - Load this file into an image editor such as The GIMP and re-save it as a PNG file, eg: splash.png (of course there’s nothing stopping you from creating your own graphic either – just make sure it’s no greater than 640×480 in size and indexed down to 16 colours).
.
- Copy the re-saved image file into /srv/tftp/ubuntu-installer/i386/boot-screens and overwrite the original splash.png file.
. - Ensure that the permissions of the newly added file is set correctly again with:$ sudo chmod 777 -R /srv
- And when you reboot your PXE workstation again, your menu will now look like:

And there you have it. A working PXE server with menu!
I will document further uses of the PXE boot facility in future articles, including how to boot the Live CD environment without the CD or a USB key, setup the ability to use your local Ubuntu mirror as an installation source for new installs, how to launch tools like Clonezilla and also how to setup a diskless boot system that uses PXE to do a normal Ubuntu desktop boot directly off the network without a local hard-drive.
Stay tuned!
Posted on Sunday, May 30, 2010 in Tutorials
|
|