| Domain | My Life | Resume | Documents | Calculators | Miscellaneous | Links | Projects | Site Methodology | Site Map |
|
Documentation
From my personal library, The Internet |
| Man Pages | RFC | HOWTO | SDK | Software |
Root over nfs clients & server Howto.Hans de Goede hans@highrise.nlv1.0 30 March 1999Howto setup a server and configure clients for diskless operation from a network.
1. Introduction
2. Basic principle
3. Preparing the server
4. Adding workstations
5. Added bonus: booting from cdrom
6. Thanks
7. Comments1. IntroductionThis howto is also available at - http://xmame.retrogames.com/hans. This document describes a setup for nfs over root. This document differs from the other root over nfs howto's in 2 ways:
This document is heavily based on a RedHat-5.2 system. Quite a bit of prior linux sysadmin experience is assumed in this howto, if you have that it shouldn't be a problem to addept this solutions to other distributions. 1.1 CopyrightWell here's the standard howto legal stuff: This manual may be reproduced and distributed in whole or in part, without fee, subject to the following conditions:
Exceptions to these rules may be granted for academic purposes: Write to the author and ask. These restrictions are here to protect us as authors, not to restrict you as learners and educators. 1.2 Changelog
2. Basic principleAs already said with this setup the clients share basicly the entire root-fs with the server. But the clients ofcourse only get read access to it. This is basicly how things work. 2.1 Things can't be that simpleUnfortunatly things aren't that simple, there are a couple of problems the overcome with this simple setup. Each ws needs its own writable copy of a number of dirsA normal linux setup needs to have write access to the following dirs:
There are 3 solutions for this, of which one will only work for /dev:
As you can see, there are a number of ways to solve this problem. For the rest of this Howto the following choices are assumed:
Write access to /home might be neededNot really a problem in every unix client/server setup /home is mounted rw from the server so we'll just do that ;) How does a ws find out it's ip so that it can communicate with the server?Luckily for us, this problem has already been solved and the linux kernel has support for 2 ways of autoconfiguration of the ip-address:
Rarp is the easiest to setup, bootp is the most flexible. Since most bootroms only support bootp that's what we'll use. What about ws sepecific configurationOn redhat most system dependent config files are already in /etc/sysconfig We'll just move those which aren't there and add symlinks. Then we mount a seperate /etc/sysconfig on a per ws basis. This is really the only distribution dependent part on other distributions you can just create a sysconfig dir, move all config files which can't be shared there and create symlinks. Also /etc/rc.d/rc3.d, or symilar on other dists, might need to be different for the server resp the workstations. Assuming that all ws run the same services in runlevel 3, we'll just create a seperate 3th runlevel for the workstations and the server:
Miscelancious problemsThere are a few problems left:
3. Preparing the serverNow it's time to prepare the server to serve diskless clients. 3.1 Building a kernelThe first thing todo is build a kernel with the nescesarry stuff in to support root over nfs. Take the following steps to build your kernel:
3.2 Creating and populating /tftpboot, making symlinks for /tmp etc.The next step is to create and populate /tftpboot The automagic partThis is all handled by a big script since putting a long list of commands into this howto seemed pretty useless to me. If you want todo this manual just read the script and type it in as you go ;) This setup script thus some nasty things like nuke /tmp, temporary kill syslog, umount /proc. So make sure that noone is using the machine during this, and that X isn't running. Just making sure your the only one logged in on a text-console is enough, no need to change runlevels. DISCLAIMER: this script has been tested but nevertheless if it messes up your server your on your own. I can take no responsibility what so ever. Lett me repeat this howto is only for experienced linux sysadmins. Also this is script is designed to be run once and I really mean once. Running it twice will nuke: /etc/fstab, /etc/X11/XF86Config, /etc/X11/X and /etc/conf.modules. Now with that said, just cut and paste the script make it executable, execute it and pray to the holy penguin that it works ;)
#!/bin/sh
SERVER_NAME=`hostname -s`
###
echo creating /etc/rc.d/rc.ws
#this basicly just echos the entire script ;)
echo "#root on nfs stuff
SERVER=$SERVER_NAME
#we need proc for mtab, route etc
mount -t proc /proc /proc
IP=\`ifconfig eth0|grep inet|cut --field 2 -d ':'|cut --field 1 -d ' '\`
#if the first mount fails we're probably the server, or atleast something is
#pretty wrong, so only do the other stuff if the first mount succeeds
mount \$SERVER:/tftpboot/\$IP/sysconfig /etc/sysconfig -o nolock &&
{
#other mounts
mount \$SERVER:/home /home -o nolock
mount \$SERVER:/ /\$SERVER -o ro,nolock
#/var
echo Creating /var ...
mke2fs -q -i 1024 /dev/ram1 1024
mount /dev/ram1 /var -o defaults,rw
cp -a /tftpboot/var /
#network stuff
. /etc/sysconfig/network
HOSTNAME=\`cat /etc/hosts|grep \$IP|cut --field 2\`
route add default gw \$GATEWAY
ifup lo
}
#restore devfs settings
/etc/rc.d/rc.devfs restore /etc/sysconfig
umount /proc" > /etc/rc.d/rc.ws
###
echo splitting runlevel 3 for the client and server
mv /etc/rc.d/rc3.d /etc/rc.d/rc3.server
cp -a /etc/rc.d/rc3.server /etc/rc.d/rc3.ws
rm /etc/rc.d/rc3.ws/*network
rm /etc/rc.d/rc3.ws/*nfs
rm /etc/rc.d/rc3.ws/*nfsfs
rm /etc/rc.d/rc3.ws/S99local
ln -s /etc/sysconfig/rc.local /etc/rc.d/rc3.ws/S99local
ln -s /etc/rc.d/rc3.server /etc/sysconfig/rc3.d
ln -s /etc/sysconfig/rc3.d /etc/rc.d/rc3.d
###
echo making tmp a link to /var/tmp
rm -fR /tmp
ln -s var/tmp /tmp
###
echo moving various files around and create symlinks for them
echo mtab
/etc/rc.d/init.d/syslog stop
umount /proc
touch /proc/mounts
mount /proc
/etc/rc.d/init.d/syslog start
rm /etc/mtab
ln -s /proc/mounts /etc/mtab
echo fstab
mv /etc/fstab /etc/sysconfig
ln -s sysconfig/fstab /etc/fstab
echo X-config files
mkdir /etc/sysconfig/X11
mv /etc/X11/X /etc/sysconfig/X11
ln -s ../sysconfig/X11/X /etc/X11/X
mv /etc/X11/XF86Config /etc/sysconfig/X11
ln -s ../sysconfig/X11/XF86Config /etc/X11/XF86Config
echo conf.modules
mv /etc/conf.modules /etc/sysconfig
ln -s sysconfig/conf.modules /etc/conf.modules
echo isapnp.conf
mv /etc/isapnp.conf /etc/sysconfig
ln -s sysconfig/isapnp.conf /etc/isapnp.conf
###
echo creating a template dir for the ws directories
echo /tftpboot/template
mkdir /home/tftpboot
ln -s home/tftpboot /tftpboot
mkdir /tftpboot/template
mkdir /$SERVER_NAME
echo root
ln -s / /tftpboot/template/root
echo sysconfig
cp -a /etc/sysconfig /tftpboot/template/sysconfig
rm -fR /tftpboot/template/sysconfig/network-scripts
ln -s /$SERVER_NAME/etc/sysconfig/network-scripts \
/tftpboot/template/sysconfig/network-scripts
echo NETWORKING=yes > /tftpboot/template/sysconfig/network
echo `grep "GATEWAY=" /etc/sysconfig/network` >> /tftpboot/template/sysconfig/network
echo "/dev/nfsroot / nfs defaults 1 1" > /tftpboot/template/sysconfig/fstab
echo "none /proc proc defaults 0 0" >> /tftpboot/template/sysconfig/fstab
echo "#!/bin/sh" > /tftpboot/template/sysconfig/rc.local
chmod 755 /tftpboot/template/sysconfig/rc.local
rm /tftpboot/template/sysconfig/rc3.d
ln -s /etc/rc.d/rc3.ws /tftpboot/template/sysconfig/rc3.d
rm /tftpboot/template/sysconfig/isapnp.conf
echo var
cp -a /var /tftpboot/var
rm -fR /tftpboot/var/lib
ln -s /$SERVER_NAME/var/lib /tftpboot/var/lib
rm -fR /tftpboot/var/catman
ln -s /$SERVER_NAME/var/catman /tftpboot/var/catman
rm -fR /tftpboot/var/log/httpd
rm -f /tftpboot/var/log/samba/*
for i in `find /tftpboot/var/log -type f`; do cat /dev/null > $i; done
rm `find /tftpboot/var/lock -type f`
rm `find /tftpboot/var/run -type f`
echo /sbin/fsck.nfs
echo "#!/bin/sh
exit 0" > /sbin/fsck.nfs
chmod 755 /sbin/fsck.nfs
echo all done
Manual adjustments to some filesNow we need to make a few manual adjustments to the server:
3.3 Exporting the appropriate file systems and setting up bootpThe server must ofcourse export the appropriate filesystems and asign the ip addresses to the clients. Exporting the appropriate file systemsWe need to export some dir's for the workstations so for the situation here at the university I would add the following to /etc/exports:
/ *.st.hhs.nl(ro,no_root_squash) /home *.st.hhs.nl(rw,no_root_squash) Ofcourse use the apropriate domain ;) and restart nfs by typing:
/etc/rc.d/init.d/nfs restart Note for knfsd users: knfsd doesn't allow you to have multiple exports on one partition with different permissions. Also knfsd doesn't allow clients to go past partition boundaries for example if a client mounts / and /usr is a different partition it won't have access to /usr. Thus if you use knfsd, at least /home should be on a different partition, the server prepare script already puts /tftpboot in /home so that doesn't need a seperate partition. If you've got any other partitions your clients should have access to export them seperatly and add mount commands for them to /etc/rc.d/rc.ws. Setting up bootp
4. Adding workstationsNow that the server is all done, we can start adding workstations. 4.1 Creating a boot disk or bootromYou'll need ot create a bootrom and / or a bootdisk to boot your workstation. Creating a bootdiskEven if you wish to use a bootrom its wise to first test with a bootdisk, to create a boot disk just type:
dd if=/<path-to-zImage>/zImage of=/dev/fd0 Creating a bootromThere are a few free package's out there to create bootroms:
About the roms themselves. Most cards take ordinary eproms with an 28 pins dip housing. These eproms come in size upto 64kB. For most cards you'll need 32kB eproms with netboot. Some cards drivers will fit into 16kB but the price difference of the eproms is minimal. These eproms can be burned with any ordinairy eprom burner. 4.2 Creating a ws dirJust copy over the template by typing:
cd /tftpbootcp -a template <ip> You could of course also copy over the dir of a workstation with identical mouse, graphicscard and monitor and ommit the configuration in step 5.4. 4.3 Add entries to /etc/bootptab and /etc/hostsEdit /etc/bootptab and add an entry for your test ws, an example entry is:
nfsroot1:hd=/tftpboot:vm=auto:ip=10.0.0.237:\ :ht=ethernet:ha=00201889EE78:\ :bf=bootImage:rp=/tftpboot/10.0.0.237/root Replace nfsroot1 by the hostname you want your ws to have. Replace 10.0.0.237 by the ip you want your ws to have (do this twice) and replace 00201889EE78 by the MAC-ADDRESS of your ws. If you don't know the MAC-ADDRESS of the ws, just boot it with the just created boot disk and look for the MAC-ADDRESS in the boot messages. There's a chance bootpd is already running so just to make sure try to restart it by typing:
killall -HUP bootpd Don't worry if it fails, that just means it wasn't running, inetd will start it when asked too. 4.4 Booting the ws for the first timeJust boot the ws from the bootdisk. This should get you a working ws in textmode, with the exact same setup as your server except for the ip-nr and the running services. Even if you want to use a bootprom it's wise to first test with the bootdisk, if that works you can try to boot with the bootrom see the bootroms documentation for more info. 4.5 Set the ws specific configuration.Now it's time to configure any ws specific settings:
5. Added bonus: booting from cdromMuch of the above also goes for booting from cdrom. Since I wanted to document howto boot from cdrom anyway, I document it in here to avoid typing a lott of the same twice. Why would one want to boot a machine from cd-rom? Booting from cdrom is interesting everywhere where one wants to run a very specific application, like a kiosk, a library database program or an intenet cafe, and one doesn't have a network or a server to use a root over nfs setup. 5.1 Basic PrincipleThe basic principle is wants again simple, boot with a cdrom as root. To make this possible we'll use the rockridge extension to put a unix like filesystem on a cd and the Eltorito extension to make cd's bootable. Things can't be that simpleOfcourse this setup also has a few problems. most are the same as above:
5.2 Creating a test setup.Now that we know what we want todo and how, it's time to create a test setup:
5.3 Creating the cdCreating a boot imageFirst of all boot into the workign partition. To create a bootable cd we'll need an image of a bootable floppy. Just dd-ing a zimage doesn't work since the loader at the beginning of the zimage doesn't seem to like the fake floppydrive a bootable cd creates. So we'll use syslinux instead.
Creating the iso imageNow that we have the boot image and an install that can boot from a readonly mount it's time to create an iso image of the cd:
Verifying the iso image
Writing the actual cdAssuming that you've got cdrecord installed and configured for your cd-writer type:
cdrecord -v speed=<desired writing speed> dev=<path to your writers generic scsi device> boot.iso 5.4 Boot the cd and test itWell the title of this paragraph says it all ;) 6. Thanks
7. CommentsComments suggestions and such are welcome. They can be send to Hans de Goede at: j.w.r.degoede@et.tudelft.nl |