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.
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!
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.
Ignore any warnings about the file not being a block device, and
proceed anyway. This is an expected warning message.
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".
Unmount and Compress the Root Filesystem
Unmount the root filesystem you just created.
Compress the filesystem file with maximum "gzip"
compression levels.
You should now have "fs_test.img.gz" file.
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.