Next Previous Contents

4. Fundamental ideas

The fundamental idea is as follows: the PC will get its IP address from the boot server via the bootp protocol, using 0.0.0.0 as the initial IP address and its kernel via the tftp protocol. (-- Booting across segments (via router) not a simple question, so either put both the server and the diskless boxes on the same lan segment or configure an UDP helper address in your router to the address of the server. Refer to your router product manual for further info.--)

For this follow the steps below.

4.1 Setting up the PC

Get the nfsboot package (the package is available from your favourite linux mirror site in the /pub/Linux/system/Linux-boot directory). It contains a booteprom image for the wd8013 card which can be directly burned in.

There are alternative ways to prepare the PC:

These images contain a bootp and tftp client. You need to prepare a linux kernel too, which contains the nfs-root option.

You may or may not configure block device (floppy or hard disk) support, but you must configure tcp/ip support, wd ethernet card support, nfs filesystem support. Then recompile the kernel as usual.

4.2 Setting up a bootpd on the server

It can be found in package bootpd-2.4.tar.gz (which can be found on your favourite linux mirror site in the /pub/Linux/system/Network/boot.net directory). Get the package, compile and install it. If your other Unix box happens to be a Slackware Linux then you may skip this step for the standard distributions contain a bootpd. The daemon can be run either directly by issuing command

______________________________________________________________________
       bootpd -s
______________________________________________________________________
or by using inetd. In this case you need to edit:

·  /etc/inetd.conf to remove the hashmark from the start of these
lines:
______________________________________________________________________
# tftp   dgram   udp     wait    root    /usr/sbin/in.tftpd     tftpd /export
# bootps dgram   udp     wait    root    /usr/sbin/in.bootpd    bootpd
______________________________________________________________________

·  insert or uncomment the following two lines in /etc/services:
______________________________________________________________________
bootps          67/tcp          # BOOTP server
tftp            69/udp          # TFTP server
______________________________________________________________________

·  restart inetd by
______________________________________________________________________
       kill -HUP <process id of inetd>.
______________________________________________________________________

4.3 Configure the bootpd on the server

First of all, bootpd have a config file called bootptab which usually resides in /etc. You must modify it by inserting the IP addresses of your gateway, dns server, and the ethernet address(es) of your diskless machine(s). An example /etc/bootptab:

______________________________________________________________________
  global.prof:\
          :sm=255.255.255.0:\
          :ds=192.168.1.5:\
          :gw=192.168.1.19:\
          :ht=ethernet:\
          :bf=linux:
  machine1:hd=/export/root/machine1:tc=global.prof:ha=0000c0863d7a:ip=192.168.1.140:
  machine2:hd=/export/root/machine2:tc=global.prof:ha=0800110244e1:ip=192.168.1.141:
  machine3:hd=/export/root/machine3:tc=global.prof:ha=0800110244de:ip=192.168.1.142:
______________________________________________________________________

global.prof is a general template for host entries, where

After this, every machine must have a line:

4.4 Understanding tftp

TFTP (Trivial File Transfer Protocol) is a file transfer protocol, such as ftp, but it's much simpler to help coding it in EPROMs. TFTP can be used in two ways:

Almost every Unix implementation contains tfpt server, probably you don't need to install your own one.

Install tftpd, make sure it's active in /etc/inetd.conf, typical line

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

4.5 Kernel Image

You must compile a kernel for the DC that includes NFS support and NIC driver compiled in (not modules). Answer yes to Root file system on NFS? and BOOTP support?

After building the kernel, run mknbi-linux from the Etherboot distribution on it. Install this tagged image as /tftpboot/(bf attribute in bootptab).

4.6 Setting up a minimal Linux configuration on the remote server

This may contain packages a, ap, n, and x of the Slackware distribution. To install more is OK; however the above packages suffice for the purposes of a diskless X terminal. For the installation you need a working Linux system. Find some disk space on the remote machine and export it read-write. Mount the exported directory onto somewhere (e.g. /mnt) on the file system of the Linux box. Start Linux setup and change the root option in the setup from / to /mnt. Then setup the above packages as usual. If you want to run no more than one diskless Linux then no changes are needed. On the other hand, if you plan to use more than one diskless machine then the above setup will not work because some files and directories must be private to the machines. The problem can be bypassed by moving the /usr (it contains no private data) and then create a separate subdir for each diskless machine. For example, if /export/linux/machine1 were mounted to /mnt then the directory structure after the initial setup will look like

______________________________________________________________________
       /export/linux/machine1/bin
       /export/linux/machine1/sbin
       /export/linux/machine1/lib
       /export/linux/machine1/etc
       /export/linux/machine1/var
       /export/linux/machine1/usr
______________________________________________________________________

After the changes you will have

______________________________________________________________________
       /export/linux/machine1/bin
       /export/linux/machine1/sbin
       /export/linux/machine1/lib
       /export/linux/machine1/etc
       /export/linux/machine1/var
       /export/linux/usr
______________________________________________________________________

Now create the subdirectories for the other machines. Assume for now that your diskless machines are called machine1, machine2, machine3, etc.; then you may use the following bash script to setup the other directories

______________________________________________________________________
       cd /export/linux
       for x in machine2 machine3 ; do
               mkdir $x; cd $x
               (cd ../machine1; tar cf - *) | tar xvf -
       done
______________________________________________________________________

Then do the following export:

as follows (-- the format of this example follows the SunOs 4.1.3 exports file syntax--) :

______________________________________________________________________
       # This file is /etc/export
       # for remote linux X terminals by Buci
       # this line is only once
       /export/root/usr             -access=linuxnet
       # these lines once for every host
       /export/root/machine1       rw=machine1,root=machine1
       /export/root/machine2       rw=machine2,root=machine2
       /export/root/machine3       rw=machine3,root=machine3
