Chapter 3. Saving Space
3.1. Analysis
One of the drawbacks in the prototype phase of the project was that the diskset was not all that useful. The
only commands that worked were the ones built into the BASH shell. We could improve our root disk by
installing commands like cat, ls, mv, rm and so on. Unfortunately, we are short on space. The current root
disk has no shared libraries so each utility would have to be statically−linked just like the BASH shell. A lot
of big binaries together with a static shell will rapidly exceed the tiny 1.44M of available disk space. So our
main goal in this phase should be to maximize space savings on the root disk and pave the way for expanded
functionality in the next phase.
3.2. Design
Take another look at the Bootdisk−HOWTO and notice how many utilities can be squeezed onto a 1.44M
floppy. There are three things that make this possible. One is the use of shared libraries. The second is
stripped binaries. And the third is the use of a compressed filesystem. We can use all of these techniques to
save space on our root disk.
3.2.1. Shared Libraries
First, in order to use shared libraries we will need to rebuild the BASH shell. This time we will configure it
without using the
−−enable−static−link
option. Once BASH is rebuilt we need to figure out which
libraries it is linked with and be sure to include them on the root disk. The ldd command makes this job easy.
By typing ldd bash on the command−line we can see a list of all the shared libraries that BASH uses. As long
as all these libraries are copied to the root disk, the new BASH build should work fine.
3.2.2. Stripped Binaries
Next, we should strip any binaries that get copied to the root disk. The manpage for strip does not give much
description of what it does other than to say, "strip discards all symbols from the object files." It seems like
removing pieces of a binary would render it useless, but this is not the case. The reason it works is because a
large number of these discarded symbols are used for debugging. While debugging symbols are very helpful
to programmers working to improve the code, they do not do much for the average end−user other than take
up more disk space. And since space is at a premium, we should definitely remove as many symbols as
possible from BASH and any other binaries before we copy over them to the ramdisk.
The process of stripping files to save space also works with shared library files. But when stripping libraries it
is important to use the
−−strip−unneeded
option so as not to break them. Using
−−strip−unneeded
shrinks the file size, but leaves the symbols needed for relocation intact which is something that shared
libraries need to function properly.
3.2.3. Compressed Root Filesystem
Finally, we can tackle the problem of how to build a compressed root filesystem. The Bootdisk−HOWTO
suggests three ways of constructing a compressed root filesystem using either a ramdisk, a spare hard drive
partition or a loopback device. This project will concentrate on using the ramdisk approach. It seems logical
Chapter 3. Saving Space
12