Chapter 5. Checking and Mounting Disks
5.1. Analysis
In the previous chapter we added many new commands by installing coreutils and as a result the root disk has
a lot more functionality. But there are still a few things lacking. One thing that really stands out is that there
was no way to mount disks. In order to get a read−write root filesystem we had to resort to passing the
rw
kernel parameter at the
grub>
prompt. This is fine for an emergency situation, but a normal system boot
process should do things differently.
Most GNU/Linux distributions take several steps to mount filesystems. Watching the boot process or digging
into the startup scripts on one of the popular Linux distributions reveals the following sequence of events:
The kernel automatically mounts the root filesystem as read−only.
1.
All local filesystems are checked for errors.
2.
If filesystems are clean, root is remounted as read−write.
3.
The rest of the local filesystems are mounted.
4.
Network filesystems are mounted.
5.
So far our Pocket Linux system can do step one and that is it. If we want to have a professional looking boot /
root diskset we will have to do better than one out of five. In this phase of the project we will work on steps
two and three. Steps four and five can wait. Since this is a diskette−based system, there really are no other
filesystems to mount besides root.
Taking into account all of the above information, the goals for this phase are defined as follows:
A way to check filesystem integrity.
•
The ability to mount filesystems.
•
A script to automate checking and mounting of local filesystems.
•
5.2. Design
5.2.1. Determining necessary utilities.
We can use the Filesystem Hierarchy Standard (FHS) document to help find the names of utilities we need
and where they reside in the directory structure. The FHS
/sbin
directory lists fsck and something called
fsck.*
for checking filesystems. Since we are using a Second Extended (ext2) filesystem the fsck.* becomes
fsck.ext2
for our purposes. Mounting filesystems is done using the commands mount and umount in the
/bin
directory. However, the name of a script to automatically mount local filesystems cannot be found. On
most systems this type of script is in the
/etc
directory, but while FHS does list requirements for
/etc
, it
does not currently make recommendations for startup scripts. Several GNU/Linux distributions use
/etc/init.d
as the place to hold startup scripts so we will put our filesystem mounting script there.
5.2.2. Finding source code
In the previous chapter we used manpages to help us find source code. In this chapter we will use a tool called
the Linux Software Map (LSM). LSM is a database of GNU/Linux software that tracks such things as package
name, author, names of binaries that make up the package and download sites. Using an LSM search engine
Chapter 5. Checking and Mounting Disks
21