5.2.4.2. /etc/mtab
The
/etc/mtab
file presents a unique challenge, because it does not contain static information like
fstab
.
The
mtab
file tracks mounted filesystems and therefore its contents change from time to time. We are
particularly interested in the state of
mtab
when the system first starts up, before any filesystems are
mounted. At this point
/etc/mtab
should be empty so we will need to configure a startup script to create an
empty
/etc/mtab
before any filesystems are mounted. But it is not possible to create any files in the
/etc
directory because
/
is read−only at startup. This creates a paradox. We cannot create an empty
mtab
, because
the
/
filesystem is not mounted as writable and we should not mount any filesystems until we have created an
empty
mtab
. In order to sidestep this problem we need to do the following:
Remount
/
as read−write, but use the
−n
option so that mount does not attempt to write an entry to
/etc/mtab
which is read−only at this point.
1.
Create an empty
/etc/mtab
file now that the filesystem is writable.
2.
Remount
/
as read−write again, this time using the
−f
option so that an entry is written into
/etc/mtab
, but
/
is not actually mounted a second time.
3.
5.2.4.3. Device files
The only thing left to do is to create device files. We will need
/dev/ram0
, because that is where the root
filesystem is located. We also need
/dev/fd0
to mount other floppy disks and
/dev/null
for use by
some of the system commands.
5.3. Construction
5.3.1. Install utilities from e2fsprogs
Download the e2fsprogs source code package from http://sourceforge.net/projects/e2fsprogs/
bash# cd /usr/src/e2fsprogs−1.35
bash# export CC="gcc −mcpu=i386"
bash# ./configure −−host=i386−pc−linux−gnu
bash# make
bash# cd e2fsck
bash# cp e2fsck.shared ~/staging/sbin/e2fsck
bash# ln −s e2fsck ~/staging/sbin/fsck.ext2
bash# cd ../misc
bash# cp fsck mke2fs ~/staging/sbin
bash# ln −s mke2fs ~/staging/sbin/mkfs.ext2
5.3.2. Install utilities from util−linux
Get the latest util−linux source from ftp://ftp.win.tue.nl/pub/linux−local/utils/util−linux/
bash# cd /usr/src/util−linux−2.12h
Use a text editor to make the following changes to
MCONFIG
:
Change "CPU=$(shell uname −m)" to "CPU=i386"
•
Change "HAVE_SHADOW=yes" to "HAVE_SHADOW=no"
•
bash# ./configure
Pocket Linux Guide
Chapter 5. Checking and Mounting Disks
23