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 #22 background image
Chapter 4. Some Basic Utilities
4.1. Analysis
In the previous chapter it might seem like we did not accomplish very much. A lot of energy was expended
redesigning the root disk, but the functionality is basically the same as in the initial prototype phase. The root
disk still does not do very much. But we did make significant improvements when it comes to space savings.
In this chapter we will put that extra space to good use and start cramming the root disk with as many utilities
as it can hold.
The first two root disks we built only had shell built−in commands like echo and pwd. This time it would be
nice to have some of the commonly used external commands like cat, ls, mkdir, rm and such on the root
disk. Keeping this in mind we can define the goals for this phase as follows:
Retain all of the functionality from the previous root disk.
Add some of the commonly used external commands.
4.2. Design
4.2.1. Determining Required Commands
The first question that might come to mind is, "How do we know which commands are needed?" It is possible
to just start with cat and ls then install other commands as we discover a need for them. But this is terribly
inefficient. We need a plan or a blueprint to work from. For this we can turn to the Filesystem Hierarchy
Standard (FHS) available from http://www.pathname.com/fhs/. The FHS dictates which commands should be
present on a Linux system and where they should be placed in the directory structure.
4.2.2. Locating Source Code
The next logical question is, "Now that we know what we need, where do we get the source code?" One way
to find the answer to this question is to check the manpages. We can either search the manpages included with
one of the popular GNU/Linux distributions or use one of the manpage search engines listed at
http://www.tldp.org/docs.html#man. One thing that should tip us off as to where to find the source code for a
particular command is the email address listed for reporting bugs. For example the cat manpage lists
bug−textutils@gnu.org. From this email address we can deduce that cat is part of the textutils package from
GNU.
4.2.3. Leveraging FHS
So let's look at the FHS requirements for the /bin directory. The first few commands in the list are cat,
chgrp, chmod, chown and cp. We already know that cat is part of GNU's textutils. Using the next few
commands as keywords in a manpage search we discover that we need GNU's fileutils package for chmod,
chgrp, chown and cp. In fact quite a few of the commands in /bin come from GNU's fileutils. The date
command also comes from a GNU package called sh−utils. So a good way to tackle the problem of finding
source code might be to group the commands together by package as shown below.
The BASH shell −− echo, false, pwd, sh, true
GNU textutils −− cat
Chapter 4. Some Basic Utilities 16

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.