Technical HOW-TO: Installing Linux (Edubuntu) using PXE Boot and Windows 7 as a server
Technical Stuff (HOW-TO): Using Windows 7 as a PXE server and installing a ‘remastered’ Ubuntu CD over the network
I’ve spent a while over the last couple of weeks researching and attempting to implement a Windows-based solution for installing Ubuntu on remote network clients. Previously, I’ve only used it to populate Windows clients. It has been a frustrating experience to say the least, not least of which the reason for the problem lies with Linux itself. Of course though, I would say that as I have always been a ‘Windows person’. That said, I do not wish to denigrate or unduly blame Linux for of course the counter-argument would always be that I was not sufficiently skilled in Linux at the time I did this to overcome the problems I encounted. And that is probably the case. However, the source of my frustration if you will pardon the poor pun is that I don’t ever feel one should have to modify the source and recompile binaries (and the kernel for that matter) to do something which I would otherwise consider to be ‘readily working’. Of course, that is where others will doubtless disagree with me. All that laid bare, of course, why not just build a linux-based server which is both free and probably less frustrating. Well… I will do that next, but there will always be those who prefer Windows, and perhaps to fit in with a corporate network, Windows architecture may be the preferred option. So this is for those folks who need or have been mandated the use of Windows. Don’t fret – I shall not ignore the full and most likely proper linux solution!
So before I start with the solution to the problem that I have used, let me firstly state a few things. Firstly, my solution is not FREE as it uses paid-for applications free to try, but must be purchased in parts – so it is not a ‘easy deploy linux appliance’. I list the apps used and their links at the bottom of this mail. Secondly, let me say that you CAN do this for FREE if you go down the whole linux route by building a linux ‘server’ and free-to-get apps or apt-get modules (either linux modules themselves available through the normal repositories, or more all-in-one type apps). Thirdly, I wanted to install in one step not a bare-naked version of Ubuntu but an up-to-date version - which is not that easy to do either. I wanted to do this in one-step like a Windows ‘slipstreamed’ install, not install the bare OS, then get updates from an Ubuntu mirror, then install them which takes quite a bit of time. Fourthly, and hopefully last, the frustration encountered with linux is that there are many many distributions (e.g. Debian/Ubuntu/Edubuntu – which is the ‘tree’ from which I am plucking the fruit) and they all differ in some ways, sometimes subtle, sometimes fundamental. For example, SUSE supports at the kernel level the ability to load the network drivers and then ‘get’ the installation files from an HTTP source, be that internal to your network or external. As it is so easy to set up an HTTP virtual directory to serve these files, setup is relatively easy. With Ubuntu, at least, Edubuntu 10, it only supports NFS, which of course is only natively supported on linux. It makes using Windows that much harder. Some distro’s even support FTP or SMB within the kernel to load the install set. If your chosen distribution DOES work with one of these other protocols your solution might be easier than dealing with NFS alone.
So what are the requirements (this might help you decide whether or not this might also help you if it matches your needs?)
1. Lightweight and portable. I work for a charity that does not have recourse to new recently captialised equipment, storage arrays and expensive servers.
2. Install the Edubuntu operating system onto old (>6yrs old) PC hardware over the network quickly. We benchmarked an install from DVD-ROM (those old machines that actually had a DVD) and the subsequent updates at well over three hours start to finish. We wanted and believed it could be done in less than 1 hour. It can be done in less than 25 mins!
3. A server that held the images centrall that could be easily replaced or reconstructed to minimise support effort. We don’t have redundancy or 24-hr availability so any problems need to be rectified quickly and easily to get back up and running.
4. Does not require significant in-depth linux command line skills to achieve. Should make the use of readily-available GUI apps wherever possible to minimise skills needed to operate/administer.
What does my solution look like?
It’s a windows client with a static IP address, using two apps, SERVA32/64 and an NFS server, with some aid of Deamon Tools Lite (although you can do without that). I used Allegro for NFS, but HANEWIN is popular, and there are also a few free variants out on the net, which I have not tried. We also need PXELinux which gives any client the ability to use a slim linux system to provide a menu and the ability to boot-strap both Linux kernels and Windows (e.g. use Windows 2003/2008 server’s WDS). Finally, we also need Daemon tools Lite (or another ISO-mounting utility.)
What do I need? (see also Appendix1)
To test or build this, you can use several things;
1. Virtualbox or VMware workstation/server
2. An EVAL CD for Windows 7 Enterprise Ed 64-bit
3. The apps mentioned above (and listed below)
4. The chosen ISO for your Ubuntu distribution.
5. PXELinux (see the download link at the bottom of this mail)
6. The remastersys app for Linux (Debian/Ubuntu supported, unknown on other distro’s)
How do I set it up?
It’s up to you whether or not you want to do the virtualisation step or proceed straight to installing on your chosen hardware, but you need to:
STAGE1: Get the PXE ‘server’ ready
1. Install Windows 7 client and configure with a static IP
2. Copy the SERVA32/64 application over to the client
3. Copy the NFS server installer over to the client (supplied instructions are for Allegra)
4. Copy the DAEMON TOOLS install to the client
5. Prepare a folder structure for the files required to remote-boot and install other OS. Create C:\RemotePXE and three sub-folders, \boot and \images and \serva32 or (\serva64)
6. Put the serva32 binaries in the serva32 folder, and create a shortcut to SERVA32.exe on the desktop and/or the startup folder to launch it automatically on startup.
How does it work?
1. The PC boots and initialises the NIC, using PXE firmware (of course you need this to make it work! Pretty much all network adapters since 2001 are capable of PXE boot, but you should check first ..)
2. The NIC with PXE BIOS extensions makes a call to the network for a DHCP offer
3. A DHCP server replies with an IP address and tells the client which server can offer the client PXE boot passing it the IP address and the filename of the boot program
4. The client contacts the PXE server using TFTP and pulls down the boot program and exexcutes it (we will be using PXELinux for this)
5. The client displays the MENU as listed in the PXELINUX.CFG\DEFAULT file
6. The client can select an OS to boot/install from the menu
7. On selection, the chosen program is given control after being TFTP’d to the client and executed. This is where PXELinux ends and your chosen OS takes over. For Linux installers, depending on your distro, it will call first the KERNEL (i.e. vmlinuz or linux) then the initird (Initial ramdisk archive which is typically GZipped)
8. For linux, the APPEND command in the DEFAULT file is used to pass arguments to the linux kernel to further install or configure the OS as required. We’ll need to use this to ‘tell’ the kernel where to get the installation set from. Again, depending on your distro, some support different arguments and natively support different protocols to do this. My instructions may only work with Ubuntu/Edubuntu 10.x but of course experimentation and research are king!
9. Depending on your distro, the install set is read (as if the PC were simply accessing the DVD in the drive) and then the installer is run. It will then display whatever comes next – for some distros this is an ASCII menu to choose options. For the Edubuntu Live CD it is the desktop, with an icon to start the installation.
10. It is up to you whether or not you then choose menu options to install, or you may wish to use something like PRESEEDING (for Ubuntu) or Kickstart (for RedHat/CentOS/SUSE). I won’t go into that here, however, I’ll do that in a different and follow-up article if I may… as well as look at some of the things we can do with MEMDISK to launch ISO images on-the fly, and further menu options for the PXELINUX.CFG\DEFAULT file…
STAGE2: Configure the server
1. You should now have a Windows 7 Ent Ed machine (I used 64-bit but either should be fine) with a static IP address and a folder structure under C:\RemotePXE\boot ..\images ..\SERVA32. Next install Daemon Tools using the default options (Daemon Tools Lite is FREE).
2. Now to set up the PXE boot menu. From the SYSLINUX archive, Copy the files pxelinux.0, vesamenu.c32 and chain.c32 to the boot folder. RENAME pxelinux.0 to pxelinux.com. Then create a subfolder for boot called PXELINUX.CFG
3. Copy the MENU text found below into a file under PXELINUX.CFG into a file DEFAULT. This is the file you will edit when you wish to add new distributions or test and experiment with new options. Take a backup by copying the file when you have a working system in case you need to delete a messed up one and rename the copy back to DEFAULT. Of course, edits of this can be made with just notepad.
See the images below for the directory structure and default files.
4. That’s good enough for the structure so far, let’s get SERVA32/64 ready to provide the right files over the right protocols now. Launch SERVA32/64 for the first time. Assent to the license agreement and if using the FREE (non-supporter version) you will need to wait for the ‘no thanks’ button to become live to start it. You’ll see the logs screens by protocol across the top, but for now nothing is configured, so click SETTINGS at the bottom to start. Of course, this is a very powerful, tiny footprint, lightweight app and I do encourage you to register (support) if you like it and want to keep it. I certainly shall.
a. Do you already have a DHCP server on your network? Chances are you do if you have not had to assign each of your PCs and devices (such as Ipads, Android Phones, WiFi printers and the like) IP addresses manually before they can be used. You will need to note the DHCP servers’ IP address. (Hint: In windows go the start menu, type CMD in the find pane and ENTER. Type IPCONFIG/ALL and [ENTER] and find the ‘DHCP Server’ line. In Linux, open the terminal and type IFCONFIG [ENTER].) OK, so now you need to configure SERVA to pass the correct information to your clients. On the DHCP tab, check proxyDHCP if you do have a primary DHCP server already. If you don’t – you’ll need to configure it here.
i. With existing DHCP server — check proxyDHCP, in Next Server (siaddr) leave either Automatic or enter the current static IP of the Windows PC you are using. For bootfile, enter pxelinux.com
ii. Without existing DHCP server — check DHCP server, and BIND to this address should be the current static IP of the Windows PC. Add the items in (i) above also for Next Server and bootfile. Specify the IP pool first IP address and pool size (e.g. to assign IPs in the sequence 192.168.1.191 to .200 then see the picture below). Add the subnet mask (/24 if you’re using the 192.168.x.x private subnet) and the router and dns entries. Router and dns are not required if you don’t need internet access from the clients.
Choose OK to save.
b. Now we need to specify where the files to be served to the clients to provide the menu system via PXELINUX and linux kernels are to be found. Select the TFTP tab and check TFTP Server. For BIND to this address – as per DHCP choose the static IP of the Windows PC. For TFTP root directory – use BROWSE to select C:\RemotePXE\boot\ (this is where the TFTP files are located, or in a subfolder – but this is considered ROOT). See the image for other configuration options and choose OK.
That should be all we need for now in terms of configuration. Now it’s time to test what we have so far.
c. Exit and restart SERVA32/64 and open it on the log page. Now boot one of your network PCs to be installed. Watch the screen carefully. You should see the following sequence:
i. PXE boot message looking for DHCP server (on the client)
ii. IP address received from the server. (on the client) / DHCP request/offer messages (on the server)
iii. The menu appear approximately as shown (on the client)
Choosing one of the menu items will do nothing at the moment as we haven’t put everything in place yet. If you did not see this sequence, there is a problem which you’ll need to troubleshoot. Follow the troubleshooting guide at the end of this document for assistance if you need it.
STAGE3: Make the updated Ubuntu Live DVD ISO
OK, so next we need to provide the actual guts of the system. We’ve put the framework in place to deliver it, now we need to put some flesh on the bones. So, one of our important requirements is that we want to install an up-to-date or near-as-damnit OS, not one that is two years old (i.e. 10.04) then spend two hours patching it. We can incorporate these updates by installing the OS, installing the updates, doing any further configuration we want, then ‘remastering’.
Here we go:
1. Install Edubuntu 10.04 on a chosen PC. For me, I used a VM, but a standard hardware PC will do.
2. Install the updates. In Ubuntu go to Administration > System Updates. and choose UPDATE. Let the system check the internet repositories – which takes a while – and come back to you. Choose UPDATE. Go away and make a cup of coffee or three. And watch some TV. And read a book. Then hopefully it will be done.
3. Perform any other system changes you want to make (I don’t know what this might be for you, but I made some directory mods and copied some files over to the system so we could make links to them later, including a wallpaper etc.)
4. Install remastersys. You can get that from Tony K’s site as listed below. (Instructions on how to do this are on the remastersys site – I have not included them here)
5. Use remastersys to make a ‘custom live CD’ from what you have now configured. Open terminal and enter the following commands: (Alternatively you can use the remastersys GUI if you install the package labelled -GUI.deb below)
sudo remastersys dist
this takes a bit of time, but not too long – no fault of remastersys, there’s just a lot of work to be done… The ouput will be an ISO file. We need that ISO file for the next stage of course, so copy it off to a network share or USB etc.
6. Handily, remastersys will gladly tell you where it placed the ISO and what it called it once it completes. Obviously, you’ll want to copy this elsewhere- like to your Windows server(!) as we’ll need to use this in the next stage to as the basis for our installer of more clients.
STAGE4: Adding the distribution install CD and making it accessible
Now that you’ve got the PXE basics done and made the updated custom live CD for your OS, it’s time to share it over NFS.
1. Copy the ISO file you made in stage 4 to the C:\RemotePXE\Images folder. If you like, place in it subdirectory with the name/version of the OS. (e.g. \edubuntu10_04\custom-dist.iso)
2. Install Allegro or your other choice of NFS server for Windows. If you use any other than Allegro you will need to configure this yourself.
3. Launch Allegro
4. Configure Allegro by open START\Programs and expand Allegro. One of the options allows you to configure it. Select this and it opens on the EXPORTS tab. Click NEW and give your exported share a unique name, logically one that identifies the distro (see example).
5. Open Daemon Tools Lite and Add the ISO to the catalogue (I won’t go into Daemon Tools here, it’s pretty straightforward and used almost ubiqutously). Now right click it and MOUNT it. Note the drive letter it has been mounted under, and use Windows explorer to verify that it is mounted and browsable (e.g. you’ll seefiles ubuntu, MD5sum and readme.disdefines, with 5 folders, one of which \casper contains the all-important filesystem.squashfs). If that’s ok – carry on…
6. Under PATH, use browse to select the drive letter root you mounted the DVD’s ISO on.
7. For the security part, select: Allowed Host Lists (ALL), Read/Write user lists (ROOT) and Read-only user lists (EVERYONE)
8. We don’t need to modify anything else now in fact, although I used the DEBUG tab to enable logging of first NFS protocol debugging then MOUNT. This is simply so I could see what was happening. Later I disabled NFS protocol as it simply generates too much detail. Select as you wish and then APPLY your changes.
10. Test the NFS connection if possible from another NFS-enabled operating system. For example, from another linux client try the following:
sudo mount -t nfs serveriporhostname:/nfsexportname /mnt/mountfolder
alternatively you can use sudo showmount serveriporhostname -e and it should at least show the exported folder name
11. In the PXELINUX.CFG\DEFAULT file (the PXE boot menu) we need to tell our linux distro WHERE to get the install files from. Change the line under the menu option for your distro to match that of the Windows ‘servers’ IP or Hostname and the exported foldername. The line you must change looks like:
APPEND boot=casper netboot=nfs nfsroot=192.168.1.190:/ubuntu1004 — keeppxe
You’ll need to change the nfsroot= part to match that of your server and exported folder. Now save the default file (you will need to close SERVA32/64 first if it still open), and we’re ready to test it.
12. Copy the Linux KERNEL and INITRAMDISK files to the C:\RemotePXE\boot folder. You can rename them if you like to match the distro and version if you will keep different versions here, but make it logical (I renamed Edubuntu’s vmlinuz kernel to ed1004_vmlinuz and the ramdisk to ed1004_initrd.gz to distinguish them). Then - make sure the KERNEL and APPEND lines in the DEFAULT boot menu file have the correct filenames. (You may not need this step if you did it earlier – but if you updated the ISO in STAGE3 then you should re-copy them from the new ISO)
STAGE5: Test from start to finish
OK, so now we should have the full essence, and it’s time to test it.
with SERVA running, and Allegro running, boot your text client. After the PXE BIOS runs and gets an IP address, you should see your menu. Now select the menu entry for the Linux distro you created. The kernel should now load, you’ll see “Loading edub1004_vmlinuz….” followed by “edub1004_initrd.gz……………” as they are tftp’d from the server.
Once the initrd file (ramdisk) loads, the Linux kernel should run and now have the facilites to further progress the installation. At this point you should notice that the Linux distro now asks for an IP address – and should display the IP address, mask, route etc. The next step is that once it has initialised the network it should try to mount the NFS drive – you’ll see “Trying nfsmount… (and the mount command)”.
This should happen quickly and if it worked, you should see on the servers NFS log “Add live user …” which confirms we have parsed the directory structure and we’re on our way in. Additionally, if you checked the log MOUNT option in Allegro, you will see “MNT3: xx.xx.xx.xx: MOUNT / ubuntu1004 ==> Accepted” or similar. Within a few moments you should see the client boot into the Ubuntu desktop. From there you can choose to INSTALL CUSTOM LIVE from the dekstop – and follow the wizard as normal to install to the client’s local filesystem. You’re done!
3.i No PXE message?
This means either your machine is not capable of PXE boot, or it is not enabled. Check it in the BIOS to see if your NIC is included in the boot order (before your HDD) and that PXE is enabled. If using a VM, check that again Network boot is included and enabled.
3.ii. No IP address?
If PXE starts and looks for s DHCP server, but never receives one, it means one of two things: Either SERVA is not started or not configured properly, or there is another network issue. The network issues could involve either a Firewall on the Windows machine blocking port access (make sure you add SERVA to the firewall permissions accepted list) or if using a VM system, try using the client and server both BRIDGED to the local network. I have had many problems getting host-only type networks to work. NAT by and large will never work for this.
3iii. No menu?
If you get PXE boot message, and you see on the client that it obtains a DHCP-based IP address, check the log in SERVA to see if IT (as opposed to another DHCP server) issued the address. You should see in the log a DHCPREQUEST message from MAC AA:BB:CC:DD:EE:FF (which is your client’s MAC address) and a corresponding DHCPOFFER, then DHCPACK, TFTP [serverIP] bootfile [pxelinux.com]. If you don’t see this transaction set, but you do get an IP address then you got it from another DHCP server. Either deactivate your other DHCP server, or set proxyDHCP on SERVA only. If you see this transaction list but you still get no menu check that PXELINUX.com exists in the boot folder and check your configuration settings in SERVA.
4. Menu selection ok and loads kernel but crashes out with Kernel Panic or driver issue? Lockup during the boot?
This is trickier to resolve!
I’m afraid the internet will be your best bet here as this is highly dependent on two main things:
1. Your distribution’s support within the KERNEL for the network card you are using (i.e. does it detect the card, load the right drivers and bring the network up – do you ever see ifeth0: up?) If you don’t, then it could be the cause of the issue. To get that working, you’d need to recompile the kernel with the correct drivers. I had lots of problems like this – or related to other hardware issues and the failure of the kernel to detect and initialise them, especially in a VM. That all said, if you’re using ubuntu 10.04 and a fairly new machine it should work as I outlined.
2. The Live filesystem (The ISO you made) could not be detected, which probably means the NFS mount failed. Try to check the NFS mount from another client to verify it is being shared and accessible.
APPENDIX1: The DEFAULT menu contents
# Timeout in units of 1/10 s
MENU MARGIN 10
MENU ROWS 16
MENU TABMSGROW 21
MENU TIMEOUTROW 26
MENU COLOR BORDER 30;44 #20ffffff #00000000 none
MENU COLOR SCROLLBAR 30;44 #20ffffff #00000000 none
MENU COLOR TITLE 0 #ffffffff #00000000 none
MENU COLOR SEL 30;47 #40000000 #20ffffff
MENU TITLE *Company* PXE Boot Menu — Please choose one option
MENU LABEL Edubuntu 10.04 including remastersys updates
KERNEL ed1004_vmlinuz initrd=ed1004_initrd.gz –
APPEND boot=casper netboot=nfs nfsroot=192.168.1.190:/ubuntu1004 — keeppxe
APPENDIX2: Applications and links
Windows 7 Eval ISO
PXE (SYSLINUX) files (http://www.syslinux.org/wiki/index.php/Download) – You’ll need to Extract core\pxelinux.0 com32\menu\vesamenu.c32 and com32\modules\chain.c32 from the syslinux download.
SERVA32/64 executables (http://www.vercot.com/~serva/)
Allegro NFS (http://www.nfsforwindows.com/home)
APPENDIX3: Alternative products/solutions:
a. FOG (http://www.fogproject.org/) using Linux
b. WDS (http://technet.microsoft.com/en-us/library/cc771670(v=ws.10).aspx) using Windows 2003 R2 or Windows 2008 R2 server.
c. The ‘proper’ linux solution. (https://help.ubuntu.com/community/PXEInstallServer) and (http://www.howtogeek.com/61263/how-to-network-boot-pxe-the-ubuntu-livecd/)
I also wish to thank those on Ubuntu forums (Jon L, Tony K) for their assistance in my search for a solution. Please let me know if you have any feedback or comments!