Simple netboot setup

In order to do some performance comparisons of qemu with various host parameters, I will be wanting to do many installs on the same hardware. That, of course, begs for automation. Automated install perhaps should be done with orchestra, and I’ll look into that soon, but as I hadn’t implemented anything like this myself in awhile, I wanted to make sure I knew how. Here, for my own future reference, is exactly how I did it.

There is nothing new or groundbreaking here. It just records a working setup for future reference.

First, the ‘lab’. I’m sitting away from my router. There are two laptops involved. A is the big one which I use for daily work. It runs a mostly stock desktop install with unity. B is the victim. A is on my wireless network through wlan0. B is connected with a crossover cable to A. Network manager doesn’t seem happy about this, so on A I run a script which does:

	stop network-manager
	iwconfig wlan0 essid myname enc mykey
	iwconfig wlan0 ap apmacaddr
	iwconfig wlan0 freq 2.417
	ifconfig wlan0 up
	dhclient wlan0
	ifconfig eth0 netmask up
	/etc/init.d/dnsmasq restart

/etc/dnsmasq.conf has


and /opt/bin/share-eth0-wlan0 has:

	# Share wlan over eth0
	echo 1 > /proc/sys/net/ipv4/ip_forward
	iptables -A FORWARD -o wlan0 -i eth0 -s -m conntrack --ctstate NEW -j ACCEPT
	iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
	iptables -A POSTROUTING -t nat -j MASQUERADE 
	/etc/init.d/dnsmasq start

‘biglap’ is another name for A.

Packages installed on A include: dnsmasq, nfs-kernel-server, tftpd-hpa, syslinux-common, apt-cacher-ng, and etherwake. When I do ‘sudo etherwake macaddr-of-B’ on A, B wakes up and starts pxeboot. It talks to dnsmasq on A, which tells B to pxeboot from biglap.

The install images are set up under /var/lib/tftboot as follows. First, /var/lib/tftboot/pxelinux.cfg/ has a file ‘default’ which contains:

# Default boot option to use
DEFAULT menu.c32
# Prompt user for selection
# Menu Configuration

label linux
  kernel chain.c32
  append hd0

label precise-amd64-mini-preseed
  kernel precise-amd64-mini/linux
  append initrd=precise-amd64-mini/initrd.gz ro netboot=nfs nfsroot= boot=casper -- priority=critical locale=en_US file=/preseed-nopart.cfg

label precise-i386-mini-preseed
  kernel precise-i386-mini/linux
  append initrd=precise-i386-mini/initrd.gz ro netboot=nfs nfsroot= boot=casper -- priority=critical locale=en_US file=/preseed-nopart.cfg

label oneiric-i386-mini-preseed
  kernel oneiric-i386-mini/linux
  append initrd=oneiric-i386-mini/initrd.gz ro netboot=nfs nfsroot= boot=casper -- priority=critical locale=en_US file=/preseed.cfg

For each install image, I grabbed the ‘mini.iso from
For instance, for precise-amd64, I did

wget -O precise-amd64-mini.iso \
mount -o loop precise-amd64-mini.iso /mnt
mkdir /var/lib/tftpboot/precise-amd64-mini
cp -a /mnt/. /var/lib/tftpboot/precise-amd64-mini/
umount /mnt

The ‘linux’ target boots from local disk. In order for this to work, I
had to copy chain.c32 from a full install iso (there must be a better
way?) into /var/lib/tftpboot.

In order to export the nfs filesystem I added the following to /etc/exports:


and did ‘sudo exportfs -a’.

I created a preseed file and copied it (called preseed-nopart.cfg) into each /var/lib/tftpboot/*-mini/ directory. Mine looks like this, obviously based on Dustin’s 🙂 :

# Ubuntu Server Quick Install
# by Dustin Kirkland 
#  * Documentation: 

d-i	hw-detect/load_firmware boolean false

# mirroring
d-i mirror/country string enter information manually
d-i mirror/http/hostname string
d-i mirror/http/directory string /

d-i	debian-installer/locale	string en_US.UTF-8
d-i	debian-installer/splash boolean false
d-i	console-setup/ask_detect	boolean false
d-i	console-setup/layoutcode	string us
d-i	console-setup/variantcode	string 
d-i	netcfg/get_nameservers	string 
d-i     netcfg/get_hostname string stack
d-i	netcfg/get_ipaddress	string 
d-i	netcfg/get_netmask	string
d-i	netcfg/get_gateway	string 
d-i	netcfg/confirm_static	boolean true
d-i     time/zone string America/Chicago
d-i 	clock-setup/utc boolean true
d-i	clock-setup/ntp	boolean true
d-i	clock-setup/ntp-server	string
d-i	base-installer/kernel/image	string linux-server
d-i	passwd/root-login	boolean false
d-i	passwd/make-user	boolean true
d-i	passwd/user-fullname string Ubuntu
d-i	passwd/username string ubuntu
d-i	passwd/user-password password ubuntu
d-i	passwd/user-password-again password ubuntu
d-i     user-setup/allow-password-weak boolean true
d-i	user-setup/encrypt-home	boolean false
d-i	apt-setup/services-select	multiselect security
d-i	apt-setup/security_host	string
d-i	apt-setup/security_path	string /ubuntu
d-i	debian-installer/allow_unauthenticated	string false
d-i	pkgsel/upgrade	select safe-upgrade
d-i	pkgsel/language-packs	multiselect 
d-i	pkgsel/update-policy	select none
d-i	pkgsel/updatedb	boolean true
d-i	grub-installer/skip	boolean false
d-i	lilo-installer/skip	boolean false
d-i	grub-installer/only_debian	boolean true
d-i	grub-installer/with_other_os	boolean true
d-i	finish-install/keep-consoles	boolean false
d-i	finish-install/reboot_in_progress	note 
d-i	cdrom-detect/eject	boolean true
d-i	debian-installer/exit/halt	boolean false
d-i	debian-installer/exit/poweroff	boolean false
d-i	pkgsel/include string byobu vim openssh-server
byobu	byobu/launch-by-default boolean true
d-i debian-installer/exit/poweroff boolean true

The partitioning steps were taken out of there because I wanted to keep my partitioning on B for the moment, but I’ll be adding it again soon to make the whole thing fully automated.

Note that I set, in other words laptop A, as archive mirror. I installed apt-cacher-ng on A, which also serves as mirror for all of my schroots, containers, VMs, and for that matter my other laptops, to save a bit of bandwidth from the house.

Now, with all that, I’m able to do repeated automated installs without any changes to house or lab network. For that matter, I’ll be able to do this from a coffee shop or a car tethered over 3G. You know, if I wanted to.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s