Point to note:
DO NOT USE HARDY IF YOU HAVE INTENTIONS OF PXE / NFS BOOTING CLIENTS WITH MODERN NICS!
OS Configuration:
I upgraded from Hardy 8.04.1 to the release that I know is actually "stable" when they called it "stable" (Dapper Drake 6.06.2 AKA my bread and butter lately).
First up, installation of Dapper... I installed LAMP default. Nothing fancy here. Once installed update your /etc/apt/sources.list so that the universe, multiverse, and restricted sites are no longer commented out. I also recommend commenting out the deb cdrom from the sources.list so you don't have to worry about having your cd handy.
Here's what is in my sources.list:
deb http://us.archive.ubuntu.com/ubuntu/ dapper main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper main restricted
deb http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper universe
deb http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
deb http://security.ubuntu.com/ubuntu dapper-security universe
deb-src http://security.ubuntu.com/ubuntu dapper-security universe
Now you'll need to update apt and install the required packages by performing:
sudo apt-get update
sudo apt-get install dhcp3-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools
PXE / TFTP configuration:
(Next two steps not necessary but makes life easier)
1 - Let's setup the tftp locations for files we'll be using:
sudo mkdir -p /tftpboot/pxelinux.cfg
2 - Change the /etc/default/tftpd-hpa file to reflect the new directory and to start on boot. Here's what mine looks like:
RUN_DAEMON="yes"
OPTIONS="-l -s /tftpboot"
Start up your tftp daemon:
/etc/init.d/tftpd-hpa start
TFTP is now up and ready (you can check to see that it is listening by doing:
netstat -anu|grep 69
PXE is really just a boot loader file ("pxlinux.0" is included in your syslinux package) that allows one to boot via a NIC versus CD-ROM, USB key, hard drive, etc... Most NICs nowadays support PXE booting and you will need to visit your client(s) to enable and bring your NIC to the top / first of the boot order in the BIOS.
Copy your "pxelinux.0" file and kernel into your tftpboot directory:
sudo cp /usr/lib/syslinux/pxelinux.0 /tftpboot
sudo cp /boot/vmlinuz* /tftpboot/vmlinuz
ORDER IS IMPORTANT FOR THE NEXT THREE STEPS
1 - We're going to create our own initrd.img for booting purposes. Because I have nuked many (MANY) systems in my day, I now have a policy of always copying whatever I'm working on to a new location (sandbox) and work with the new copy. We're going to need an entire directory tree copied:
sudo cp -Rp /etc/mkinitramfs /etc/mkinitramfs-pxe
2 - We now have our own mkinitramfs sandbox. Modify the /etc/mkinitramfs-pxe/initramfs.conf so that "BOOT=nfs" "DEVICE=eth1" (We're using eth1 as an example since this IS a lament post regarding multi-NIC clients. Typically eth0 is your first NIC) and "NFSROOT=192.168.0.254:/nfsroot" where 192.168.0.254 is your NFS server.
Here's what my /etc/mkinitramfs-pxe/initramfs.conf looks like:
BUSYBOX=y
BOOT=nfs
MODULES=most
DEVICE=eth1
NFSROOT=192.168.0.254:/nfsroot
3 - Now we can make our own initrd.img (which is nothing more than a cpio file that is gzipped):
sudo mkinitramfs -d /etc/mkinitramfs-pxe -o /tftpboot
Now we'll need to create / edit our /tftpboot/pxelinux.cfg/default (or the hardware address of the client, mine is named "01-00-30-48-2d-1b-a3") and I am a visual person, so I create a pause with dialog. Here's what's inside my pxe configuration file:
timeout 100
prompt 1
display a3-menu.txt
default 0
label 0
kernel vmlinuz
append root=/dev/nfs nfsroot=192.168.0.254:/nfsroot ip=dhcp initrd=initrd.img rw --
DHCP Configuration:
You'll need to configure your dhcp server now so the client(s) can get IP addresses and boot to their PXE image. Modify your /etc/dhcp3/dhcpd.conf file to reflect the correct settings for your network.
Here's what mine looks like:
allow booting;
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
option domain-name "sandbox.local";
option domain-name-servers 172.24.17.21,172.24.17.23;
authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.1 192.168.0.200;
option routers 192.168.0.254;
next-server 192.168.0.254;
filename "pxelinux.0";
# i1620
host i1620 {
hardware ethernet 00:30:48:2D:1B:A3;
fixed-address 192.168.0.69;
option host-name "i1620";
}
}
Your configuration will probably have different:
domain-name = the domain suffix for the clients
domain-name-servers = ip addresses of your DNS servers
subnet = the subnet that you will be handing out IP addresses on
netmask = the network mask for the subnet (above)
range = the range of IP addresses to use for your clients
routers = your default route and / or all other routes
next-server = your tftp / PXE server
filename = the name of the PXE boot loader file
host = name and configurations for any given host
hardware ethernet = your (above) host's machine address
fixed-address = the address your (above) host will always get
host-name = the hostname for your (above) host if it doesn't already have one
Start the DHCP service:
sudo /etc/init.d/dhcp3-server start
NFS Configuration:
(your location may vary) Create a location for the NFS root:
sudo mkdir /nfsroot
Edit your /etc/exports file to reflect your NFS root folder you will be using.
Mine looks like this:
/nfs 192.168.0.0/255.255.255.0(rw,no_root_squash,async)
Now start the service:
sudo /etc/init.d/nfs-kernel-server start
Client configuration:
Many people will install locally to their client, copy the OS files to the nfsroot, and then pull the drive from the client. I'm lazy, so I just copied my server files over to the /nfsroot directory and modified a handful of files. There are only a few gotchas, that I will explain after you modify your basic files. Your configurations will vary from mine, so make sure you at least look into each of the following:
/etc/hostname
/etc/hosts
/etc/fstab
/etc/network/interfaces
The last two will need some serious changing. First edit your /etc/fstab to reflect correct mount points for "/proc" and "/"
Mine looks like this:
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
/dev/nfs / nfs defaults 1 1
Finally you will need to edit your /etc/network/interfaces file to reflect correct activation.
Mine looks like this:
auto lo
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet manual
You're done! (weeeeeee *plop*)
Go reboot your client and it will boot up PXE and mount / to your nfsroot!
