LTSP Part 2 – Configuration

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.

  • Hey, I’ve worked on gPXE booting over HTTP somewhat recently.

    forum.ebox-platform.com/index.php?topic=2360.msg10138#msg10138

    I use nginx as my http server, it’s small and reasonably easy to configure multiple hosts on quickly.

    Recently blogged about setting nginx up with php5 with lucid and phpmyadmin.

    blog.sllabs.com/2010/06/fun-with-nginx-upstart-and-lucid.html

    Came across your page while I was catching up; ubuntu lucid’s casper scripts have fixed TORAM=Yes on isos, which should work via netboot too, I’m hoping. Likely going to blog my results with http booting lucid in various ways.

    I’ve got my boot catalog online at files.sllabs.com/boot/

    DOWN WITH TFTP! Just serve gPXE! 😀

  • ravi

    where should i write the boot script which u mentioned

  • Rick Ogden

    Ravi: It doesn’t matter, you just reference it when making the boot image using the EMBEDDED_IMAGE command:

    $ make EMBEDDED_IMAGE=/path/to/script.gpxe

    I didn’t include it as there is plenty of documentation on the gPXE site: http://etherboot.org/wiki/scripting

    Rick

  • Rene Winnik

    Just wanted to say thanks for the write up. I had just started with the same problem. I have 2 questions:

    The only piece that seems to be missing is the nbdroot=xxx.xxx.xxx.xxx:2000

    In normal dhcp operation, where does it get this value. In my case the normal DHCP works, it is just when I get to a location that I can not modify the DHCP that I have the same problem as you do.

    The second is how do you modify the (in my case a cdrom ) gxeboot boot to do all this automatically.

    Thanks, great write up and keep up the good work.

    Rene’

  • Rick Ogden

    Hi Rene,

    I’m pretty sure in a standard LTSP configuration the NBD server IP and port is stored in the configs inside the pxelinux.cfg file (inside the image directory in the tftp location). That’s what contains the boot parameters.

    To modify the CD you use the command mentioned in the comment above “make EMBEDDED_IMAGE=/path/to/script.gpxe” where the EMBEDDED_IMAGE value is the path to the script. If you rerun that it will overwrite any existing images with the new one.

    Alternatively you could do what I do, which is host a boot script on a webserver and tell all clients to go to that once they have an IP. This is what I’ve done (and will be talking about it in Part 3 when I get around to writing it). This way you just alter the script on the webserver and it will be used from then on by all your clients.

    Hope this answers your questions.

    Rick