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.

No comments:

Post a Comment