(M)  s i s t e m a   o p e r a c i o n a l   m a g n u x   l i n u x ~/ · documentação · suporte · sobre


5. Build A JavaStation-Ready FileSystem

This chapter describes 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.


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. They have been contributed by various JavaStation users. Warning: As of the time of this revision (May 3rd, 2001), these files are now heavily out of date, and may hold older versions of applications that have known security flaws. Use these only as a starting point, not in a production environment! If you'd like to see new versions of filesystems here, please contribute filesystems to include, or eel free to donate the HOWTO author a cheap SPARC system to build one on.

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

This image was based on RedHat 6/SPARC. It has the Xfree 3.3.5 framebuffer server dated 19990823, but only works with Krups. If you are working with a Mr. Coffee unit, you must substitute the other X server discussed later in this HOWTO.

5.4.1. Outside Sample Filesystems

Of course, other filesystems and tools exist outside this document, and have been used by JavaStation users. Here are a few that were reported on the sparclinux mailing list as having been used.

  1. http://busybox.lineo.com (a single executable which has dozens of common unix tool functions built in)

  2. http://www.ultralinux.org/js (Jim Mintha's filesystems)