Copying LTSP root image on bootup

LTSP logoIn work we use LTSP to boot up thin clients. Nothing runs locally on these thin clients, they’re used for either VNC or rdesktop access. One problem we had was that if the LTSP server was rebooted, the NBD client would lose its connection to the server and never re-establish it. This mattered because we want to be able to remotely shut down thin clients overnight.

So, we came up with a quick and dirty way of copying the root filesystem image locally to the thin client. Your thin client needs to have enough free RAM to store it all (these are diskless), and in our case the image is about 290MB while the thin clients have 1GB RAM. We don’t need much RAM for the actual system just to run X and VNC/rdesktop.

So, run ltsp-chroot, then add the following contents to a new file called /usr/share/initramfs-tools/scripts/local-top/z_nbd :

 

It’s very simple. We’re adding a small script to the “INITial RAM FileSystem” that Linux uses in the early stages of booting up. It uses dd to pull the entire root filesystem from the LTSP server, which in practice only takes a few seconds. Then it stops the nbd-client, and moves our new local copy into the place where the rest of LTSP expects to find it.

When you’ve create the file, and still within the ltsp-chroot, run:

to rebuild the initramfs.

Finally, exit from the ltsp-chroot and from the main server run

to copy the new initramfs in the TFTP server’s path.

Leave a Reply

Your email address will not be published. Required fields are marked *