______________________________________________________________________
Don't forget to run exportfs -a.

4.7 Configuring the tftp server

Now it is time to configure the tftp server. If you do not need secure tftp then everything is quite simple for your clients can be booted from the /export directory.

If a secure tftp is used then you can either make a full /export/linux directory structure under /tftpboot (with a single real kernel and symbolic links for the other machines), or let the /export directory be the boot directory of the secure tftpd. Or, if you have a separate tftpboot directory then, similarly, you need only the original directory structure with a single kernel and symbolic links for the others. You can achieve this setup by typing the following:

______________________________________________________________________
     mkdir -p /tftpboot/export/linux/machine1
     cd /tftpboot/export/linux/machine1
     cp /export/linux/machine1/<name of the kernel> .
______________________________________________________________________

Then type the following:

______________________________________________________________________
        mkdir -p /tftpboot/export/linux/machine2
        cd ../machine2
        ln -s ../machine2/<name of the kernel>
______________________________________________________________________

4.8 Final work

Finally, you must insert

______________________________________________________________________
        /sbin/mount nfs_server:/export/linux/usr /usr
______________________________________________________________________

as the first line of

______________________________________________________________________
        /export/linux/<machinex>/etc/rc.d/rc.S
______________________________________________________________________
  where <machinex> stands for machine1, machine2, etc.

4.9 Net Loader

A small program that runs as a BIOS extension, usually on an EPROM on the NIC. It handles the BOOTP query and TFTP loading and then transfers control to the loaded image.

It uses TCP/IP protocols but the loaded image doesn't have to be Linux. The loaded image can be anything, even DOG.

There are two free implementations of TCP/IP net loaders: Etherboot and Netboot : Etherboot uses built-in drivers while Netboot uses Packet drivers.

They can also be loaded from a floppy for testing and for temporary setups.

4.10 RH5 configuration

The DC requests to mount /tftpboot/(IP address of DC) (in 2.1 and above: /tftpboot/(name of DC in bootptab) ) as its / by NFS from server. You must export this from the server (rw, no_root_squash) because the DC wants to write on it (log files, etc).

The / must contain /sbin, /bin, /lib, /etc, /var, /tmp, /root, /dev and /proc.

/sbin, /bin, /lib/ can be a copy of an existing RH5 system. They can be shared between all DCs. But hard links only. BTW, don't link to server originals.

/etc, /var and /dev should be non-sharable copies. Customise /etc/sysconfig/network, /etc/sysconfig/network-scripts/ifcfg-eth0, /etc/fstab, /etc/conf.modules, and others. Turn off all network services you don't need. Remove all stuff you don't need from /var, e.g. RPM db, lpd files.

/root and /proc should just exist. /tmp should exist and be mode 1777.

You probably want to create /usr and /home mount points. /usr can be mounted ro.

About 10 MB per DC plus about 15 MB of shared files should be sufficient. BTW: if your DCs are quite similar, the kernel image can also be shared.

Here is an illustrative script to create the first root filesystem.

#!/bin/sh
if [ $# != 1 ]
then
        echo Usage: $0 client-IP-addr
        exit 1
fi

cd /

umask 022

mkdir -p /tftpboot/$1

# just make these ones
for d in home mnt proc tmp usr
do
        mkdir /tftpboot/$1/$d
        done

        chmod 1777 /tftpboot/$1/tmp

        touch /tftpboot/$1/fastboot
        chattr +i /tftpboot/$1/fastboot

        # copy these ones
        cp -a bin lib sbin dev etc root var /tftpboot/$1

cat <<EOF
Now, in /tftpboot/$1/etc, edit

                sysconfig/network
                sysconfig/network-scripts/ifcfg-eth0
                fstab
                conf.modules

and configure

                rc.d/rc3.d
EOF

Here is an illustrative script to duplicate the root filesystem

#!/bin/sh
if [ $# != 2 ]
then
        echo Usage: $0 olddir newdir
        exit 1
fi

cd /tftpboot

if [ ! -d $1 ]
then
        echo $1 is not a directory
        exit 1
fi

umask 022

mkdir -p $2

# just make these ones
for d in home mnt proc tmp usr
do
        mkdir $2/$d
done

chmod 1777 $2/tmp

touch $2/fastboot
chattr +i $2/fastboot

# link these ones
for d in bin lib sbin
do
        (cd $1; find $d -print | cpio -pl ../$2)
done

# copy these ones
for d in dev etc root var
do
        cp -a $1/$d $2
done

cat <<EOF
Now, in /tftpboot/$2/etc, edit

        sysconfig/network
        sysconfig/network-scripts/ifcfg-eth0
        fstab (maybe)
        conf.modules (maybe)

and configure

        rc.d/rc3.d
EOF

4.11 Gotchas and caveats

RH5 wants to fsck the root FS. I stopped this with a /fastboot. But init script wants to delete it, so I did chattr +i /fastboot

/etc/localtime is a link to TZ file in /usr/share/... I made it a copy.

Turn off /etc/rc.d/rc6.d/K97network or it will disable the network before root FS is done with.

X server wants to write into /usr/X11R6/lib/X11/xkb/compiled. I made this a link to /etc/X11/kbd/compiled

Remember your DC will keep appending to log files so have logrotate or something deal with them at regular intervals.

4.12 X-terminal

On the server, make sure the DC is matched by a clause in /etc/X11/xdm/Xaccess and comment out the :0 in /etc/X11/xdm/Xservers. Then make sure that xdm is run from the init scripts.

On the client, run X -query server

You will get the xdm login box and then all your X clients will run on the server.

For other applications use - you could use diskless technique for netboot routers, print servers (but should not be spooling print server), standalone apps, etc.


Next Previous Contents