2004-10-14-1845Z


After a lot of futzing around back-and-forth, I am using an nfsroot of the server's own root, mounted read-only... and it works! Here's my new boot default in /tftpboot/pxelinux.cfg/default:

DEFAULT vmlinuz ip=dhcp root=/dev/nfs nfsroot=/ init=/etc/pxeclient.init panic=5

Here's /etc/pxeclient.init:

#!/bin/bash
exec </dev/console >/dev/console 2>/dev/console
PATH=/bin:/sbin:/usr/bin:/usr/sbin
ramfs() {
 dd if=/dev/zero of=/dev/ram$1 bs=1024 count=8192 &>/dev/null
 mke2fs -q /dev/ram$1 &>/dev/null
 mount -n -o rw /dev/ram$1 $2 &>/dev/null
}
echo Setting up ramdisks...
ramfs 0 /tmp
chmod 1777 /tmp
ramfs 1 /mnt/tmp/etc
ramfs 2 /mnt/tmp/var
ramfs 3 /mnt/tmp/home
mount -n -t proc proc /proc &>/dev/null
#echo Mount status: $(</proc/mounts) # FIXME debugging only
cp -a /etc /mnt/tmp
#echo Home directories: /home/* # FIXME debugging only
cp -a /home/internet /mnt/tmp/home
# now overwrite necessary files with client configurations
cp -af /ref/client/* /mnt/tmp
umount /mnt/tmp/*
mount -n -o rw /dev/ram1 /etc
mount -n -o rw /dev/ram2 /var
mount -n -o rw /dev/ram3 /home
cp -f /proc/mounts /etc/mtab
mount -o rw,gid=5,mode=620 -t devpts devpts /dev/pts
# define bootserver
for declaration in $(grep -v '^#' /proc/net/pnp | sed -e 's/ /=/'); do
 declare $declaration
done
netroot=$(echo $bootserver | cut -d '.' -f 1,2,3)
gateway=$netroot.1
mount -t nfs $bootserver:/opt /opt
route add default gw $gateway
export bootserver gateway
#/bin/bash -l # FIXME debugging only
exec /sbin/init

And /opt/bootlocal.sh, which is the same as rc.local on RH-style systems:

#!/bin/bash
# put other system startup command here
[ -z "`pidof syslogd`" ] && /sbin/syslogd

# if dhcpd3 didn't start yet, try again here [ -z "`pidof dhcpd3`" ] && /etc/init.d/dhcp3-server restart [ -z "`pidof dhcpd3`" ] && echo "Still no DHCP service running!" >&2

# if httpd isn't running, attempt to start it here [ -z "`pidof httpd`" ] && /etc/init.d/httpd restart [ -z "`pidof httpd`" ] && echo "Still no HTTP service running!" >&2

# find out who we are declare $(ifconfig eth0 | awk '$2 ~ "^addr:" {print $2}' | sed -e 's/:/=/') if [ "$addr" ]; then echo Determined address to be: $addr >&2 hostname=$(grep "^$addr\>" /etc/hosts | awk '{print $2}') if [ "$hostname" ]; then echo Setting hostname to $hostname >&2 hostname $hostname fi # did we lose our default route? if so, fix it if ! [ "$(awk '$2 ~ "00000000"' /proc/net/route)" ]; then net=$(echo $addr | cut -d '.' -f 1,2,3) gateway=$net.1 # not always true, but in my case it is echo Setting default gateway to $gateway >&2 route add default gw $gateway fi fi

# make reboot "safe" for unattended shop su - internet -c startx &

Sloppy as it may look, you don't see a single hardcoded IP address, do you? Well, they're hardcoded somewhere, but not in those scripts, heheh... /etc/hosts and /etc/dhcp3/dhcpd.conf is where all the nasty hardcoding can be found.

I avoid having a completely separate filesystem for the nfsroot by having /ref/client/etc contain only files that have to be different than the server's, and overwriting the client's ramdisk with those files after copying all of /etc over. I was going to do the same with /var, but that tree can be unpredictably large, so I made a full copy under /ref/client and zeroed out most of the files.

The system still needs a lot of tweaking... and my third system freezes once anything tries to read from /dev/mouse (as in starting Xwindows), so I'm going to have to rebuild the kernel with the mouse as a module to see if I can solve that problem. Google shows many people having had that problem, but I haven't found a single good answer. What bugs me is that the system in question is identical to the master workstation, being one of those two Wal-mart.com specials I bought a couple of months or so ago. If it works on this one, why not on that?

In other news... as soon as I got my payment for that last job, I went to MelSobel.com and bought that used B&L I've had my eye on. I've given up on getting into the genetics engineering industry by any normal method; I got into electronics, and then into computer programming, by doing it on my own first and making a name for myself. That's the way I'm going to go about genetics too. We'll see how it works, won't we?

Back to blog or home page

last updated 2013-01-10 20:32:15. served from tektonic.jcomeau.com