Pocket Linux Guide

Revision History
Revision 3.12005-04-09DH
Minor clarifications and spelling corrections.
Revision 3.02004-11-02DH
Changed bootloader to GRUB rather than LILO. Updated versions on all source code packages. Made minor clarifications to some shell commands and scripts.
Revision 2.12004-02-18DH
Corrected typos. Changed resource site hosting to SourceForge. Added appendix B to include the GNU Free Documentation License as part of this document.
Revision 2.02003-11-08DH
Updated to use GNU coreutils in place of fileutils, sh-utils and textutils. Updated version numbers on many source code packages. Introduced Freshmeat as a resource for finding source code. Changed /etc/mtab to a real file rather than using a symlink to /proc/mounts. Corrected local_fs script errors. Updated email address.
Revision 1.22003-05-31DH
Corrected errors in "strip -o library" commands.
Revision 1.12003-05-21DH
Bug fixes, typo corrections and improved XML markup.
Revision 1.02003-02-17DH
Initial Release, reviewed by LDP.

Abstract

The Pocket Linux Guide is for anyone interested in learning the techniques of building a GNU/Linux system from source code. The guide is structured as a project that builds a small diskette-based GNU/Linux system called Pocket Linux. Each chapter explores a small piece of the overall system explaining how it works, why it is needed and how to build it. After completing the Pocket Linux project, readers should possess an enhanced knowledge of what makes GNU/Linux systems work as well as the confidence to explore larger, more complex source-code-only projects.


Table of Contents

Legal Information
1. Copyright and License
2. Disclaimer
Introduction
1. About Pocket Linux
2. Prerequisite Skills
3. Project Format
4. Help & Support
5. Feedback
1. Project Initiation
1. A Brief History of GNU/Linux
2. The Goal of Pocket Linux
3. Working Within The Constraints
2. A Simple Prototype
1. Analysis
2. Design
2.1. Simplification
2.2. Boot Disk
2.3. Root Disk
2.4. CPU Compatibility
3. Construction
3.1. Prepare the boot disk media
3.2. Build the GRUB bootloader
3.3. Copy the bootloader files to diskette
3.4. Finish bootloader installation
3.5. Build the Linux kernel
3.6. Copy the kernel to diskette
3.7. Unmount the boot disk
3.8. Prepare the root disk media
3.9. Build BASH
3.10. Copy BASH to the root disk
3.11. Create device files that BASH needs
3.12. Unmount the root disk
4. Implementation
4.1. System startup
4.2. Testing what works
4.3. Noting what does not work
4.4. System shutdown
3. Saving Space
1. Analysis
2. Design
2.1. Shared Libraries
2.2. Stripped Binaries
2.3. Compressed Root Filesystem
3. Construction
3.1. Create a ramdisk
3.2. Rebuild the BASH shell
3.3. Determine which libraries are required
3.4. Copy BASH and its libraries to the ramdisk
3.5. Create a console device
3.6. Compress the ramdisk image
3.7. Copy the compressed image to diskette
4. Implementation
4.1. System startup
4.2. Verify results
4.3. System shutdown
4. Some Basic Utilities
1. Analysis
2. Design
2.1. Determining Required Commands
2.2. Locating Source Code
2.3. Leveraging FHS
2.4. Downloading Source Code
3. Construction
3.1. Create a staging area
3.2. Copy contents of phase 2 rootdisk
3.3. Install binaries from GNU coreutils
3.4. Copy additional libraries
3.5. Strip binaries and libraries
3.6. Create a compressed root disk image
3.7. Write the root disk image to floppy
4. Implementation
4.1. System startup
4.2. Testing new commands
4.3. System shutdown
5. Checking and Mounting Disks
1. Analysis
2. Design
2.1. Determining necessary utilities.
2.2. Finding source code
2.3. Automating fsck and mount
2.4. File dependencies
3. Construction
3.1. Install utilities from e2fsprogs
3.2. Install utilities from util-linux
3.3. Check library requirements
3.4. Strip binaries to save space
3.5. Create additional device files
3.6. Create the fstab and mtab files
3.7. Write a script to check and mount local filesystems
3.8. Create a compressed root disk image
3.9. Write the root disk image to floppy
4. Implementation
4.1. System startup
4.2. Test the local_fs script
4.3. Create and mount additional filesystems
4.4. System shutdown
6. Automating Startup & Shutdown
1. Analysis
2. Design
2.1. Determining necessary utilities
2.2. Obtaining source code
2.3. Checking dependencies
2.4. Designing a simple GRUB configuration file.
2.5. Outlining start-up scripts
3. Construction
3.1. Create a GRUB configuration file
3.2. Install sysvinit utilities
3.3. Create /etc/inittab file
3.4. Create /etc/init.d/rc script
3.5. Modify /etc/init.d/local_fs script
3.6. Create a hostname script
3.7. Create halt & reboot scripts
3.8. Create rcN.d directories and links
3.9. Create the root disk image
3.10. Copy the image to diskette
4. Implementation
4.1. System Startup
4.2. Verify success of startup scripts
4.3. System shutdown
7. Enabling Multiple Users
1. Analysis
2. Design
2.1. The login process
2.2. Obtaining source code
2.3. Creating support files
2.4. Dependencies
2.5. Assigning ownership and permissions
3. Construction
3.1. Verify presence of getty and login
3.2. Modify inittab for multi-user mode
3.3. Create tty devices
3.4. Create support files in /etc
3.5. Copy required libraries
3.6. Set directory and file permissions
3.7. Create the root disk image
3.8. Copy the image to diskette
4. Implementation
4.1. System Startup
4.2. Add a new user to the system
4.3. Test the new user's ability to use the system
4.4. System shutdown
8. Filling in the Gaps
1. Analysis
2. Design
2.1. more
2.2. More device files
2.3. ps, sed & ed
3. Construction
3.1. Write a "more" script
3.2. Create additional device files
3.3. Install ps
3.4. Install sed
3.5. Install ed
3.6. Strip binaries to save space
3.7. Ensure proper permissions
3.8. Create the root disk image
3.9. Copy the image to diskette
4. Implementation
4.1. System startup
4.2. Test the "more" script
4.3. Use ps to show running processes
4.4. Run a simple sed script
4.5. Test the "ed" editor
4.6. System shutdown
9. Project Wrap Up
1. Celebrating Accomplishments
2. Planning Next Steps
A. Hosting Applications
1. Analysis
2. Design
2.1. Support for audio hardware
2.2. Creating space for the program
2.3. Accessing audio files
2.4. Other required files
2.5. Summary of tasks
3. Construction
3.1. Create an enhanced boot disk
3.2. Create an enhanced root disk
3.3. Create a compressed /usr disk for mp3blaster
3.4. Create a data diskette for testing
4. Implementation
4.1. System Startup
4.2. Verify that the /usr diskette loaded properly
4.3. Check the audio device initialization
4.4. Test audio output
4.5. Play a sample file
4.6. System shutdown
B. GNU Free Documentation License
1. PREAMBLE
2. APPLICABILITY AND DEFINITIONS
3. VERBATIM COPYING
4. COPYING IN QUANTITY
5. MODIFICATIONS
6. COMBINING DOCUMENTS
7. COLLECTIONS OF DOCUMENTS
8. AGGREGATION WITH INDEPENDENT WORKS
9. TRANSLATION
10. TERMINATION
11. FUTURE REVISIONS OF THIS LICENSE
12. ADDENDUM: How to use this License for your documents