In the previous post I had the problem:
… when I boot up, I get the Ubuntu boot screen, which shows it’s connecting to the terminal server, however it then fails with an errror saying
Error: Failed to connect to NBD server
And I get sent to a basic busybox shell.
There were two reasons for this.
PXE… booted
First of all, because I obtain the DHCP separately from the network boot, I need to treat it as if it’s a static IP. LTSP can handle static IPs, but this posed a couple of problems. I would need to specify a separate config file for each MAC address in the pxelinux.cfg/ directory. Secondly it would require each MAC address to be given the same IP each time (this was not going to happen).
So instead of getting gPXE to PXE boot, I completely bypass pxelinux.0 and use my own boot script. In this script I pass in the IP and other information. gPXE has some environment variables which can be used for this, so I wrote a script (The ‘x’s should be replaced by the terminal server’s IP address).
#!gpxe dhcp net0 kernel tftp://xxx.xxx.xxx.xxx/ltsp/i386/vmlinuz ip=${ip}:xxx.xxx.xxx.xxx:${gateway}:${netmask}:${hostname}:eth0:none nbdroot=xxx.xxx.xxx.xxx:2000 initrd tftp://xxx.xxx.xxx.xxx/ltsp/i386/initrd.img boot vmlinuz
This script retrieves the kernel, and passes as parameters the environment variables (which were set by the dhcp) the IP, gateway, netmask and hostname. Another parameter is the nbd server location and port. The we retrieve the initial ramdisk (initrd) and boot.
More haste less speed
After that was fixed, on my test machines it still didn’t connect to the NBD server. This is because my test machines are core2duo 3ghz with 4gb RAM; they were so fast at booting up, that it didn’t get a response from the NBD server in time. I diagnosed this by adding the parameter:
break=mount
To the kernel line in the script above. This stopped the boot, then it got a response from the server, and when I pressed ctrl+D (to continue the boot) it booted up fine. This is a bug in the ltsp_nbd script.
I solved this by logging into the terminal server and opening the file /opt/ltsp/i386/usr/share/initramfs-tools/scripts/ltsp_nbd, then added the line:
sleep 5
after the line:
ip link set lo up
This meant that the script paused for 5 seconds to allow the NBD server to respond.
Once edited the initramfs needs updating, as do the kernels:
chroot /opt/ltsp/i386 update-initramfs -u ltsp-update-kernels
I will be writing a part 3 to this sometime soon talking about some of the customisations I will be adding.