This is a great approach for easy deploying various distros over the network instead of using cd-rom/usb sticks. Since I already had a PI running as a torrent client/server and SAMBA why not implement some additional features? After some hours of hacking I manage to get the stuff working perfectly.
Let's get started. Please let me know if any step generates any issues.
Login as root
pi@pi ~ $sudo su -
root@pi:~#apt-get update
root@pi:~#apt-get install syslinux-common #This is for pxe booting files.
root@pi:~#apt-get install dnsmasq #Since I already have a router providing DHCP we need to use a proxy dhcp. dnsmasq is a great set of tools providing us with both tftp and proxy dhcp.
#mkdir /srv/tftpboot #root folder for pxe server.
root@pi:/srv/tftpboot#cp /usr/lib/syslinux/pxelinux.0 . #copy neccacary files for pxe boot.
root@pi:/srv/tftpboot#cp /usr/lib/syslinux/menu.c32 .
root@pi:/srv/tftpboot#mkdir pxelinux.cfg #folder for boot menu
root@pi:/srv/tftpboot/pxelinux.cfg
root@pi:/srv/tftpboot/#vim.tiny default #Menu file
Add following info for /srv/tftboot/pxelinux.cfg/default:
DEFAULT menu.c32
PROMPT 0
MENU TITLE PXE Boot
LABEL Test
MENU LABEL Test
Edit dnsmasq settings. Just add following lines at the end of the file.
# vim.tiny /etc/dnsmasq.conf
interface=eth0
dhcp-range=192.168.0.0,proxy
dhcp-boot=pxelinux.0
pxe-service=x86PC,"Booting from Network...",pxelinux
enable-tftp
tftp-root=/srv/tftpboot
dhcp-boot=pxelinux.0,servername,192.168.0.10
#restart dnsmasq to load config
root@pi:/srv/tftpboot#service dnsmasq restart
Try to boot a machine with pxe booting. Just to verify that's working.
Next we need to install nfs support for sharing the mounted iso files.
root@pi:/srv/tftpboot#apt-get install nfs-kernel-server
root@pi:/srv/tftpboot#mkdir /tftpboot/iso #this is where we put distro iso files
root@pi:/srv/tftpboot#mkdir /tftpboot/nfs #this is where we share nfs files
root@pi:/srv/tftpboot#mkdir /tftpboot/nfs/ubuntu #folder for ubuntu dist
Edit nfs shares
root@pi:/srv/tftpboot/#vim.tiny /etc/exports
Add following line:
/srv/tftpboot/nfs/ubuntu/ *(ro,sync,no_subtree_check)
root@pi:/srv/tftpboot# mount -o loop iso/ubuntu-13.04.iso nfs/ubuntu/ #mount iso file to nfs folder
mount: warning: nfs/ubuntu/ seems to be mounted read-only.
Then we need to enable rpcbind and restart nfs
root@pi:/srv/tftpboot#update-rc.d rpcbind enable && update-rc.d nfs-common enable
root@pi:/srv/tftpboot#service rpcbind start
root@pi:/srv/tftpboot#service nfs-kernel-server restart
Add following entry to the /srv/tftpboot/pxelinux.cfg/default
DEFAULT menu.c32
PROMPT 0
MENU TITLE PXE Boot
LABEL Test
MENU LABEL Test
LABEL Ubuntu
MENU LABEL ^Ubuntu 13.04
KERNEL nfs/ubuntu/casper/vmlinuz
APPEND initrd=nfs/ubuntu/casper/initrd.lz boot=casper netboot=nfs
nfsroot=192.168.0.180:/srv/tftpboot/nfs/ubuntu
Change IP to your server IP in default config file
That should be all. Works flawless for me(I/O performance of the PI is not awesome but definitely works fine). A really neat way of installing without using cd-rom or usb.
Does your site have a contact page? I'm having a tough time locating it but, I'd like to send you
ReplyDeletean e-mail. I've got some creative ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it develop over time.
Also visit my homepage - seed box
This is the easiest and straight forward PXE server how to guide, thanks.
ReplyDeleteTo get this working properly I had to modify the dhcp-boot entries in the dnsmasq.conf file.
ReplyDeletedhcp-boot=/full/pathto/pxelinux.0
Then it worked like a charm. Thank you very much for the write-up. Your work is greatly appreciated. I can now test my PI PXE config without having to segregate it from my network.
Thanks mate :-)
DeleteI always run into a strange Error when trying to boot my Ubuntu-Linux via this PXE. It always says NFSMount: Need a path. The Kernel is loading normally but the boot aborts everytime.
ReplyDeleteThanks for this great tutorial, but I have the same failure like 2 posts before from Ian Ide, but his fix to supply full path doesn't work for me :(
ReplyDeleteAny clue?
It worked out! ;)
DeleteGetting PXE-E74 bad boot file error. Help plz
ReplyDelete