Thursday, March 6, 2014

Setting up an DHCP server - network boot part three

You can use any dhcp server to get pxe booting to run. We are using isc-dhcp-server, which is part of debian. Dnsmasq, which also is a dns server, would be an alternative.

So let's install the server
# apt-get install isc-dhcp-server

It's configuration file is  /etc/dhcp/dhcpd.conf.
default-lease-time 600;
max-lease-time 7200;
allow booting;

# in this example, we serve DHCP requests from 192.168.0.(5 to 253)
# and we have a router at 192.168.0.1
subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.5 192.168.0.253;
  option broadcast-address 192.168.0.255;
  option routers 192.168.0.1;             
  option domain-name-servers 192.168.0.1; 
  filename "pxelinux.0"; 
  next-server 192.168.0.3;  #make sure, that this is the ip address of 
                            # your tftp server
}

After you have configured your dhcp server, you need to restart it.

  # /etc/init.d/isc-dhcp-server restart

Now we are ready for booting any machine over the network. We set up a TFTP server, an NFS server and a DHCP server. That's all it takes.

By the way I usually use VirtualBox to try and test network booting.

Further reading:
http://www.debian-administration.org/articles/478
https://help.ubuntu.com/community/PXEInstallMultiDistro
https://help.ubuntu.com/community/DisklessUbuntuHowto

Tuesday, March 4, 2014

Setting up an NFS server - network boot part two

NFS is used to share files/directories among networked computers. First let's install NFS.

apt-get install nfs-kernel-server 
 
Next we will create a directory that holds our cd images. Of course NFS can be used for other things - e.g. holding user data centrally.
We will just provide some iso images and make them available for network boot.

mkdir ~/netbootimages

I put several different live cd images into that folder (e.g. ubuntu, clonezilla, and others)
In addition to where my net boot images are located, we need to create an nfs share.

mkdir -a /srv/boot/isoimages

Next we create a directory for each cd image on the tftp server share

mkdir -p "/var/lib/tftpboot/isoimage/MYISO"

Then we mount the iso into that share

mount -t iso9660 -o loop ~/netbootimages/MYISO.iso "/var/lib/tftpboot/isoimage/MYISO"

And we need to also make the image available on the nfs share. We use mount bind/rebind for that, so we have all the files there just once.

mount --rbind /var/lib/tftpboot/isoimages/MYISO /srv/boot/isoimages/MYISO


Next we need to export the files
exportfs -i -o async,no_root_squash,no_subtree_check,ro 0.0.0.0/0.0.0.0:/srv/boot/isoimages/MYISO

PXE boot also needs three boot files: the boot-strap (pxelinux.0), the menu (menu.c32), and the menu text configuration (pxelinux.cfg/default). So let's copy/create them:

cp /usr/lib/syslinux/pxelinux.0 "/var/lib/tftpboot/"
cp /usr/lib/syslinux/menu.c32 "/var/lib/tftpboot/"
mkdir -p "/var/lib/tftpboot/pxelinux.cfg"



In the folder pxelinux.cfg I created a default file, which looks like this


default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

MENU TITLE Main Menu

LABEL local
        MENU LABEL Boot local hard drive
        LOCALBOOT 0

LABEL Ubuntu12.04.4  
    kernel isoimages/12.04.4-64/casper/vmlinuz.efi
    append boot=casper netboot=nfs nfsroot=NFS_SERVER_IP:/srv/boot/isoimages/12.04.4-64 initrd=isoimages/12.04.4-64/casper/initrd.lz 


Further reading:
https://wiki.ubuntu.com/LiveCDNetboot
http://tjworld.net/wiki/Linux/Ubuntu/NetbootPxeLiveCDMultipleReleases
http://www.howtogeek.com/61263/how-to-network-boot-pxe-the-ubuntu-livecd/


We are almost done. Last thing is, we need to configure a dhcp server, to serve the pxelinux.0 file. This will be part of one of the next blog entries.