#!/rd/bin/sh # # /sbin/init for diskless workstations # Copyright (c) 2000, 2003, 2004 by Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 23-Dec-00, Jamie Zawinski # # This file is run by the kernel from a ramdisk file system. The kernel # should invoke this as the first thing. It mounts stuff, then runs init. # # The root file system on this ramdisk will remain the kiosk's root # directory (read-only.) This script NFS mounts a few directories to # fill in the dangling symlinks, then invokes init to finish booting. # # expects SERVER= and ID= to be passed on the kernel command line. # SERVER is IP of the NFS server to use; ID is the name of the sub-directory # to mount as this particular kiosk's writable (non-shared) file system. # The programs in /ro/bin are symlinks to busybox, an all-in-one shell # program. # First, make sure the boot ramdisk (root file system) is writable. # (/proc needs to be mounted first, in order for this to work) /rd/bin/mount -t proc proc /proc /rd/bin/mount -t rootfs rootfs -o remount,rw / # first mount various vital directories from the NFS server. # /ro is the root directory shared between the server and clients.. # /ro2 is the root directory shared between all clients (the pieces # where the clients differ from the server.) # /rw is the per-client writable directory; each client has its own. # /rd/bin/mount -t nfs -r -o nolock $SERVER:/ /ro /rd/bin/mount -t nfs -r -o nolock $SERVER:/home/guest/share /ro2 /rd/bin/mount -t nfs -o nolock $SERVER:/home/guest/$ID /rw # We needed a handful of devices in /dev even before mounting anything. # Now that the mounts are up, we can use the server's fully-populated dev. # but devices are still open in our /dev, so just rename it out of the # way, and then turn /dev into a symlink to the server's version. # /rd/bin/mv /dev rd/dev #/rd/bin/ln -s rw/dev /dev /rd/bin/mkdir /dev /rd/bin/mount -t nfs -o nolock $SERVER:/home/guest/$ID/dev /dev # Now invoke "init" and complete the boot-up with server-loaded files. # The argument "#" is what the kernel passes as the runlevel to tell # init to read the "initdefault" entry in /etc/inittab. # #/rd/bin/sh exec /sbin/init '#'