3. Creating the SunPCi root directory

3.1. Making a root directory availabe to the SunPCi card

Since we cannot access any local disks (see preface), we need to boot over the network. This requires our root (/) filesystem to be on the network as well. This means we will have to set up a directory on an NFS server that can be mounted by Linux. This does not have to be a Linux machine (although it has some pro's). In fact, the Sun machine that hosts the SunPCi card will do fine.

Once you have created the root filesystem using one of the methods below, you will need to export it over NFS. You can do this directly from the machine you created the filesystem on, or you can transfer it to another system first. Packing and unpacking the filesystem using tar as root ensures all permissions and file types will be transfered correctly.

For Linux, create an /etc/exports file that looks like this:

/home/sunpci/linix	192.168.0.11(rw,no_root_squash)
For Solaris, set up your /etc/dfs/dfstab this way:
share -F nfs -o rw=@192.168.0.11/32,root=@192.168.0.11/32 /home/sunpci/linux
The rw option should be clear, the no_root_squash (root= under Solaris) will make sure root users on the SunPCi card have actual root permissions on the nfs filesystem as well. The 192.168.0.11 is the address you will later assign to the SunPCi ethernet interface.

There are two ways to create the SunPCi root directry. Either offline on a seperate system (the NFS server for example), or online booting the SunPCi card with a Linux kernel and a temporary root image.

3.2. Creating the directory tree offline

3.2.1. Cloning an existing Linux filesystem

There are several ways to create the directory structure itself. One possibility is to create the SunPCi root directory from a Linux system you are already using. This method is explained in detail in chapter 3 of the NFS-Root-Client Mini-Howto.

3.2.2. Using debootstrap on an existing Debian system

For Debian systems running woody (Debian 3.0), there is even an easier way. The debootstrap script was written especially to accomplish this. On an i386 Debian 3.0+ system, run:

bash# apt-get install debootstrap
bash# mkdir -p /home/sunpci/linux
bash# debootstrap woody /home/sunpci/linux http://ftp.nl.debian.org/debian

You will have to replace the nl part of the URL with your own country code, or omit it when in the USA. A full list of debian mirrors is at http://www.debian.org/mirror/list . Please note that not all mirrors support the http protocol (if so, use ftp:// instead).

Alternativly, you can boot the system first (see next paragraph) and run debootstrap directly from the SunPCi card. You will need Internet access from the network you connect the SunPCi ethernet interface to.

3.2.3. Downloading an already prepared filesystem

Debian 2.x had a ready made filesystem in a base2_2.tgz file. This method is no longer used, and these files are no longer available.

I have prepared a Debian 3.0 base filesystem using debootstrap on November 15, 2001. It is definately outdated by now, so you'd better create one yourself. It is 22MB, and can be downloaded here: base3_0.tgz.

3.3. Creating the directory tree by booting Linux first

This part consists of booting a Linux kernel on the SunPCi card in order to install the base root directory. I used the Debian 3.0 (woody) bootimages for this, and it does work, but since Debian 3.0 was still in the testing phase at that point, the process was not flawless. I do not know if the current woody bootimages work without any problems now. Please E-mail me your experiences. If you can't stomach things going wrong, consider using one of the option in the previous section instead.

3.3.1. Booting up!

This is the fun part. How do you boot a machine that has no floppy drive, no cdrom, and no hard drive you can use? Historically RARP, BOOTP and DHCP come to mind. The SunPCi card BIOS does have the option to use the Net device for booting, but this is quite unhandy. Think about switching the BIOS settings back and forth between booting Linux and Windows. Instead, I went the LOADLIN route.

LOADLIN.EXE is a DOS utility capable of loading a Linux kernel into memory, effectivly leaving the DOS environment completely. In combination with the SunPCi card, LOADLIN can be used from Caldera OpenDOS or the DOS mode of Windows 95/98. Do not try to run LOADLIN in the DOS-box of a Windows OS. This is bound to blow up in your face. Note: there is a way to boot Windows Millennium into DOS mode, although it is not supported by Microsoft.

We are going to need a kernel and a temporary root filesystem. I compiled a pretty decent 2.4.17 kernel. I am providing the .config file in case you want to rebuild it using a more recent kernel source. As a temporary root filesystem, we'll use the root.bin from the Debian 3.0 bootfloppies set at ftp://ftp.nl.debian.org/debian/dists/woody/main/disks-i386/current/images-1.44/root.bin

You can copy LOADLIN.EXE as well as your linux kernel to the DOS filesystem using drive F: of the Caldera OpenDOS environment.

Create a BAT file named linboot.bat which contains 1 line:

loadlin linux root=/dev/ram initrd=root.bin console=ttyS0 console=tty0
I am using ttyS0 as console since the VGA emulation inside Xwindows is too poor to keep up with the amount of text generated by Linux booting up. By using ttyS0, you can connect a serial cable to COM1 of the SunPCi card, and watch the boot from there. Using Solaris connect COM1 with a serial crossover to port B of the Sun and run tip hardwire (or connect it to port A and edit /etc/remote to point hardwire to /dev/term/a). If you use sunpci with the -vga option, you do not need this.

Before going further, let me say 1 more thing about the VGA emulation. You can refresh the screen while running Linux by pressing left Alt + F2 and then left Alt + F1. This switches Linux to tty2 and then back to tty1. You can also use tty3 and tty4 but CDE remaps left Alt + F3 and left Alt + F4. (Gnome remaps left Alt + F2, left Alt + F3 and left Alt + F4 so it is not suitable for this task. Use OpenWindows safely, it does not remap any of these keys.)

Run the batch file! Watch in awe how your SunPCi card boots Linux for the first time.

3.3.2. Creating the root filesystem using the Installation Menu

After booting Linux using the root.bin, you will be presented with a menu based installer. These are the steps that need to be performed.

  1. Configure the Keyboad
  2. Configure the Network
  3. Mount a Previously-Initialized Partition
    Be sure to add a -o nolock option before the server:/path data. This circumvents a problem with lockd and/or statd not being present on the bootfloppy image. (Thanks to Jarek Zuk.)
  4. Configure the Hostname
  5. Install the Base System -> Network -> Woody -> URL
  6. Reboot the System

I did not have much luck mounting my exported NFS directory using bootfloppies version 3.0.15. Any of the above steps can be done manually in tty2 by pressing left Alt + F2, at any time. If the menu based window seems to hang, simply press Ctrl + C and it will restart. The manual steps are:

# ifconfig eth0 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255 up
# route add default gw 192.168.0.1
# echo domain xs4all.nl > /etc/resolv.conf
# echo nameserver 194.109.104.104 >> /etc/resolv.conf
# mount -t nfs -o rw,nolock 192.168.0.2:/home/sunpci/linux /target
# debootstrap --arch i386 woody /home/sunpci/linux http://ftp.nl.debian.org/debian

3.4. Preparing your system for the first NFS boot

The base root filesystem you have created was not designed to be booted directly over NFS. Some changes need to be made for it to work. You can make these changes while running Linux (using the linboot.bat file) from the SunPCi card, or directly on the NFS server.

3.4.1. Changes needed for the NFS boot to work

These changes absolutely need to be made before the first NFS boot is attempted. Things will break if you boot without them.

/etc/hostname
Put your hostname (sunpci in my case) in this file.
 
/etc/fstab
This needs to contain all your filesystems. It should look something like:
	# /etc/fstab: static file system information.
	#
	# <file system>                 <mount point> <type> <options> <dump> <pass>
	192.168.0.2:/home/sunpci/linux  /             nfs    defaults  0      0
	proc                            /proc         proc   defaults  0      0
  
/etc/init.d/rcS
This is the main script that is executed during bootup. If you do not have a Debian system, it might be in a different place. Look in /etc/inittab to find out where. Since the root filesystem is mounted read-only during boot, and only mounted read-write after a fsck pass (which never happens for NFS mounted file systems) it needs to be remounted read-write manually. Add this line somewhere in the beginning of /etc/init.d/rcS :
	mount -av
	

3.4.2. Other required changes

These changes need to be made to the root filesystem at one point in time. They are not required for your system to boot properly, but it doesn't hurt making them prior to that joyous event.

/etc/hosts
I suggest putting at least 3 lines in this file; your SunPCi system, your NFS server and localhost:
	192.168.0.11  sunpci # SunPCi-IIpro card
	192.168.0.2   surian # Solaris 8 machine
	127.0.0.1     localhost
	
/etc/resolv.conf
Fill this with the usual DNS related info:
	domain xs4all.nl
	search xs4all.nl vdberg.org
	nameserver 194.109.104.104
	nameserver 194.109.6.66
	nameserver 194.109.9.99