5. Build A JavaStation-Ready FileSystem

This chapter details how one constructs a filesystem suitable for use on the Linux-running JavaStations.

5.1. Preparing Yourself to Build Your Own Filesystem

Building a filesystem for use with the JavaStations is a time-consuming, but rewarding task for those who undertake it. You will learn more about library dependencies than you ever thought you could, all the time while trying to keep the overall image size as small as possible.

There are two common approaches one can take when rolling a new JavaStation-ready filesystem.

  1. Start with an established distribution's filesystem and whittle down to the core.

  2. Start with an established distribution's "rescue disk" filesystem and add desired functionality.

Which path you take, of course, is entirely up to you. The "rescue disk" build procedure seems to work best though, as more base commands in a rescue disk are statically linked, increasing the starting image size but causing less initial library headaches.

Obviously when building a filesystem in the context of the JavaStation, you will be basing off of an existing Linux/SPARC filesystem. The filesystems that come with the RedHat and Debian distributions are good starting points.

Warning

In the future, you will also need to make sure you base off a filesystem built with compiled 32-bit mode executables, as a 64-bit userland project is presently in progress for 64-bit SPARC Linux kernels.

5.2. Contents of the "/etc/fstab" File

The configuration lines placed into "/etc/fstab" depend on whether you will be using the "NFS-Root" or "Embedded-Root" filesystem configuration.

5.2.1. "NFS-Root" Filesystem fstab

Here is an example of an "/etc/fstab" for an "NFS-Root" boot option.

###
#
your.nfs.server:/path/to/filesystem  /  nfs defaults,rsize=8192,wsize=8192 1 1
#
none                    /proc                   proc    defaults        0 0
###

5.2.2. "Embedded-Root" Filesystem fstab

Here is an example of an "/etc/fstab" for an "Embedded-Root" boot option.

###
#
/dev/ram /     ext2  defaults
#
/proc    /proc    proc  defaults
###

5.3. The "Embedded-Root" Image Creation Procedure

Prepping up the "Embedded-Root" boot image requires a number of extra steps. Due to these extra steps, the "NFS-Root" filesystem option is recommended for beginners to Linux on the JavaStation. You might also try the samples pointed to in this document. Should you still wish to build and embedded image on your own, this section outlines the basic instructions.

Creating the "Embedded-Root" boot image is a 5-Step Procedure:

  1. Prototype Your Filesystem

    This whole chapter deals with rolling your own filesystem. In this step, it is assumed you create your own filesystem, perhaps by prototyping one on a working "NFS-Root" filesystem configuration.

    One thing to keep in mind is that unlike your "NFS-Root" filesystem, the "Embedded-Root" filesystem must fit within the confines of your allocated RAMdisk, generally 4-16 MB. Your maximum size is dependant on the setting of the RAMdisk driver.

  2. Create an Empty File for Your FileSystem

    You now need to create a file-based filesystem "container". This is just a file that is the size of your RAMdisk.

    To create this, try the dd command:

    dd if=/dev/zero of=./fs_test.img bs=1k count=8000 

    Using this example, you now should have an 8 MB file named "fs_test.img". Note: Be sure the count you use matches the RAMdisk size you allocated for in the kernel's RAMdisk driver!

  3. Format your Filesystem "Container"

    Now that you have a "container" for your filesystem, it is time to format it and place a bare filesystem on it.

    In our kernel phase, we added in support for the ext2 filesystem. We'll now format our "container" with this filesystem type.

    mkfs.ext2 ./fs_test.img

    Ignore any warnings about the file not being a block device, and proceed anyway. This is an expected warning message.

  4. Mount the Filesystem "Container" and Write to It

    Now that you have your filesystem container, you can mount it and load your prototyped filesystem on it.

    To mount the container, use the kernel loopback device. Make sure your server's kernel has loopback support enabled and issue a:

    mount -o loop ./fs_test.img /mnt

    Copy your files to the filesystem, and make sure "/etc/fstab" has the RAMdisk entries as described elsewhere in this document.

    To avoid symbolic links being changed into actual copies of files, use a copy tool like "tar" or "cpio" instead of a "cp".

  5. Unmount and Compress the Root Filesystem

    Unmount the root filesystem you just created.

    umount /mnt

    Compress the filesystem file with maximum "gzip" compression levels.

    gzip -v9 ./fs_test.img

    You should now have "fs_test.img.gz" file.

  6. Hook the Root-Filesystem Onto the Back of Your Kernel Image

    Now you must append the filesystem image onto your kernel.

    You do this with a utility program called "piggyback". The piggyback program takes care of the task of appending the two and letting the kernel know where both it and the filesystem begins and ends.

    The "piggyback" program is found in your kernel source tree under <LINUXROOT>/arch/sparc/boot. It might also be found on your favorite ftp.kernel.org site.

    For piggyback to work, it needs your AOUT format kernel image, the System.map file from your kernel source root directory, and the compressed root-filesystem you just created.

    We put it all together with a:

    piggyback vmlinux.aout System.map fs_test.img.gz

    Be sure to backup your kernel image first, as piggyback used the same "vmlinux.aout" filename for output. Check the filesize of your "vmlinux.aout" file after giving this command and you can verify the filesystem has indeed been appended.

Congratulations! You've created an "Embedded-Root" kernel/filesystem boot image.

5.4. Sample FileSystems

Here are some sample filesystems for you to start with.

A filesystem image contributed by Varol Kapton is at: http://javastation-howto.homeip.net/Files/jsroot_varol.tar.gz