Setting Up A Multi boot PXE Install Server On Ubuntu Lucid
Installing Necessary Packages
We are going to install the packages required for the PXE server:
· tftpd-hpa - this is the file transfer server
· dhcp3-server - linux dhcp server, not needed if you allready have a dhcp server
· openbsd-inetd - new inetd server
sudo apt-get install tftpd-hpa dhcp3-server openbsd-inetd
Setting Up Tftp Server
Edit /etc/inet.conf to and ensure the line is correct, last part is important:
sudo gedit /etc/inetd.conf
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /tftpboot
Ensure that it reads /tftpboot rather than /var/lib/tftpboot.
We need to check that the tftpd server is running.
netstat -lu
Check for this line:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 *:tftp *:*
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 *:tftp *:*
If you don't see the tftp line, then go back and edit /etc/inet.conf again.
Then enable inetd at boot:
sudo update-inetd --enable BOOT
Now restart your inetd server:
sudo /etc/init.d/openbsd-inetd restart
Next we need to edit the /etc/default/tftpd-hpa file to change the boot directory:
sudo gedit /etc/default/tftpd-hpa
Change the file to look like this:
RUN_DAEMON="yes"
OPTIONS="-l -s /tftpboot"
Restart tftpd server:
sudo /etc/init.d/tftpd-hpa restart
We now need to create a folder to store our boot stuff in.
sudo mkdir /tftpboot
Now we need to change the user to nobody:
sudo chown nobody /tftpboot
Then we need to let everyone read and write to /tftpboot:
sudo chmod 777 /tftpboot
Now check if that worked:
ls -ld /tftpboot
You should see a line similar to this:
drwxrwxrwx 2 nobody root 4096 2010-01-28 15:04 /tftpboot
7. Setting Up DHCP Server
On what network interfaces should the DHCP server (dhcpd) serve DHCP requests? Answer this question by editing the line in /etc/default/dhcp3-server file. Separate multiple interfaces with spaces, e.g. "eth0 eth1". As I only want the DHCP server running on eth1, I need to change this line.
sudo gedit /etc/default/dhcp3-server
Change the INTERFACES line to:
INTERFACES="eth1"
Now we need to back up the configuration files for dhcpd server:
sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_orig
Now we can configure dhcpd:
sudo gedit /etc/dhcp3/dhcpd.conf
Here is my file, you will need to change the values to suit.
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.2 192.168.2.255;
filename "pxelinux.0";
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.2.255;
option routers 192.168.2.1;
}
This will dynamically assign IP addresses from the range 192.168.2.2 to 192.168.2.255 to your client computers. The gateway is 192.168.2.1.
It is important that you have the line filename "pxelinux.0"; in your configuration!
Then restart your DHCP server:
sudo /etc/init.d/dhcp3-server restart
If you already have a DHCP server in your network, you must modify its configuration. Let's assume you have something like
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.2 192.168.2.255;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.2.255;
option routers 192.168.2.1;
}
in the configuration. You must add
filename "pxelinux.0";
next-server 192.168.2.100;
next-server 192.168.2.100;
to it (where 192.168.2.100 is the IP address of our Ubuntu PXE server) so that it looks like this:
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.2 192.168.0.255;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.2.255;
option routers 192.168.2.1;
filename "pxelinux.0";
next-server 192.168.2.100;
}
Now verify that it DHCP is running (if not, you may have a problem with you dhcp config file).
ps ax | grep dhcpd
8. Setting Up Boot Files
We now need to get the netboot files.
cd /tftpboot
Download files with lftp:
lftp -c "open http://archive.ubuntu.com/ubuntu/dists/karmic/main/installer-i386/current/images/netboot/; mirror"
Instead, if Ubuntu is in your cdrom drive:
mount /media/cdrom
cp -a /media/cdrom/install/netboot/* /tftpboot/
cp -a /media/cdrom/install/netboot/* /tftpboot/
Now we can add a splash screen to our configuration, first we need the versamenu.c32 file.
cp /tftpboot/ubuntu-installer/i386/boot-screens/vesamenu.c32 /tftpboot
lftp -c "get http://www.howtoforge.com/images/pxe_install_server_ubuntu_9.10/howtoforge_pxe.png;"