A.2.2. Creating space for the program
Probably the easiest way to create more space for the mp3blaster program is to mount an additional storage
device. There are several choices for mount points. So far
/usr
,
/home
and
/opt
are all empty directories
and any one of them could be used to mount a floppy, CD−ROM or additional compressed ramdisk image.
The
/usr
directory is a logical choice for a place to put an application, but what about the choice of media?
Mp3blaster and its required libraries are too big to fit on a 1.44M floppy and burning a CD−ROM seems like
a lot of work for one little program. So given these constraints, the best choice would be to put the program on
a compressed floppy.
A.2.2.1. Mounting additional compressed floppies
Mounting CDs and uncompressed diskettes is easy, but what about loading compressed images from floppy
into ramdisk? It will have to be done manually, because automatic mounting of compressed floppies only
works for the root diskette. And using mount /dev/fd0 will not work because there is no filesystem on the
diskette, there are only the contents of a gzip file. The actual filesystem is contained inside the gzip file. So
how can we mount the filesystem buried beneath the gzip file? This puzzle can be solved by examining at the
steps used to create the familiar compressed root disk floppy.
A ramdisk is created, mounted and filled with files.
1.
The ramdisk device is unmounted.
2.
The contents of the ramdisk are dumped to an image file using dd.
3.
The image file is compressed with gzip.
4.
The compressed image file is written to floppy with dd.
5.
If that is how the compressed image makes its way from ramdisk to compressed floppy, then going from
compressed floppy to ramdisk should be as simple as running through the steps in reverse.
The compressed image file is read from floppy with dd.
1.
The image file is uncompressed with gunzip.
2.
The contents of the image file are dumped into ramdisk using dd.
3.
The ramdisk device is mounted.
4.
The files are available.
5.
We can cut out the intermediate image file by using a pipe to combine dd and gunzip like this: dd if=/dev/fd0
| gunzip −cq > /dev/ram1
. Now the compressed floppy goes straight into ramdisk, decompressing on the fly.
A.2.2.2. Root disk support for additional ramdisks
We already have kernel support for ramdisks, because we are using a compressed root disk, but we will need
to create more ramdisks in
/dev
. Typically the kernel supports eight ramdisks on
/dev/ram0
through
/dev/ram7
with
ram0
being used for the rootdisk. The
devices.txt
file included in the Linux source
code documentation will be helpful for matching devices to their major and minor numbers.
A.2.3. Accessing audio files
The sample mp3 file that we will be using in our example is small enough to fit on an uncompressed floppy
disk so that there is no need to burn a CD. However, serious music lovers may want to have the capability to
mount a custom CD−ROM full of tunes and that option will require support for additional hardware.
Pocket Linux Guide
Appendix A. Hosting Applications
49