Monday, October 4, 2010

dnsmasq as tftp boot server

I upgraded my main workstation to 10.10 today. I may have missed a step where I was supposed to edit the grub2 setup. At any rate I ended up with a machine that booted to "grub rescue>".

Easy fix with a livecd. But with a machine that won't boot from a cd, what do you do?

Well my boy spinach can PXE boot. He's set to do that first in his BIOS.

Spinach is fairly modern hardware he just has a flacky IDE2 channel.

So...I used to do this with a fancy schmacy setup on a fedora box I was using for study. Today I needed quick.

I have another local machine, already running 10.10, that has a static IP on my local network. Her name is turnip. It's _my network, I'll name them what I want.

Cut to Turnip

I need the netboot image, dhcpd, tftpd. But wait! I can do all this with dynmasq.

Get the netboot image; unpack; copy to boot directory
Make sure you have dynmasq installed.

sudo apt-get -s install dnsmasq

The dash s means simulate. You decide.

I installed it.

Now my router is setup to serve up DHCP addresses from, I know that new hosts on my network will ask for the first available dhcpd assigned address. So I am going to make my dynmasq service start serving addresses at a lower number than my router.

I haven't covered getting the netboot image...sigh

The following is my current working dnsmasq.conf; just the lines that matter...

# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
# make sure this range is lower than what is provided by your router

# Override the default route supplied by dnsmasq, which assumes the
# router is the same machine as the one running dnsmasq.
# change it to the address of your router

# Set the boot filename for netboot/PXE. You will only need
# this is you want to boot machines over the network and you will need
# a TFTP server; either dnsmasq's built in TFTP server or an
# external one. (See below for how to enable the TFTP server.)

# Enable dnsmasq's built-in TFTP server

# Set the root directory for files availble via FTP.
# set this to where you put the unpacked and moved the netboot tarball

I'm missing the steps to get the netboot image.

tftp-hpa is not running

To get my netboot image I did the following...

cd /mydownloaddirectory

# example mark@flounder:~$ cd /data/downloads/isos/ubuntu/

wget -c

# remember I'm in my download directory
# unpack it here

tar xzv netboot.tar.gz

# this gives me

ls -lh /mydownloaddirectory

# example
# mark@flounder:/data/downloads/isos/ubuntu$ ls -lh
# total 1.4G
# -rw-r--r-- 1 mark mark 693M 2010-10-04 10:10 maverick-desktop-i386.iso
# drwxr-xr-x 3 mark mark 4.0K 2010-09-28 08:53 netboot
# -rw-r--r-- 1 mark mark 13M 2010-09-28 09:03 netboot.tar.gz
# -rw-r--r-- 1 mark mark 673M 2010-09-10 14:16 ubuntu-10.04.1-server-i386.iso

# now I need to move the netboot directory some where that will be owned by root
# if you are using a tftp boot server this should be where it looks
# I did a bunch of rtfm today and decided on /var/lib/tftboot even though I wasn't using tftp-hpa

# again note this is issued from my download directory

sudo cp -r netboot /var/lib/tftpboot

# now I just need to restart dnsmasq

sudo service dnsmasq restart

Back to Spinach

Rebooted via PXE boot server; repaired grub2, rebooted to Maverick Meerkat