If you don’t already know, I work at a small Racine County school district in Wisconsin as the sole IT sysadmin. I started there about a year ago, and ever since I’ve been trying to figure out how to make my job easier while providing the necessary equipment to students and staff. One of the biggest things I’ve noticed is students rarely use Windows for anything other than accessing Google Apps via Chrome (and games, but that’s a story for another time). I started thinking to myself how we might be able to better utilize our existing hardware without spending a dime, and that’s when I came up with the idea to install Ubuntu on a limited number of machines.
To start off with what we need to do is get WDS to push out the syslinux derivative pxelinux — a lightweight bootloader designed to be used with PXE booting. If you’re unaware, WDS is basically the Windows installer disc (Windows PE) designed to work over the network plus some PXE-specific bootloaders. For my example I will be adding Ubuntu 13.04 with using Windows Server 2008 R2 as my WDS server.
Hint: I basically just followed the official syslinux wiki: http://www.syslinux.org/wiki/index.php/WDSLINUX
C:/RemoteInstall
on my server.Desktop/syslinux/core/pxelinux.0 to %wdsroot%/boot/<arch>
and rename it to pxelinux.com
Desktop/syslinux/com32/menu/vesamenu.c32
and Desktop/syslinux/com32/modules/chain.c32
to %wdsroot%/boot/<arch>
pxelinux.cfg
in %wdsroot%/boot/<arch>
DEFAULT vesamenu.c32
PROMPT 0
NOESCAPE 0
ALLOWOPTIONS 0
# Timeout in units of 1/10 s
TIMEOUT 300
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 PXE Boot Menu
#---
LABEL wds
MENU DEFAULT
MENU LABEL Windows Deployment Services
KERNEL pxeboot.0
#---
LABEL local
MENU LABEL Boot from Harddisk
LOCALBOOT 0
Type 0x80
#--
LABEL ubuntu-thirteen-four
menu label Ubuntu 13.04 Desktop
kernel /linux/ubuntu/13.04-desktop/casper/vmlinuz
APPEND boot=casper netboot=nfs nfsroot=<wds server ip>:/linux/ubuntu/13.04-desktop/ initrd=/linux/ubuntu/13.04-desktop/casper/initrd.lz quiet splash
pxeboot.n12
and name it pxeboot.0
linux/ubuntu/13.04-desktop
under %wdsroot%/boot/<arch>
wdsutil /set-server /bootprogram:bootx86pxelinux.com /architecture:x86
wdsutil /set-server /N12bootprogram:bootx86pxelinux.com /architecture:x86
%wdsroot%/boot/<arch>
with guest access allowed. Might want to test this before you try booting off PXE.That should be it. Usually I like the idea of restarting the WDS service and then just verifying all of my options and make sure my files are in the correct place. Now you can PXE boot your client. Hopefully instead of the normal WDS bootloader you now get a bootloader with a gray background. Choose the Ubuntu option, give it a couple minutes, and then you should see the Ubuntu live desktop!
I may end up revising this section due to the fact that right now I am using likewise-open for AD auth but it works. Grab yourself an install of Ubuntu and follow along:
<code class="EnlighterJSRAW" data-enlighter-language="shell">sudo apt-get install likewise-open openssh-server
<code class="EnlighterJSRAW" data-enlighter-language="shell">sudo domainjoin-cli join ad.example.com domainadmin
<code class="EnlighterJSRAW" data-enlighter-language="shell">sudo lwconfig AssumeDefaultDomain true
echo "greeter-hide-users=true" | sudo tee -a /etc/lightdm/lightdm.conf echo "allow-guest=false" | sudo tee -a /etc/lightdm/lightdm.conf echo "greeter-show-remote-login=false" | sudo tee -a /etc/lightdm/lightdm.conf
This was the section I had the most issues with. Documentation is thin, and usually in engineer-ese. Just follow the steps below and if you want to know anything, feel free to leave a comment.
I guess I should kick off by saying what preseed is. When you preseed you basically create a configuration file that answers questions that you are asked during the install of modern Debian Linux distros. You can do things such as specify partitioning settings, locale, keyboard layout, and packages that you may want to install along the way. You can also run scripts which we will be doing in the last section. If you want to check out what a preseed file may look like, scroll down a bit or check out the one from 12.04’s documentation.
sudo apt-get install apache2
/var/www
) make a directory named preseed
Create a new file named ubuntu.seed and type the following lines in it:
d-i mirror/country string US
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian# Install the Ubuntu desktop.
tasksel tasksel/first multiselect ubuntu-desktop
ubiquity ubiquity/keep-installed string icedtea6-plugin openoffice.org# Localization
d-i debian-installer/locale string en_US
# Keyboard
d-i keyboard-configuration/layoutcode string us
# Networking
d-i netcfg/choose_interface select auto
d-i hw-detect/load_firmware boolean true
d-i netcfg/get_hostname string
d-i apt-setup/services-select multiselect security, volatile
# Time
d-i clock-setup/utc boolean false
d-i time/zone string US/Central
d-i clock-setup/ntp boolean true
# Root Account
d-i passwd/root-password password rootpassword
d-i passwd/root-password-again password rootpassword
# Local Account
d-i passwd/user-fullname string Local Admin
d-i passwd/username string localadmin
d-i passwd/user-password password localadminpass
d-i passwd/user-password-again password localadminpass
d-i user-setup/encrypt-home boolean false
# Packages
d-i pkgsel/include string openssh-server vim likewise-open curl
# Finishing
d-i finish-install/reboot_in_progress note
d-i cdrom-detet/eject boolean false
%wdsroot%/boot/<arch>/pxelinux.cfg
? Open that up again and append the following to the bottom:
#--
LABEL ubuntu-thirteen-four-preseed
menu label Ubuntu 13.04 Desktop - Preseed
kernel /linux/ubuntu/13.04-desktop/ubuntu-installer/i386/linux
APPEND boot=casper preseed/url=http://<apache server ip>/preseed/ubuntu.seed install auto-install/enable=true netboot=nfs nfsroot=<wds server ip>:/linux/ubuntu/13.04-desktop/ initrd=/linux/ubuntu/13.04-desktop/ubuntu-installer/i386/initrd.gz
ubuntu-installer
located in the archive to %wdsroot%/boot/<arch>/linux/ubuntu/13.04-desktop/
Hopefully now if you PXE boot again you will have the option for preseeding at the bottom. Try it out on a machine and see how the install goes. If it’s all good, we’ll move onto the next part for setting up a cache to speed up the install process.
So anyone that’s installed packages before on Debian with a slow connection knows how long it can take. Multiply that by X number of machines you want to deploy and it can add up fast. Hell, even the Ubuntu installer loads tons of packages from the internet. We can cut the install time in half just by setting up a package cache.
If you’ve installed Ubuntu before and paid attention to how many packages it downloads, you probably know how much this will help. I noticed after setting up the cache I was able to eliminate around 650MB of package downloading from the internet. That’s a nice big number.
To set up the cache we will be utilizing apt-cacher-ng:
sudo apt-get install apt-cacher-ng sudo apt-get update
ubuntu.seed
file to use our cacher as a proxy. Find the following lines:
d-i mirror/country string US
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
Insert this line under that section:
d-i mirror/http/proxy string http://<cache server ip>:3142/
To test you will have to run the installer at least twice. Once for downloading the initial packages, a second time for doing an install via the cache. Time both of them too! I went from a 10 minute install on the non-cached install to less than 5 minutes on the cached install!
Okay, so far we’ve got our PXE server set up to boot Ubuntu Live and our Ubuntu preseeded installer. We’ve seen how we can join a machine to AD with working authentication. And finally we have our apt cache set up to save us precious amounts of time. The final step then is to tie everything together so when we want to install Ubuntu our steps will look like this:
Alright, it’s getting late (3:30AM) so let’s wrap this up:
d-i preseed/late_command string sed -i '/exit 0/ d' /target/etc/rc.local; echo "sh /home/sysprep.sh" >> /target/etc/rc.local; echo "exit 0" >> /target/etc/rc.local; wget -O - http://webserver.com/preseed/scripts/sysprep.sh >> /target/home/sysprep.sh
scripts
Put these lines into a file named sysprep.sh
#!/bin/sh
cd /tmp
# Cache Repo
echo "Acquire::http::Proxy "http://<apt cache ip>:3142";" | tee /etc/apt/apt.conf.d/90-apt-proxy.conf
# Google Repo
# I added this in case anyone wanted to install Google Chrome automatically.
# If you don't want this remove the next 4 lines and "google-chrome-stable" below
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list | tee /etc/apt/sources.list.d/google.list
apt-get update
# Install some packages we want
apt-get -y install google-chrome-stable vlc
# Network Interfaces
# On some machines Ubuntu will just refuse to use DHCP on our NIC. We'll change that.
rm /etc/network/interfaces
touch /etc/network/interfaces
echo "auto lo" | tee -a /etc/network/interfaces
echo "iface lo inet loopback" | tee -a /etc/network/interfaces
echo "auto eth0" | tee -a /etc/network/interfaces
echo "iface eth0 inet dhcp" | tee -a /etc/network/interfaces
# Join to AD
apt-get -y install likewise-open
domainjoin-cli join ad.example.com <domainadmin> <password>
lwconfig AssumeDefaultDomain true
# Change login screen settings
echo "greeter-hide-users=true" | tee -a /etc/lightdm/lightdm.conf
echo "allow-guest=false" | tee -a /etc/lightdm/lightdm.conf
echo "greeter-show-remote-login=false" | tee -a /etc/lightdm/lightdm.conf
sed -i '/sh /home/sysprep.sh/ d' /etc/rc.local
rm /home/sysprep.sh
shutdown -r now
I think that’s it for now. It should cover pretty much everything. I’m going to hit publish on this post, but I’ll be back around for cleaning it up a bit.