EasyManua.ls Logo

Linux Pocket Linux Guide User Manual

Default Icon
67 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #29 background image
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

Table of Contents

Question and Answer IconNeed help?

Do you have a question about the Linux Pocket Linux Guide and is the answer not in the manual?

Linux Pocket Linux Guide Specifications

General IconGeneral
TitleLinux Pocket Guide
AuthorDaniel J. Barrett
PublisherO'Reilly Media
FormatPaperback
LanguageEnglish

Summary

Legal Information

Copyright and License

Legal text regarding document usage and permissions.

Disclaimer

Legal text disclaiming warranties and responsibilities for document use.

Introduction

About Pocket Linux

Overview of the guide's purpose and target audience.

Prerequisite Skills

Lists necessary skills for following the guide.

Project Format

Explains the chapter structure: Analysis, Design, Construction, Implementation.

Chapter 1: Project Initiation

The Goal of Pocket Linux

Outlines the objectives and constraints of the Pocket Linux project.

Working Within The Constraints

Discusses the limitations and advantages of the project's design.

Chapter 2: A Simple Prototype

2.1. Analysis

Defines the goals for the initial minimal working system.

2.2. Design

Outlines the components needed for a basic boot/root disk set.

2.2.1. Simplification

Focuses on essential components, ignoring complexity.

2.2.2. Boot Disk

Details requirements for the boot disk, including GRUB and kernel.

2.2.3. Root Disk

Describes requirements for the root disk, including BASH and /dev files.

2.3. Construction

Steps for building the boot and root disk floppies.

2.3.1. Prepare the boot disk media

Instructions for formatting and mounting the boot diskette.

2.3.5. Build the Linux kernel

Steps for configuring and compiling the Linux kernel.

2.3.9. Build BASH

Compiling and stripping the BASH shell for the root disk.

2.4. Implementation

Steps to start and test the prototype system.

2.4.1. System startup

Detailed instructions to boot the Pocket Linux system.

Chapter 3: Saving Space

3.1. Analysis

Discusses limitations of the prototype and goals for space saving.

3.2. Design

Outlines techniques for space saving: shared libraries, stripped binaries, compressed filesystem.

3.2.1. Shared Libraries

Rebuilding BASH to use shared libraries.

3.2.3. Compressed Root Filesystem

Using a ramdisk approach for a compressed filesystem.

3.3. Construction

Steps for building the compressed root filesystem using a ramdisk.

3.3.2. Rebuild the BASH shell

Reconfiguring BASH without static linking.

3.3.6. Compress the ramdisk image

Unmounting, dumping, and compressing the ramdisk.

3.4. Implementation

Steps to boot and test the space-optimized system.

3.4.1. System startup

Booting the system with the compressed root disk.

Chapter 4: Some Basic Utilities

4.1. Analysis

Discusses the need to add more utilities to the root disk.

4.2. Design

Plans for adding common external commands like cat, ls, mkdir, rm.

4.2.1. Determining Required Commands

Using FHS to identify necessary commands.

4.2.4. Downloading Source Code

Instructions for downloading package source code.

4.3. Construction

Steps for building and installing new utilities.

4.3.1. Create a staging area

Setting up a temporary directory for building.

4.3.3. Install binaries from GNU coreutils

Compiling and installing core utilities.

4.3.6. Create a compressed root disk image

Compressing the updated root filesystem.

4.4. Implementation

Steps to boot and test the system with new utilities.

4.4.1. System startup

Booting the system with a read-write root filesystem.

4.4.2. Testing new commands

Verifying the functionality of newly added utilities.

Chapter 5: Checking and Mounting Disks

5.1. Analysis

Discusses the need for disk mounting and checking capabilities.

5.2. Design

Planning to implement fsck and mount utilities.

5.2.1. Determining necessary utilities

Identifying fsck, mount, umount based on FHS.

5.2.3. Automating fsck and mount

Designing a script to check and mount filesystems.

5.2.4. File dependencies

Identifying necessary files like /etc/fstab and /dev entries.

5.2.4.1. /etc/fstab

Creating the fstab file for filesystem configuration.

5.3. Construction

Steps for installing utilities and creating configuration files.

5.3.1. Install utilities from e2fsprogs

Compiling and installing fsck and mke2fs.

5.3.2. Install utilities from util-linux

Compiling and installing mount, umount, and others.

5.3.6. Create the fstab and mtab files

Setting up filesystem configuration and tracking files.

5.3.7. Write a script to check and mount local filesystems

Creating the `local_fs` startup script.

5.3.8. Create a compressed root disk image

Compressing the updated root filesystem.

5.4. Implementation

Steps to boot and test the system with mounting capabilities.

5.4.1. System startup

Booting the system and checking startup scripts.

5.4.2. Test the local_fs script

Verifying the automated filesystem mounting script.

Chapter 6: Automating Startup & Shutdown

6.1. Analysis

Discusses improving system startup, shutdown, and manual processes.

6.2. Design

Planning to automate boot parameters, use init daemon, and implement graceful shutdown.

6.2.1. Determining necessary utilities

Identifying init daemon, shutdown, halt, reboot.

6.2.4. Designing a simple GRUB configuration file

Creating `menu.lst` for automated booting.

6.2.5. Outlining start-up scripts

Planning System V style init scripts.

6.3. Construction

Steps for creating startup scripts and configuring the system.

6.3.1. Create a GRUB configuration file

Writing the `menu.lst` file.

6.3.3. Create /etc/inittab file

Configuring the init daemon's behavior.

6.3.4. Create /etc/init.d/rc script

