Diskless Workstation

From LQWiki
Jump to: navigation, search

This article explains how to make a diskless Debian Etch workstation. It is based on the Ubuntu how-to https://help.ubuntu.com/community/DisklessUbuntuHowto. The workstation will boot from PXE

We assume the client and server are already set up with Debian Etch, with the client set up on a single root partition. In this example, is the server, while is the router. You'll want to change these numbers for your own server and router.

Install server packages

Install the following packages on the server:

apt-get install dhcp3-server
apt-get install tftp-hpa
apt-get install syslinux
apt-get install nfs-kernel-server
apt-get install initramfs-tools
apt-get install pxe
apt-get install atftpd

Set up tftp boot

Create the /tftpboot and start populating it with something like:

mkdir -p /tftpboot/pxelinux.cfg
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
cp /boot/vmlinuz-2.6.15-1-486 /tftpboot/

Replace vmlinuz-2.6.16-1-486 with the kernel you're using.

If you run in to problems with TFTPD, be sure to run

chown -R nobody.nogroup /tftpboot
chmod -R 777 /tftpboot

and if you get "cannot set group for user nobody" in /var/log/syslog, be sure to run

adduser nobody

Configure the tftp service to provide access to /tftpboot by editing /etc/inetd.conf. Make sure the line starting with "tftp" ends with "/tftpboot". It should look something like:

tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot

Restart the tftp service with:

/etc/init.d/inetd restart

Create a net-bootable initrd image with:

cd /etc/initramfs-tools/
cp initramfs.conf initramfs.conf.originalbackup

Edit initramfs.conf using a text editor. Change the BOOT line from "BOOT=local" to "BOOT=nfs". After creating this image, you may change the BOOT line back to local.

mkinitramfs -o initrd.img.netboot
mv initrd.img.netboot /tftpboot/

Create a PXE config file /tftpboot/pxelinux.cfg/default. If you know the workstation's MAC address, name the file 01-aa-bb-cc-dd-ee-ff where aabbccddeeff is the MAC address. (You'll need to name the files like this or by IP address in hex if you're setting up more than one diskless workstation.) Here's an example:

LABEL linux
KERNEL vmlinuz-2.6.15-1-486
APPEND root=/dev/nfs initrd=initrd.img.netboot nfsroot= ip=dhcp rw

You'll want to put your server's IP address in and your desired location of the workstation's OS.

Set up DHCP

First, deactivate any DHCP service on your router or other server. Then configure DHCP service (dhcpd) on your server with:

vi /etc/dhcp3/dhcpd.conf
/etc/init.d/dhcp3-server restart

Unless your TFTP server is on the same machine as your DHCP server, make sure to include this line at the top:


Without this line, the client will hang on trying to load the pxe config file.

You'll need to insert lines to the file to configure assigned addresses. This entry will set up dynamic addresses:

default-lease-time 600;
max-lease-time 7200;

option domain-name "xephon";
option domain-name-servers,,;
option routers;
subnet netmask {
  filename "/tftpboot/pxelinux.0";

This entry will set up a static address. You'll need to know the MAC address--for example, by booting up a liveCD and running "ifconfig -a" as root.

  hardware ethernet 00:14:2a:ef:ea:07;
  filename "/tftpboot/pxelinux.0";

If you want, you can define addresses in /etc/hosts and use them under fixed-address.

Set up nfs

Create the nfs share on the server with:

mkdir /mnt/hda5/yuki

Edit /etc/exports. Create this entry:

/mnt/hda5/yuki yuki.xephon(rw,async,no_root_squash)

Then, do a

exportfs -rv

Note that this assumes the address of yuki.xephon is defined in /etc/hosts. You can replace this with a numerical IP address. You can also replace it with "*" if you don't mind any machine on the LAN to have access.

Copy over the files by running the following ON THE CLIENT:

mkdir /mnt/yuki
mount -tnfs -onolock /mnt/yuki
cp -axv /. /mnt/yuki/.
cp -axv /dev/. /mnt/yuki/dev/.

Now, back on the server, modify the files to make them suitable for diskless netbooting. Edit /mnt/hda5/yuki/etc/network/interfaces and comment out any lines which automatically bring up eth0 (like "auto eth0" or "allow-hotplug eth0"). Just leave a line like "iface eth0 inet dhcp". The network interface eth0 will have already been brought up by net-booting, and we don't want to reset it.

Edit /mnt/hda5/yuki/etc/fstab to look something like this:

###/dev/hda1       /               ext3    noatime,errors=remount-ro 0       1
###/dev/hda5       /mnt/hda5       ext3    noatime         0       2
###/dev/hda6       none            swap    sw              0       0

/dev/nfs        /               nfs     defaults 0 0
none            /tmp            tmpfs   defaults 0 0
none            /var/run        tmpfs   defaults 0 0
none            /var/lock       tmpfs   defaults 0 0
none            /var/tmp        tmpfs   defaults 0 0
none            /media          tmpfs   defaults 0 0

Comment out any local partitions including swap.

Configure BIOS

On the client workstation, boot up and enter setup to turn on PXE LAN boot. If you don't have this option, then you may have to set up a boot floppy (see EtherBoot). Then reboot, and see if everything works!

Setting up more workstations

If you want to set up more than one workstation, you'll need to know the MAC addresses of them all. You can find it out by logging on as root and running "ifconfig -a" (on Debian systems). Then:

1. Create a new PXE config file /tftpboot/pxelinux.cfg/01-aa-bb-cc-dd-ee-ff where aabbccddeeff is the MAC address (use lowercase).

2. Create a new entry in /etc/dhcp3/dhcpd.conf for the new MAC address. Don't forget to restart the DHCP server with "/etc/init.d/dhcp3-server restart"

3. Create the new nfs shared directory and populate it. Create a new entry in /etc/exports as appropriate. Don't forget to resync the exports with "exportfs -rv"

4. Configure the BIOS on the client for LAN boot.

For creating the new workstation's directory, you can copy from an existing one and just edit /mnt/hda5/newworkstation/etc/hostname to change the hostname.

See also