Nethence Newdoc Olddoc Lab Your IP BBDock  

Warning: those guides are mostly obsolete, please have a look at the new documentation.


Setting up a diskless NetBSD/i386 system
This guide is mainly based on the official one, but I hope, will be much more straighforward and comprehensive, as it is limited for now to the x86 hardware plateforms.
Versions used:
- NetBSD 6.1.3 amd64 for the PXE & NFS server,
- NetBSD 6.1.3 i386 for the diskless system.
Note. If you emulate the diskless system with VMware Server v1.x, ensure you are using only one virtual processor, otherwise the netbsd kernel crashes and reboots in cycles. Donno exactly what is causing that, crappy multiprocessor emulation on that old VMware product I am still using, or a NetBSD bug. But that's not the real issue here.
Preparing the diskless filesystems
Ok let's setup the Unix tree and swap device,
mkdir -p /export/client/root/dev/
mkdir -p /export/client/root/swap/
chmod 700 /export/client/root/swap/
mkdir -p /export/client/root/home/
mkdir -p /export/client/home/
#mkdir -p /export/client/usr/
mknod /export/client/root/dev/console c 0 0
dd if=/dev/zero of=/export/client/swap bs=1024k count=256
chmod 600 /export/client/swap
Note. Fixing swap mount point to 700 and device-as-file permission to 600 otherwise you get a WARNING swap is readable by the world at the diskless system boot time (donno which one exactly is causing it but fixing both at once cannot hurt).
Extract the NetBSD distribution to it,
cd /data/netbsd613x32/ 
tar xvzpf kern-GENERIC.tgz -C /export/client/root/
#tar xvzpf kern-MONOLITHIC.tgz -C /export/client/root/
for set in base.tgz comp.tgz etc.tgz games.tgz man.tgz misc.tgz modules.tgz tests.tgz text.tgz; do
  print $set...\\c
  tar xzphfe $set -C /export/client/root/ && print done
done; unset set
#mv -f /export/client/root/usr/* /export/client/usr/
#touch /export/client/root/usr/NOT_MOUNTED
Note. Using the monolithic kernel isn't mandatory, root on nfs also works with the GENERIC one and it doesn't need the modules for that.
Configure fstab to it knows where to find it,
cd /export/client/root/etc/
cat > fstab <<EOF9
$nfsserver:/export/client/swap none swap sw,nfsmntpt=/swap
$nfsserver:/export/client/root / nfs rw 0 0
$nfsserver:/export/client/home /home nfs rw 0 0
#$nfsserver:/export/client/usr /usr nfs rw 0 0
unset nfsserver
Setup the system so it won't auto-configure the network for now,
cd /export/client/root/etc/
echo client.example.local > myname
echo > mygate
cat > rc.conf <<EOF9
Note. Donno why hostname= won't set the hostname, switching to the /etc/myname method simply fixed it.
Note. Donno why defaultroute= won't work either.
Note. No need to further configure the network as it is done at boot time already.
Setup the IP address (will reference to this from the interface parameters),
cd /export/client/root/etc/
cat > hosts <<EOF9
::1 localhost localhost. localhost localhost. gw.example.local gw client.example.local client nfs.example.local nfs
Setting up the PXE boot
Configure the DHCP daemon to point to the TFTP-server boot loader,
cd /etc/
vi dhcpd.conf
like e.g.,
allow bootp;
ddns-update-style none;
allow unknown-clients;
subnet netmask {
option domain-name "example.local";
option subnet-mask;
option routers;
option domain-name-servers;
option ntp-servers;
# stage 1:
filename "pxeboot_ia32.bin"; # relative to /tftpboot
# stage 2:
next-server; # IP of NFS server
option root-path "/export/client/root"; # path on NFS server
Note. You could also seperate the PXE service to dedicated MAC addresses,
host client {
hardware ethernet 00:0c:29:77:a0:2a;
# stage 1:
cd /etc/
cat dhcpd=yes >> rc.conf
rc.d/dhcpd restart
Configure the TFTP daemon to provide the boot loader,
mkdir -p /tftpboot/
cp /export/client/root/usr/mdec/pxeboot_ia32.bin /tftpboot/
cd /etc/
vi inetd.conf
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot
tftp dgram udp6 wait root /usr/libexec/tftpd tftpd -l -s /tftpboot
Note. Yes both lines are recommended, otherwise you might get some name resolution issues (tftp localhost works while tftp didn't... that was really strange).
/etc/rc.d/inetd restart
The next step is mandatory for the kernel boot to work, as it is provided by NFS directly.
Setting up the NFS share
Setup the shares,
cat >> /etc/exports <<EOF9
/export/client/root -maproot=root:wheel 
/export/client/swap -maproot=root:wheel 
/export/client/home -maproot=nobody:nobody -network= 
#/export/client/usr -maproot=nobody:nobody 
Note. Careful you have to specify the client's IP or use the -network option, which is kind of an issue here for the read-write and client-specitic directories, unless you are considering -ro. Otherwise only the first share would show up.
Ref. exporting more than one directory to the world in one filesystems failed:
Enable the daemons,
cd /etc/
cat >> rc.conf <<EOF9
and apply,
/etc/rc.d/rpcbind restart
/etc/rc.d/mountd restart
/etc/rc.d/nfslocking restart
/etc/rc.d/nfsd restart
if you need to reload the exports file afterwards, on NetBSD it is,
hup mountd
showmount -e
Diskless' first boot
You will enter single user mode as it will find /etc/rc.conf without rc_configured. Create the device files,
wsconsctl -w encoding=fr 
cd /dev/
swapctl -A
swapctl -l
configure RC (doing this on the server side may be easyer),
cd /export/client/root/etc/
cat >> rc.conf <<EOF
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
echo "encoding fr" >> wscons.conf
then back to the diskless system prompt, reboot,
Note. The /swap/ folder needs to exist so you can remotely mount the already prepared swap file through NFS.
Check that you don't have any warnings at system boot time and check that swap is now enabled by default,
swapctl -l
Additional notes
You could also export /home/ instead of /export/client/home/ but this would be rather interesting in a NIS situation.
Diskless NetBSD HOW-TO:
Introduction, Diskless NetBSD HOW-TO:
Introduction (i386-specific), Diskless NetBSD HOW-TO:
Setting up the dhcpd server, Diskless NetBSD HOW-TO:
Setting up the tftpd server, Diskless NetBSD HOW-TO:
Setting up the NFS server, Diskless NetBSD HOW-TO:
Setting up the filesystem, Diskless NetBSD HOW-TO:
Finishing up your installation, Diskless NetBSD HOW-TO:

(obsolete, see the new doc)