Creating the main runlevel script.

6.3.5. Modify /etc/init.d/local_fs script

Adapting the mounting script for start/stop.

6.3.8. Create rcN.d directories and links

Organizing startup scripts into runlevel directories.

6.4. Implementation

Steps to boot and verify automated startup/shutdown.

6.4.1. System Startup

Booting the system with automated configuration.

6.4.2. Verify success of startup scripts

Checking if filesystems are mounted and hostname is set.

6.4.3. System shutdown

Performing a graceful system shutdown.

Chapter 7: Enabling Multiple Users

7.1. Analysis

Discusses moving from single-user to multi-user mode.

7.2. Design

Planning for multi-user capability and virtual consoles.

7.2.1. The login process

Outlining the steps for user login.

7.2.3. Creating support files

Preparing necessary configuration files and device nodes.

7.2.3.1. Device nodes

Creating /dev entries for virtual consoles.

7.2.3.3. /etc/passwd

Creating a minimal passwd file for users.

7.2.3.5. Conventions

Guidelines for user/group naming and ID assignment.

7.2.4. Dependencies

Identifying libraries required for login, like libnss_files.

7.3. Construction

Steps for implementing multi-user support.

7.3.2. Modify inittab for multi-user mode

Configuring `inittab` for multiple virtual terminals.

7.3.3. Create tty devices

Creating device nodes for virtual terminals.

7.3.4. Create support files in /etc

Creating essential configuration files like `nsswitch.conf`.

7.3.6. Set directory and file permissions

Applying appropriate permissions for multi-user security.

7.3.7. Create the root disk image

Compressing the system with multi-user support.

7.4. Implementation

Steps to boot and test multi-user features.

7.4.2. Add a new user to the system

Creating a new user account and group.

Chapter 8: Filling in the Gaps

8.1. Analysis

Identifying missing commands according to FHS, like `more`, `ps`, `sed`, `ed`.

8.2. Design

Planning to add the missing commands, including a custom `more` script.

8.2.1. more

Designing a simple shell script to emulate the `more` command.

8.2.3. ps, sed & ed

Identifying sources for `ps`, `sed`, and `ed` packages.

8.3. Construction

Steps for implementing the missing utilities.

8.3.1. Write a "more" script

Creating the shell script for the `more` command.

8.3.3. Install ps

Compiling and installing the `ps` utility.

8.3.4. Install sed

Compiling and installing the `sed` utility.

8.3.5. Install ed

Compiling and installing the `ed` editor.

8.3.7. Ensure proper permissions

Setting permissions for the new utilities.

8.3.8. Create the root disk image

Compressing the system with the new utilities.

8.4.2. Test the "more" script

Using the custom `more` script with `dmesg` and `local_fs`.

8.4.3. Use ps to show running processes

Demonstrating the `ps` command.

8.4.4. Run a simple sed script

Using `sed` to modify `/etc/passwd`.

Chapter 9: Project Wrap Up

9.1. Celebrating Accomplishments

Summarizes the achievements of the project.

9.2. Planning Next Steps

Discusses future expansion possibilities for Pocket Linux.

Appendix A: Hosting Applications

A.1. Analysis

Discusses expanding Pocket Linux to run applications like mp3blaster.

A.2. Design

Planning for audio hardware support, mp3blaster space, and audio file access.

A.2.1. Support for audio hardware

Kernel and /dev configuration for sound cards.

A.2.1.1. Kernel support for audio

Building a kernel with built-in audio support.

A.2.2. Creating space for the program

Strategies for adding mp3blaster, including compressed floppies.

A.2.2.1. Mounting additional compressed floppies

Loading compressed images from floppy to ramdisk.

A.2.3. Accessing audio files

Handling audio files and potential CD-ROM support.

A.2.4. Other required files

Identifying libraries and terminfo for mp3blaster.

A.3. Construction

Steps to build the enhanced system.

A.3.1. Create an enhanced boot disk

Building a new kernel with additional hardware support.

A.3.1.1. Build a new kernel

Configuring kernel options for audio and CD-ROM.

A.3.2.2. Install the gunzip binary

Compiling and installing gunzip.

A.3.2.3. Write a startup script to mount a compressed floppy

Creating a script to load the /usr image.

A.3.3. Create a compressed /usr disk for mp3blaster

Building the /usr disk with mp3blaster.

A.3.3.1. Create a staging area

Setting up a staging directory for the /usr disk.

A.3.3.2. Install the mp3blaster program

Downloading and compiling mp3blaster.

A.3.4. Create a data diskette for testing

Creating a floppy for sample audio files.

A.4. Implementation

Steps to test the hosted application.

A.4.1. System Startup

Booting the system with the enhanced diskettes.

A.4.5. Play a sample file

Using mp3blaster to play an audio file.

Appendix B: GNU Free Documentation License

B.1. PREAMBLE

Explains the purpose and freedoms granted by the license.

B.2. APPLICABILITY AND DEFINITIONS

Defines terms and scope of the license.

B.3. VERBATIM COPYING

Conditions for copying and distributing the document verbatim.

B.5. MODIFICATIONS

Guidelines for creating and distributing modified versions.

B.6. COMBINING DOCUMENTS

Rules for combining this document with others.

B.7. COLLECTIONS OF DOCUMENTS

Procedures for creating document collections.

B.9. TRANSLATION

Guidelines for distributing translated versions.

B.10. TERMINATION

Conditions under which the license can be terminated.

B.11. FUTURE REVISIONS OF THIS LICENSE

Information on future license versions.