This guide explains how to configure a Windows Server 2008 machine to push out a static Ubuntu image that can be picked up by diskless terminals, so that you can have any number of machines running a fully-functional instance of Ubuntu without having a hard drive, as long as they are capable of PXE booting.
This is a guest article by Alexander Karnitis and Cody Dull, two readers that work for Hyndman Inc and had to figure out how to accomplish this task for their job. They were kind enough to write up the process for everybody else.
Why do I want this?
PXE booting makes it both easier and cheaper to manage a network, and the ability to serve custom Ubuntu images from a Windows Server can help make your environment more robust. You can use these images to give users the same basic environment to work from, have an easily-restorable system (just power-cycle the machine), perform diagnostics on a malfunctioning machine, and more. Also, by serving these images from a Windows Server, it would be possible to serve both Windows and Ubuntu images from a single location, though that is beyond the scope of this guide.
What do I need?
Windows Server 2008 Machine running Windows Deployment Services (WDS) Client capable of PXE booting Windows Server Machine running DHCP An NFS server (this guide assumes that the NFS server is the same as the WDS server, but that doesn’t have to be the case)
Creating the WDS Server
Installing Windows Deployment Services on a windows server isn’t terribly difficult, and Microsoft has great guides to walk you through the installation process (2008 and 2008 R2 here), so this guide won’t cover how to do that, but know that you want both the Deployment Server and Transport server. Also note that when configuring the role, you’ll want to check the box “Respond to all (known and unknown) client computers” during the setup, unless the computers that you are booting are already known to Active Directory. This is because the server refers to Active Directory as the authority on what are known and unknown devices.
The guide should be followed up until the “Steps for adding images” section, as we will be adding our images through pxelinux, not WDS.
Installing pxelinux
Download and extract a copy of syslinux (one possible source is here). From here, we’re going to be copying the files that pxelinux needs to run over into the WDS directory. Specifically, for pxelinux 5.01, that means that we’ll be copying over the following files:
· Core\pxelinux.0
· Com32\menu\vesamenu.c32
· Com32\lib\libcom32.c32
· Com32\elflink\ldlinux.c32
· Com32\libutil\libutil.c32
· Com32\chain\chain.c32
These files will be copied over into the desired architecture directory (\boot\x64, \boot\x86, or both). After copying the files, the architecture directory should look similar to this (there are slight differences between x86 and x64, but not for pxelinux).
Here, the architecture directories are located under the directory that was specified to hold the WDS files when customizing the WDS role.
At this point, we will have no more use for any other syslinux files, so the syslinux directory can safely be removed.
Configuring PXElinux
The pxelinux config file can be heavily customized to provide a unique boot menu for different computers based on a hardware type and hardware address, or based on an IP address or range of IP addresses (more on that here), and can provide quite a few boot methods and a fairly robust menu system (more on that here). For the purposes of this basic guide, however, we’ll stick to the default config file and explain the basic menu that can be used to pxeboot a liveCD. To start with, the config files need to be located in a sub-folder named “pxelinux.cfg”, so create that folder in the same directory that you copied over the pxelinux files to. We also created an “Images” folder alongside the pxelinux.cfg folder to store all of our linux images. At this point, the architecture folder should look something like this:
Now, in the pxelinux.cfg folder, create a file called “default” without a file extension.
Open the file in a text editor like notepad and type the following:
Note that this setup is assuming that the image is stored under Images/UbuntuLIVE from the architecture directory.
Timeout in units of 1/10 s
TIMEOUT 30 #3 second timeout. 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 Netboot Menu
#-A sample liveCD boot
LABEL
kernel Images/UbuntuLIVE/casper/vmlinuz #location of the kernel
append boot=casper netboot=nfs nfsroot=
For more information on what this is doing, you can look at:
https://www. howtogeek. com/61263/how-to-network-boot-pxe-the-ubuntu-livecd/
Creating an NFS share
Creating an NFS share is pretty simple on Windows server as well, and can be done by following the steps here. There are a few things to note with regards to Permissions, however.
First, NTFS permissions on the share folder are going to have to be changed, as the Everyone group will need to have Read and Execute permissions.
Make sure that the share created is an NFS share, not an SMB share.
Also, all machines will need to have anonymous access, and the Everyone NTFS permissions will need to be applied to anonymous users.
Once everything is set up, it might still take a while for all of the settings to propagate through the network, but once they do it should be possible to start serving LiveCD’s from your Windows Server box! To test the server, you can share a simple LiveCD taken from Ubuntu’s website. However, it is also possible to serve up a customized LiveCD. If you are planning to do some basic configuration to the LiveCD, you can follow the article:
https://www. howtogeek. com/109736/how-to-create-a-custom-ubuntu-live-cd-or-usb/
However, if you want to do some more intense customization like tweaking Unity, which can’t be done well using the above method, or if you want to take a simple machine and serve up identical copies of it, another fairly simple method that will allow you to make an image that can be served is as follows:
Creating and Customizing Your Ubuntu Live CD
Creating a new custom image is easy. Download and install a virtual machine player if you don’t already have one. The steps in this guide are for Oracle VM VirtualBox. https://www.virtualbox.org/wiki/Downloads
Create a new virtual machine, select Linux as the Type and Ubuntu or Ubuntu(64 bit) as the Version, depending on your preference, click Next.
Select the amount of memory to be allocated, at least 1024 MB is recommended, click Next.
Choose to create a new virtual hard drive now of type VDI and make it dynamically allocated.
Finally, set the size of the virtual hard drive. 4 GB is the minimum, but 6-8 GB is recommended.
Download Ubuntu 12.04 LTS Live CD from Ubuntu’s website. Make sure you select the same version you selected in step 2. http://www.ubuntu.com/download/desktop
Go to the settings of the VM you just created. Under Storage, click the single disk under Controller: IDE. On the right of the screen under Attributes, click the disk with an arrow next to the field CD/DVD Drive. Click Choose a virtual file. Navigate to where you downloaded the Live CD and select it.
You can now start the VM and install Ubuntu 12.04.
Once installed, make all desired changes. Some of the changes that we did include:
If this is going to be used by anyone except system admins, create a User account as a standard user, set it to log in automatically with no password required.
Remove any unnecessary programs depending on the purpose of the final image.
Some larger programs that can be removed if not needed are: Firefox, LibreOffice, Gwibber, Thunderbird, empathy, and any games.
You may do this are by using the aptitude purge
Make the file executable and add it to Startup Applications. Additional commands can be run at start time using this method. Keep in mind that this will only work if all of your machines label their displays similarly. If you have multiple models, a more sophisticated approach may be necessary. Unlock any remaining icons from the launcher that don’t need to be there, and add any you wish to add.
After making all customizations, you must install Remastersys. Despite some posts you may find on forums, Remastersys is still up and running.
Get Synaptic Package Manager by either entering sudo apt-get install synaptic at the terminal or get it from Ubuntu Software Center. Run the following command in terminal to download the repository gpg key: sudo wget –O –http://www. remastersys. com/Ubuntu/remastersys. gpg. key | apt-key add – Open the file /etc/apt/sources. list in a text editor with sudo rights, append the following line, changing precise to your version if necessary:deb http://www. remastersys. com/ubuntu precise main Open Synaptic and search for Remastersys. Mark the packages Remastersys and Remastersys-gui to be installed, press apply to install. Open Remastersys-gui and select Backup.
You now have a custom live cd. The next step is to transfer it over to your server. If you have followed the Configuring Windows Server 2008 to PXE boot Ubuntu guide, here are the steps to deploy the image.
Execute the following command in terminal to make the Ubuntu VM an NFS client.
sudo apt-get install rpcbind nfs-common Create a directory to mount the NFS share on.
sudo mkdir /NFS You must now mount an NFS share with write permissions granted.
It is recommended that you create an additional share for the purpose of transferring files from client to server as you share, for the pxe boot file system won’t typically have this permission.
sudo mount
To change the custom image, go back to the VM and repeat the steps from above starting at the step where you chose the disk image to boot from. This time, instead of using the default cd downloaded from Ubuntu, you will use the backup iso file you exported.