Next Previous Contents

## 3. Setup on the server

## 3.1 Compiling the kernels

On the server side, if you don't plan to use the old, user-mode NFS daemon, you'll need to compile NFS server support into the kernel (``NFS server support,'' a.k.a. knfsd or `CONFIG_NFSD`). If you plan to use the older RARP protocol to assign the client an IP address, RARP support in the kernel of the server is probably a good idea. (You must have it if you will boot via RARP without kernel parameters.) On the other hand, it doesn't help you if the client isn't on the same subnet as the server.

The kernel for the workstation needs the following settings, as a minimum:

- NFS filesystem support (`CONFIG_NFS_FS`). Note that there is no need for ext2 support.
- Root file system on NFS (`CONFIG_ROOT_NFS`).
- Ethernet (10 or 100Mbit) (`CONFIG_NET_ETHERNET`).
- The ethernet driver for the workstation's network card (or onboard ethernet chip, if it's built into the motherboard or chipset).

Where there is an option to compile something in as a module, do not do so; modules only work after the kernel is booted, and these things are needed during boot.

For dynamically assigned IP numbers, you'll also need to select one or more of these kernel options:

- IP: kernel level autoconfiguration (`CONFIG_IP_PNP`)
- RARP support (`CONFIG_IP_PNP_RARP`)
- BOOTP support (`CONFIG_IP_PNP_BOOTP`)
- DHCP support (`CONFIG_IP_PNP_DHCP`)

If the workstation will be booted without kernel parameters, you need also to set the root device to 0:255. Do this by creating a dummy device file with `mknod /dev/nfsroot b 0 255`. After having created such a device file, you can set root device of the kernel image with `rdev <kernel-image> /dev/nfsroot`. [NOTE: Modern kernels recognize `root=/dev/nfs` as a command-line argument; for consistency and/or compatibility, it may be better to use `/dev/nfs` as the device name instead of `/dev/nfsroot`.]

## 3.2 Creation of the root filesystem

### Copying the filesystem

Warning: while these instruction might work for you, they are by no means sensefull in a production environment. For a better way to set up a root filesystem for the clients, see the NFS-Root-Client mini-HOWTO by Ofer Maor `<ofer@hadar.co.il>`.

After having decided where to place the root tree, create it with (e.g.) `mkdir -p <directory>` and `tar cClf / - | tar xpCf <directory> -`.

If you boot your kernel without LILO, then the rootdir has to be `/tftpboot/<IP-address>`. If you don't like it, you can change it in the top Makefile in the kernel sources, look for a line like: `NFS_ROOT = -DNFS_ROOT="\"/tftpboot/%s\""` If you change this, you have to recompile the kernel.

### Changes to the root filesystem

Now trim the unneeded files, and check the /etc/rc.d scripts. Some important points:

- One important thing is eth0 setup. The workstation comes up with eth0 set up, at least partially. Setting the IP address of the workstation to the the IP address of the server is not considered a clever thing to do. (As it happened to the original author on one of his early attempts.)
- Another point is the /etc/fstab of the workstation. It should be set up for NFS filesystems. <NOTE: this is not true in 2.4 kernels; the NFS mount is implicit and may actually cause mount(1) error messages if it's explicitly listed in /etc/fstab. It is not clear when this changed.>
- WARNING: Don't confuse the server root filesystem and the workstation root filesystem. (I've already patched up a rc.inet1 on the server, and wondered why the workstation still didn't work.)

### Exporting the filesystem

Export the root dir to the workstation. The basic idea is to edit `/etc/exports` to include a line similar to one of the following:

- `/path/on/server/to/nfs_root <client-IP-number>(rw,no_root_squash,no_all_squash) <2nd-client-IP-number>(rw,no_root_squash,no_all_squash)`
- `/path/on/server/to/nfs_root <client-IP-network>/<client-IP-netmask>(rw,no_root_squash,no_all_squash)`

For example, a DHCP client receiving an IP address on a class C subnet would need an exports entry similar to this:

- `/path/on/server/to/nfs_root 192.168.263.0/255.255.255.0(rw,no_root_squash,no_all_squash)`

The `no_root_squash` parameter allows the superuser (root) to be treated as such by the NFS server; otherwise root will be remapped to nobody and will generally be unable to do anything useful with the filesystem. The `no_all_squash` parameter is similar but applies to non-root users. See the `exports(5)` man page for details.

You will have to notify the NFS server after making any changes to the exports file. Under Red Hat this can easily be done by typing `/etc/rc.d/init.d/nfs stop; /etc/rc.d/init.d/nfs start`. On other systems, a simple `/etc/rc.d/init.d/nfs restart` or even `exportfs -a` may suffice, while on older machines running the user-mode NFS daemon you may actually need to `killall -HUP rpc.mountd; killall -HUP rpc.nfsd`. (Do not `killall -HUP rpc.portmap`, however!)

You may also need to edit `/etc/hosts.allow` and/or `/etc/hosts.deny` if tcp_wrappers are installed. In particular, if the remote system (client) gets RPC: connection refused errors, `/etc/hosts.deny` probably contains `portmap: ALL` or `ALL: ALL`. To enable the client to use the server's portmapper, add a corresponding line to `/etc/hosts.allow`:

> `

>     portmap: <client-IP-number>
>     portmap: <2nd-client-IP-number>
>     portmap: <client-IP-network>/<client-IP-netmask>

> `

There is no need to restart anything in this case. You can check by running `rpcinfo -p` on the NFS server and `rpcinfo -p NFS-server` on a Linux client within the allowed range; the RPC services listed by both should match.

In case of problems, check `/var/log/messages` and `/var/log/syslog` for errors (for example, run `tail -f /var/log/messages /var/log/syslog` and then try booting the client), and check your man pages (exports, exportfs, portmap, etc.). As a last resort, a reboot of the NFS server may help, but that's a borderline Microsoftism...

### RARP setup

Set up the RARP somewhere on the net. If you boot without a nfsroot parameter, the RARP server has to be the NFS server. Usually this will be the NFS server. To do this, you will need to run a kernel with RARP support.

To do this, execute (and install it somewhere in `/etc/rc.d` of the server!):

`/sbin/rarp -s <ip-addr> <hardware-addr>`

where

ip-addr

  is the IP address of the workstation, and

hardware-addr

  is the ethernet address of the network card of the workstation.

example: `/sbin/rarp -s 131.131.90.200 00:00:c0:47:10:12`

You can also use a symbolic name instead of the IP address, as long the server is able to find out the IP address. (/etc/hosts or DNS lookups)

### BOOTP setup

For BOOTP setup you need to edit `/etc/bootptab`. Please consult the bootpd(8) and bootptab(5) man pages.

### DHCP setup

There is no need for the DHCP server to be the same as the NFS server, and in most cases, a DHCP server will already be set up. If one is not, however, consult the DHCP mini-HOWTO for further help.

### Finding out hardware addresses

I don't know the hardware address! How can I find it out?

- Boot the kernel disk you made, and watch for the line where the network card is recognized. It usually contains 6 hex bytes, that should be the address of the card.
- Boot the workstation with some OS with TCP/IP networking enabled. Then ping the workstation from the server. Look in the ARP-cache by executing: `/sbin/arp -a`

Next Previous Contents