Linux From Scratch
Version 6.6
Created by Gerard Beekmans
by Created by Gerard Beekmans and Edited by Matthew Burgess and Bruce Dubbs Copyright © 1999-2010 Gerard Beekmans
Copyright © 1999-2010, Gerard Beekmans All rights reserved.
This book is licensed under a Creative Commons License.
Table of Contents
Preface ... viii
i. Foreword ... viii
ii. Audience ... viii
iii. LFS Target Architectures ... ix
iv. LFS and Standards ... x
v. Rationale for Packages in the Book ... xi
vi. Prerequisites ... xv
vii. Host System Requirements ... xvi
viii. Typography ... xviii
ix. Structure ... xix
x. Errata ... xix
I. Introduction ... 1
1. Introduction ... 2
1.1. How to Build an LFS System ... 2
1.2. What's new since the last release ... 3
1.3. Changelog ... 4
1.4. Resources ... 8
1.5. Help ... 9
II. Preparing for the Build ... 12
2. Preparing a New Partition ... 13
2.1. Introduction ... 13
2.2. Creating a New Partition ... 13
2.3. Creating a File System on the Partition ... 14
2.4. Mounting the New Partition ... 15
3. Packages and Patches ... 17
3.1. Introduction ... 17
3.2. All Packages ... 17
3.3. Needed Patches ... 23
4. Final Preparations ... 25
4.1. About $LFS ... 25
4.2. Creating the $LFS/tools Directory ... 25
4.3. Adding the LFS User ... 26
4.4. Setting Up the Environment ... 26
4.5. About SBUs ... 28
4.6. About the Test Suites ... 28
5. Constructing a Temporary System ... 30
5.1. Introduction ... 30
5.2. Toolchain Technical Notes ... 30
5.3. General Compilation Instructions ... 32
5.10. GCC-4.4.3 - Pass 2 ... 44
5.11. Tcl-8.5.8 ... 48
5.12. Expect-5.43.0 ... 50
5.13. DejaGNU-1.4.4 ... 52
5.14. Ncurses-5.7 ... 53
5.15. Bash-4.1 ... 54
5.16. Bzip2-1.0.5 ... 55
5.17. Coreutils-8.4 ... 56
5.18. Diffutils-2.8.1 ... 57
5.19. Findutils-4.4.2 ... 58
5.20. Gawk-3.1.7 ... 59
5.21. Gettext-0.17 ... 60
5.22. Grep-2.5.4 ... 61
5.23. Gzip-1.4 ... 62
5.24. M4-1.4.13 ... 63
5.25. Make-3.81 ... 64
5.26. Patch-2.6.1 ... 65
5.27. Perl-5.10.1 ... 66
5.28. Sed-4.2.1 ... 67
5.29. Tar-1.22 ... 68
5.30. Texinfo-4.13a ... 69
5.31. Stripping ... 70
5.32. Changing Ownership ... 70
III. Building the LFS System ... 71
6. Installing Basic System Software ... 72
6.1. Introduction ... 72
6.2. Preparing Virtual Kernel File Systems ... 72
6.3. Package Management ... 73
6.4. Entering the Chroot Environment ... 76
6.5. Creating Directories ... 77
6.6. Creating Essential Files and Symlinks ... 78
6.7. Linux-2.6.32.8 API Headers ... 80
6.8. Man-pages-3.23 ... 81
6.9. Glibc-2.11.1 ... 82
6.10. Re-adjusting the Toolchain ... 89
6.11. Zlib-1.2.3 ... 91
6.12. Binutils-2.20 ... 93
6.13. GMP-5.0.0 ... 96
6.14. MPFR-2.4.2 ... 98
6.15. File-5.04 ... 99
6.16. GCC-4.4.3 ... 100
6.17. Sed-4.2.1 ... 105
6.18. Pkg-config-0.23 ... 106
6.19. Ncurses-5.7 ... 107
6.20. Util-linux-ng-2.17 ... 110
6.21. E2fsprogs-1.41.10 ... 114
6.23. Iana-Etc-2.30 ... 122
6.24. M4-1.4.13 ... 123
6.25. Bison-2.4.1 ... 124
6.26. Procps-3.2.8 ... 125
6.27. Grep-2.5.4 ... 127
6.28. Readline-6.1 ... 128
6.29. Bash-4.1 ... 130
6.30. Libtool-2.2.6b ... 132
6.31. GDBM-1.8.3 ... 133
6.32. Inetutils-1.7 ... 134
6.33. Perl-5.10.1 ... 136
6.34. Autoconf-2.65 ... 139
6.35. Automake-1.11.1 ... 140
6.36. Bzip2-1.0.5 ... 142
6.37. Diffutils-2.8.1 ... 144
6.38. Gawk-3.1.7 ... 145
6.39. Findutils-4.4.2 ... 146
6.40. Flex-2.5.35 ... 148
6.41. Gettext-0.17 ... 150
6.42. Groff-1.20.1 ... 152
6.43. GRUB-1.97.2 ... 155
6.44. Gzip-1.4 ... 157
6.45. IPRoute2-2.6.31 ... 159
6.46. Kbd-1.15.1 ... 161
6.47. Less-436 ... 163
6.48. Make-3.81 ... 164
6.49. Man-DB-2.5.6 ... 165
6.50. Module-Init-Tools-3.11.1 ... 168
6.51. Patch-2.6.1 ... 170
6.52. Psmisc-22.10 ... 171
6.53. Shadow-4.1.4.2 ... 172
6.54. Sysklogd-1.5 ... 175
6.55. Sysvinit-2.86 ... 176
6.56. Tar-1.22 ... 179
6.57. Texinfo-4.13a ... 180
6.58. Udev-151 ... 182
6.59. Vim-7.2 ... 185
6.60. About Debugging Symbols ... 188
6.61. Stripping Again ... 188
6.62. Cleaning Up ... 189
7. Setting Up System Bootscripts ... 190
7.7. Creating the /etc/inputrc File ... 197
7.8. The Bash Shell Startup Files ... 200
7.9. Device and Module Handling on an LFS System ... 201
7.10. Creating Custom Symlinks to Devices ... 205
7.11. Configuring the localnet Script ... 207
7.12. Customizing the /etc/hosts File ... 207
7.13. Configuring the network Script ... 208
8. Making the LFS System Bootable ... 211
8.1. Introduction ... 211
8.2. Creating the /etc/fstab File ... 211
8.3. Linux-2.6.32.8 ... 213
8.4. Using GRUB to Set Up the Boot Process ... 216
9. The End ... 219
9.1. The End ... 219
9.2. Get Counted ... 219
9.3. Rebooting the System ... 219
9.4. What Now? ... 220
IV. Appendices ... 222
A. Acronyms and Terms ... 223
B. Acknowledgments ... 226
C. Dependencies ... 229
D. Boot and sysconfig scripts version-20100124 ... 238
D.1. /etc/rc.d/init.d/rc ... 238
D.2. /etc/rc.d/init.d/functions ... 240
D.3. /etc/rc.d/init.d/mountkernfs ... 253
D.4. /etc/rc.d/init.d/consolelog ... 254
D.5. /etc/rc.d/init.d/modules ... 255
D.6. /etc/rc.d/init.d/udev ... 256
D.7. /etc/rc.d/init.d/swap ... 258
D.8. /etc/rc.d/init.d/setclock ... 259
D.9. /etc/rc.d/init.d/checkfs ... 260
D.10. /etc/rc.d/init.d/mountfs ... 262
D.11. /etc/rc.d/init.d/udev_retry ... 263
D.12. /etc/rc.d/init.d/cleanfs ... 264
D.13. /etc/rc.d/init.d/console ... 266
D.14. /etc/rc.d/init.d/localnet ... 268
D.15. /etc/rc.d/init.d/sysctl ... 269
D.16. /etc/rc.d/init.d/sysklogd ... 270
D.17. /etc/rc.d/init.d/network ... 271
D.18. /etc/rc.d/init.d/sendsignals ... 272
D.19. /etc/rc.d/init.d/reboot ... 273
D.20. /etc/rc.d/init.d/halt ... 274
D.21. /etc/rc.d/init.d/template ... 274
D.22. /etc/sysconfig/rc ... 275
D.23. /etc/sysconfig/modules ... 275
D.24. /etc/sysconfig/createfiles ... 276
D.26. /etc/sysconfig/network-devices/ifdown ... 278
D.27. /etc/sysconfig/network-devices/services/ipv4-static ... 280
D.28. /etc/sysconfig/network-devices/services/ipv4-static-route ... 281
E. Udev configuration rules ... 284
E.1. 55-lfs.rules ... 284
F. LFS Licenses ... 285
F.1. Creative Commons License ... 285
F.2. The MIT License ... 289
Preface
Foreword
My journey to learn and better understand Linux began over a decade ago, back in 1998. I had just installed my first Linux distribution and had quickly become intrigued with the whole concept and philosophy behind Linux.
There are always many ways to accomplish a single task. The same can be said about Linux distributions. A great many have existed over the years. Some still exist, some have morphed into something else, yet others have been relegated to our memories. They all do things differently to suit the needs of their target audience. Because so many different ways to accomplish the same end goal exist, I began to realize I no longer had to be limited by any one implementation. Prior to discovering Linux, we simply put up with issues in other Operating Systems as you had no choice. It was what it was, whether you liked it or not. With Linux, the concept of choice began to emerge. If you didn't like something, you were free, even encouraged, to change it.
I tried a number of distributions and could not decide on any one. They were great systems in their own right. It wasn't a matter of right and wrong anymore. It had become a matter of personal taste. With all that choice available, it became apparent that there would not be a single system that would be perfect for me. So I set out to create my own Linux system that would fully conform to my personal preferences.
To truly make it my own system, I resolved to compile everything from source code instead of using pre-compiled binary packages. This “perfect” Linux system would have the strengths of various systems without their perceived weaknesses. At first, the idea was rather daunting. I remained committed to the idea that such a system could be built.
After sorting through issues such as circular dependencies and compile-time errors, I finally built a custom-built Linux system. It was fully operational and perfectly usable like any of the other Linux systems out there at the time. But it was my own creation. It was very satisfying to have put together such a system yourself. The only thing better would have been to create each piece of software myself. This was the next best thing.
As I shared my goals and experiences with other members of the Linux community, it became apparent that there was a sustained interest in these ideas. It quickly became plain that such custom-built Linux systems serve not only to meet user specific requirements, but also serve as an ideal learning opportunity for programmers and system administrators to enhance their (existing) Linux skills. Out of this broadened interest, the Linux From Scratch Project was born.
This Linux From Scratch book is the central core around that project. It provides the background and instructions necessary for you to design and build your own system. While this book provides a template that will result in a correctly working system, you are free to alter the instructions to suit yourself, which is, in part, an important part of this project. You remain in control; we just lend a helping hand to get you started on your own journey.
I sincerely hope you will have a great time working on your own Linux From Scratch system and enjoy the numerous benefits of having a system that is truly your own.
--Gerard Beekmans
Audience
One important reason for this project's existence is to help you learn how a Linux system works from the inside out. Building an LFS system helps demonstrate what makes Linux tick, and how things work together and depend on each other. One of the best things that this learning experience can provide is the ability to customize a Linux system to suit your own unique needs.
Another key benefit of LFS is that it allows you to have more control over the system without relying on someone else's Linux implementation. With LFS, you are in the driver's seat and dictate every aspect of the system.
LFS allows you to create very compact Linux systems. When installing regular distributions, you are often forced to install a great many programs which are probably never used or understood. These programs waste resources. You may argue that with today's hard drive and CPUs, such resources are no longer a consideration. Sometimes, however, you are still constrained by size considerations if nothing else. Think about bootable CDs, USB sticks, and embedded systems. Those are areas where LFS can be beneficial.
Another advantage of a custom built Linux system is security. By compiling the entire system from source code, you are empowered to audit everything and apply all the security patches desired. It is no longer necessary to wait for somebody else to compile binary packages that fix a security hole. Unless you examine the patch and implement it yourself, you have no guarantee that the new binary package was built correctly and adequately fixes the problem.
The goal of Linux From Scratch is to build a complete and usable foundation-level system. If you do not wish to build your own Linux system from scratch, you may not entirely benefit from the information in this book.
There are too many other good reasons to build your own LFS system to list them all here. In the end, education is by far the most powerful of reasons. As you continue in your LFS experience, you will discover the power that information and knowledge truly bring.
LFS Target Architectures
The primary target architecture of LFS is the 32-bit Intel CPU. If you have not built an LFS system before, you should probably start with that target. The 32-bit architecture is the most widely supported Linux system and is most compatible with both open source and proprietary software.
On the other hand, the instructions in this book are known to work, with some modifications, with both Power PC and 64-bit AMD/Intel CPUs. To build a system that utilizes one of these CPUs, the main prerequisite, in addition to those on the next few pages, is an existing Linux system such as an earlier LFS installation, Ubuntu, Red Hat/ Fedora, SuSE, or other distribution that targets the architecture that you have. Also note that a 32-bit distribution can be installed and used as a host system on a 64-bit AMD/Intel computer.
Some other facts about 64-bit systems need to be added here. When compared to a 32-bit system, the sizes of executable programs are slightly larger and the execution speeds are only slightly faster. For example, in a test build of LFS-6.5 on a Core2Duo CPU based system, the following statistics were measured:
The default 64-bit build that results from LFS is considered a "pure" 64-bit system. That is, it supports 64-bit executables only. Building a "multi-lib" system requires compiling many applications twice, once for a 32-bit system and once for a 64-bit system. This is not directly supported in LFS because it would interfere with the educational objective of providing the instructions needed for a straightforward base Linux system. You can refer to the Cross Linux From Scratch project for this advanced topic.
There is one last comment about bit systems. There are some packages that cannot currently be built in a "pure" 64-bit system or require specialized build instructions. Generally, these packages have some embedded 32-64-bit specific assembly language instructions that fail when building on a 64-bit system. This includes some Xorg drivers from Beyond Linux From Scratch (BLFS). Many of these problems can be worked around, but may require some specialized procedures or patches.
LFS and Standards
The structure of LFS follows Linux standards as closely as possible. The primary standards are:
• The Single UNIX Specification Version 3 (POSIX). Note: Free registration is required.
• Filesystem Hierarcy Standard (FHS)
• Linux Standard Base (LSB) Core Specification 4.0
The LSB has five separate standards: Core, C++, Desktop, Runtime Languages, and Printing. In addition to generic requirements there are also architecture specific requirements. LFS attempts to conform to the architectures discussed in the previous section.
Note
Many people do not agree with the requirements of the LSB. The main purpose of defining it is to ensure that proprietary software will be able to be installed and run properly on a compliant system. Since LFS is source based, the user has complete control over what packages are desired and many choose not to install some packages that are specified by the LSB.
Creating a complete LFS system capable of passing the LSB certifications tests is possible, but not without many additional packages that are beyond the scope of LFS. Most of these additional packages have installation instructions in BLFS.
Packages supplied by LFS needed to satisfy the LSB Requirements
LSB Core: Bash, Binutils, Coreutils, Diffutils, File, Findutils, Gawk, Grep, Gzip, M4, Man-DB, Ncurses, Procps, Psmisc, Sed, Shadow, Tar, Util-linux-ng, Zlib
LSB C++: Gcc
LSB Desktop: None
LSB Runtime Languages: Perl
LSB Printing: None
LSB Multimeda: None
Packages supplied by BLFS needed to satisfy the LSB Requirements
LSB C++: None
LSB Desktop: ATK, Cairo, Desktop-file-utils, Freetype, Fontconfig, Glib2, GTK+2, Icon-naming-utils, Libjpeg, Libpng, Libxml2, MesaLib, Pango, Qt3, Qt4, Xorg
LSB Runtime Languages: Python
LSB Printing: CUPS
LSB Multimeda: Alsa Libraries, NSPR, NSS, OpenSSL, Java
Packages not supplied by LFS or BLFS needed to satisfy the LSB Requirements
LSB Core: At, Batch, Install_initd, Lsb_release, Remove_initd, Test
LSB C++: None
LSB Desktop: None
LSB Runtime Languages: None
LSB Printing: None
LSB Multimeda: Xdg-utils
Rationale for Packages in the Book
As stated earlier, the goal of LFS is to build a complete and usable foundation-level system. This includes all packages needed to replicate itself while providing a relatively minimal base from which to customize a more complete system based on the choices of the user. This does not mean that LFS is the smallest system possible. Several important packages are included that are not strictly required. The lists below document the rationale for each package in the book.
• Autoconf
This package contains programs for producing shell scripts that can automatically configure source code from a developer's template. It is often needed to rebuild a package after updates to the build procedures.
• Automake
This package contains programs for generating Make files from a template. It is often needed to rebuild a package after updates to the build procedures.
• Bash
This package satisfies an LSB core requirement to provide a Bourne Shell interface to the system. It was chosen over other shell packages because of its common usage and extensive capabilities beyond basic shell functions.
This package contains programs for compressing and decompressing files. It is required to decompress many LFS packages.
• Coreutils
This package contains a number of essential programs for viewing and manipulating files and directories.
• DejaGNU
This package contains a framework for testing other programs. It is only installed in the temporary toolchain.
• Diffutils
This package contains programs that show the differences between files or directories.
• Expect
This package contains a program for carrying out scripted dialogues with other interactive programs. It is commonly used for testing other packages. It is only installed in the temporary toolchain.
• E2fsprogs
This package contains the utilities for handling the ext2, ext3 and ext4 file systems. These are the most common and thoroughly tested file systems that Linux supports.
• File
This package contains a utility for determining the type of a given file or files.
• Findutils
This package contains programs to find files in a file system.
• Flex
This package contains a utility for generating programs that recognize patterns in text. It is the GNU version of the lex (lexical analyzer) program. It is required to build several LFS packages.
• Gawk
This package contains programs for manipulating text files. It is the GNU version of awk (Aho-Weinberg-Kernighan).
• Gcc
This package is the Gnu Compiler Collection. It contains the C and C++ compilers as well as several others not built by LFS.
• GDBM
This package contains the GNU Database Manager library. It is used by one other LFS package, Man-DB.
• Gettext
This package contains utilities and libraries for internationalization and localization of numerous packages.
• Glibc
This package contains the main C library. Linux programs would not run without it.
This package contains math libraries and have useful functions for arbitrary precision arithmetic. It is required to build Gcc.
• Grep
This package contains programs for searching through files.
• Groff
This package contains programs for processing and formatting text. One important function of these programs is to format man pages.
• GRUB
This package is the Grand Unified Boot Loader. It is one of several boot loaders available, but is the most flexible.
• Gzip
This package contains programs for compressing and decompressing files.
• Iana-etc
This package provides data for network services and protocols. It is needed to enable proper networking capabilities.
• Inetutils
This package contains programs for basic network administration.
• IProute2
This package contains programs for basic and advanced IPv4 and IPv6 networking. It was chosen over the other common network tools package (net-tools) for its IPv6 capabilities.
• Kbd
This package contains key-table files and keyboard utilities for non-US keyboards.
• Less
This package contains a very nice text file viewer that allows scrolling up or down when viewing a file.
• Libtool
This package contains the GNU generic library support script. It wraps the complexity of using shared libraries in a consistent, portable interface. It is needed by the test suites in other LFS packages.
• Linux Kernel
This package is the Operating System. It is the Linux in the GNU/Linux environment.
This package contains programs for finding and viewing man pages. It was chosen instead of the man package due to superior internationalization capabilities. It supplies the man program.
• Man-pages
This package contains the actual contents of the basic Linux man pages.
• Module-Init-Tools
This package contains programs needed to administer Linux kernel modules.
• MPFR
This package contains functions for multiple precision arithmetic. It is required by Gcc.
• Ncurses
This package contains libraries for terminal-independent handling of character screens. It is often used to provide cursor control for a menuing system.
• Patch
This package contains a program for modifying or creating files by applying a patch file typically created by the diff program. It is needed by the build procedure for several LFS packages.
• Perl
This package is an interpreter for the runtime language PERL.
• Pkg-config
This package contains a tool for passing the include path and/or library paths to build tools during the configure and make processes. It is needed by many LFS packages.
• Procps
This package contains programs for monitoring processes.
• Psmisc
This package contains programs for displaying information about running processes.
• Readline
This package is a set of libraries that offers command-line editing and history capabilities. It is used by Bash.
• Sed
This package allows editing of text without opening it in a text editor. It is also needed by most LFS packages' configure scripts.
• Shadow
This package contains programs for handling passwords in a secure way.
• Sysklogd
This package contains programs for logging system messages, such as those given by the kernel or daemon processes when unusual events occur.
• Sysvinit
• Tar
This package provides archiving and extraction capabilities of virtually all packages used in LFS.
• Tcl
This package contains the Tool Command Language used in many testsuites in LFS packages. It is only installed in the temporary toolchain.
• Texinfo
This package contains programs for reading, writing, and converting info pages. It is used in the installation procedures of many LFS packages.
• Udev
This package contains programs for dynamic creation of device nodes. It is an alternative to creating thousands of static devices in the /dev directory.
• Util-linux-ng
This package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages.
• Vim
This package contains an editor. It was chosen because of its compatibility with the classic vi editor and its huge number of powerful capabilities. An editor is a very personal choice for many users and any other editor could be substituted if desired.
• Zlib
This package contains compression and decompression routines used by some programs.
Prerequisites
Building an LFS system is not a simple task. It requires a certain level of existing knowledge of Unix system administration in order to resolve problems and correctly execute the commands listed. In particular, as an absolute minimum, you should already have the ability to use the command line (shell) to copy or move files and directories, list directory and file contents, and change the current directory. It is also expected that you have a reasonable knowledge of using and installing Linux software.
Because the LFS book assumes at least this basic level of skill, the various LFS support forums are unlikely to be able to provide you with much assistance in these areas. You will find that your questions regarding such basic knowledge will likely go unanswered or you will simply be referred to the LFS essential pre-reading list.
Before building an LFS system, we recommend reading the following HOWTOs:
• Software-Building-HOWTO http://www.tldp.org/HOWTO/Software-Building-HOWTO.html
This is an LFS Hint written specifically for users new to Linux. It includes a list of links to excellent sources of information on a wide range of topics. Anyone attempting to install LFS should have an understanding of many of the topics in this hint.
Host System Requirements
Your host system should have the following software with the minimum versions indicated. This should not be an issue for most modern Linux distributions. Also note that many distributions will place software headers into separate packages, often in the form of “<package-name>-devel” or “<package-name>-dev”. Be sure to install those if your distribution provides them.
• Bash-2.05a (/bin/sh should be a symbolic or hard link to bash)
• Binutils-2.12 (Versions greater than 2.20 are not recommended as they have not been tested) • Bison-1.875 (/usr/bin/yacc should be a link to bison or small script that executes bison) • Bzip2-1.0.2
• Coreutils-5.0 (or Sh-Utils-2.0, Textutils-2.0, and Fileutils-4.1) • Diffutils-2.8
• Findutils-4.1.20
• Gawk-3.0 (/usr/bin/awk should be a link to gawk)
• Gcc-3.0.1 (Versions greater than 4.4.3 are not recommended as they have not been tested) • Glibc-2.2.5 (Versions greater than 2.11.1 are not recommended as they have not been tested) • Grep-2.5
• Gzip-1.2.4
• Linux Kernel-2.6.18 (having been compiled with GCC-3.0 or greater)
The reason for the kernel version requirement is that we specify that version when building glibc in Chapter 6 at the recommendation of the developers. This can be overridden if desired but at least a 2.6.0 kernel is required because thread-local storage support in Binutils will not be built and the Native POSIX Threading Library (NPTL) test suite will segfault if the host's kernel isn't at least a 2.6.0 version compiled with a 3.0 or later release of GCC.
If the host kernel is either earlier than 2.6.18, or it was not compiled using a GCC-3.0 (or later) compiler, you will need to replace the kernel with one adhering to the specifications. There are two ways you can go about this. First, see if your Linux vendor provides a 2.6.18 or later kernel package. If so, you may wish to install it. If your vendor doesn't offer an acceptable kernel package, or you would prefer not to install it, you can compile a kernel yourself. Instructions for compiling the kernel and configuring the boot loader (assuming the host uses GRUB) are located in Chapter 8.
• M4-1.4 • Make-3.79.1 • Patch-2.5.4 • Perl-5.6.0 • Sed-3.0.2 • Tar-1.14 • Texinfo-4.8
To see whether your host system has all the appropriate versions, and the ability to compile programs, run the following:
cat > version-check.sh << "EOF"
#!/bin/bash export LC_ALL=C
# Simple script to list version numbers of critical development tools
bash --version | head -n1 | cut -d" " -f2-4 echo "/bin/sh -> `readlink -f /bin/sh`"
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-bison --version | head -n1
if [ -e /usr/bin/yacc ];
then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; else echo "yacc not found"; fi
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 diff --version | head -n1
find --version | head -n1 gawk --version | head -n1 if [ -e /usr/bin/awk ];
then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`"; else echo "awk not found"; fi
gcc --version | head -n1
/lib/libc.so.6 | head -n1 | cut -d"," -f1 grep --version | head -n1
gzip --version | head -n1 cat /proc/version
m4 --version | head -n1 make --version | head -n1 patch --version | head -n1 echo Perl `perl -V:version` sed --version | head -n1 tar --version | head -n1
echo "Texinfo: `makeinfo --version | head -n1`" echo 'main(){}' > dummy.c && gcc -o dummy dummy.c if [ -x dummy ]; then echo "Compilation OK";
else echo "Compilation failed"; fi rm -f dummy.c dummy
Typography
To make things easier to follow, there are a few typographical conventions used throughout this book. This section contains some examples of the typographical format found throughout Linux From Scratch.
./configure --prefix=/usr
This form of text is designed to be typed exactly as seen unless otherwise noted in the surrounding text. It is also used in the explanation sections to identify which of the commands is being referenced.
In some cases, a logical line is extended to two or more physical lines with a backslash at the end of the line.
CC="gcc -B/usr/bin/" ../binutils-2.18/configure \ --prefix=/tools --disable-nls --disable-werror
Note that the backslash must be followed by an immediate return. Other whitespace characters like spaces or tab characters will create incorrect results.
install-info: unknown option '--dir-file=/mnt/lfs/usr/info/dir'
This form of text (fixed-width text) shows screen output, usually as the result of commands issued. This format is also used to show filenames, such as /etc/ld.so.conf.
Emphasis
This form of text is used for several purposes in the book. Its main purpose is to emphasize important points or items.
http://www.linuxfromscratch.org/
This format is used for hyperlinks both within the LFS community and to external pages. It includes HOWTOs, download locations, and websites.
cat > $LFS/etc/group << "EOF"
root:x:0: bin:x:1: ...
EOF
This format is used when creating configuration files. The first command tells the system to create the file $LFS/ etc/group from whatever is typed on the following lines until the sequence End Of File (EOF) is encountered. Therefore, this entire section is generally typed as seen.
<REPLACED TEXT>
This format is used to encapsulate text that is not to be typed as seen or for copy-and-paste operations.
[OPTIONAL TEXT]
This format is used to encapsulate text that is optional.
passwd(5)
passwd will print the first man page it finds that matches “passwd”, which will be /usr/share/man/man1/ passwd.1. For this example, you will need to run man 5 passwd in order to read the specific page being referred to. It should be noted that most man pages do not have duplicate page names in different sections. Therefore, man <program name> is generally sufficient.
Structure
This book is divided into the following parts.
Part I - Introduction
Part I explains a few important notes on how to proceed with the LFS installation. This section also provides meta-information about the book.
Part II - Preparing for the Build
Part II describes how to prepare for the building process—making a partition, downloading the packages, and compiling temporary tools.
Part III - Building the LFS System
Part III guides the reader through the building of the LFS system—compiling and installing all the packages one by one, setting up the boot scripts, and installing the kernel. The resulting Linux system is the foundation on which other software can be built to expand the system as desired. At the end of this book, there is an easy to use reference listing all of the programs, libraries, and important files that have been installed.
Errata
Chapter 1. Introduction
1.1. How to Build an LFS System
The LFS system will be built by using an already installed Linux distribution (such as Debian, Mandriva, Red Hat, or SUSE). This existing Linux system (the host) will be used as a starting point to provide necessary programs, including a compiler, linker, and shell, to build the new system. Select the “development” option during the distribution installation to be able to access these tools.
As an alternative to installing a separate distribution onto your machine, you may wish to use the Linux From Scratch LiveCD or a LiveCD from a commercial distribution. The LFS LiveCD works well as a host system, providing all the tools you need to successfully follow the instructions in this book. Unfortunately, development of the LiveCD has not progressed recently and it only contains older versions of the source packages and patches (the versions not labeled “-nosrc” or “-min”), and this book. For more information about the LFS LiveCD or to download a copy, visit http://www.linuxfromscratch.org/livecd/.
Note
The LFS LiveCD might not work on newer hardware configurations, failing to boot or failing to detect some devices such as some SATA hard drives.
Chapter 2 of this book describes how to create a new Linux native partition and file system. This is the place where the new LFS system will be compiled and installed. Chapter 3 explains which packages and patches need to be downloaded to build an LFS system and how to store them on the new file system. Chapter 4 discusses the setup of an appropriate working environment. Please read Chapter 4 carefully as it explains several important issues you need be aware of before beginning to work your way through Chapter 5 and beyond.
Chapter 5 explains the installation of a number of packages that will form the basic development suite (or toolchain) which is used to build the actual system in Chapter 6. Some of these packages are needed to resolve circular dependencies—for example, to compile a compiler, you need a compiler.
Chapter 5 also shows you how to build a first pass of the toolchain, including Binutils and GCC (first pass basically means these two core packages will be reinstalled). The next step is to build Glibc, the C library. Glibc will be compiled by the toolchain programs built in the first pass. Then, a second pass of the toolchain will be built. This time, the toolchain will be dynamically linked against the newly built Glibc. The remaining Chapter 5 packages are built using this second pass toolchain. When this is done, the LFS installation process will no longer depend on the host distribution, with the exception of the running kernel.
This effort to isolate the new system from the host distribution may seem excessive. A full technical explanation as to why this is done is provided in Section 5.2, “Toolchain Technical Notes”.
This is the process in a nutshell. Detailed information on each step is discussed in the following chapters and package descriptions. Items that may seem complicated will be clarified, and everything will fall into place as you embark on the LFS adventure.
1.2. What's new since the last release
Below is a list of package updates made since the previous release of the book.
Upgraded to:
• Autoconf 2.65
• Automake 1.11.1
• Bash 4.1
• Binutils 2.20
• Coreutils 8.4
• E2fsprogs 1.41.10
• File 5.04
• GCC 4.4.3
• Glibc 2.11.1
• GMP 5.0.0
• GRUB 1.97.2
• Gzip 1.4
• Inetutils 1.7
• IPRoute2 2.6.31
• Less 436
• Libtool 2.2.6b
• Linux 2.6.32.8
• Man-DB 2.5.6
• Man-pages 3.23
• Module-Init-Tools 3.11.1
• MPFR 2.4.2
• Patch 2.6.1
• Perl 5.10.1
• Psmisc 22.10
• Readline 6.1
• TCL 8.5.8
• Udev 151
• Util-Linux-NG 2.17
Added:
• coreutils-8.4-uname-1.patch
• make-3.81-upstream_fixes-1.patch
• patch-2.6.1-test_fix-1.patch
• perl-5.10.1-utf8-1.patch
Removed:
• bash-4.0-fixes-3.patch
• coreutils-7.5-i18n-1.patch
• coreutils-7.1-uname-1.patch
• inetutils-1.6-no_server_man_pages-1.patch
• patch-2.5.9-fixes-1.patch
• readline-6.0-fixes-1.patch
1.3. Changelog
This is version 6.6 of the Linux From Scratch book, dated March 1, 2010. If this book is more than six months old, a newer and better version is probably already available. To find out, please check one of the mirrors via http://www. linuxfromscratch.org/mirrors.html.
Below is a list of changes made since the previous release of the book.
Changelog Entries:
• 2010-02-28
• [bdubbs] Fix location of change to config.h in Bison. Fixes #2595.
• 2010-02-26
• [bdubbs] Add make-3.81-upstream_fixes-1.patch. Fixes #2588.
• [bdubbs] Add perl-5.10.1-utf8-1.patch. Fixes #2589.
• 2010-02-22
• [matthew] Correct the version number used in Readline's documentation. This is the equivalent of upstream's 002 patch.
• [bdubbs] Update to e2fsprogs-1.41.10. Fixes #2576. This also reverts the changes made in response to #2586.
• [bdubbs] Make more robust output in version check for glibc.
• 2010-02-21
• [bdubbs] Fix an error in e2fsprogs. Fixes #2586.
• [matthew] Tag for lfs-6.6-rc2.
• [bdubbs] Put file before gcc in chapter 6 for better test coverage. Fixes #2568.
• [bdubbs] Update known failure problems in glibc tests. Fixes #2569.
• 2010-02-11
• [bdubbs] Update the book's attribution.
• 2010-02-01
• [matthew] Have Module-Init-Tools use Zlib's dynamic instead of static library. Fixes #2562.
• [matthew] Upgrade to Linux-2.6.32.7. Fixes #2563.
• 2010-01-31
• [bdubbs] Reword paragraph in 'Target Architectures' discussing multi-lib systems.
• 2010-01-28
• [matthew] Upgrade to Udev-151. Fixes #2561.
• [matthew] Upgrade to Linux-2.6.32.6. Fixes #2559.
• 2010-01-26
• [matthew] Remove a lot of redundant Udev rules, using upstream's rules instead. Fixes #2527.
• [bryan] Use /etc/modprobe.d/*.conf files instead of a single /etc/modprobe.conf file, since module-init-tools now warns. Fixes #2560.
• 2010-01-24
• [bdubbs] Update to GRUB-1.97.2. Fixes #2556.
• [matthew] Update to lfs-bootscripts-20100124, which checks that /dev isn't already mounted.. Fixes #2550.
• [matthew] Don't create /lib/udev/devices/kmsg as Udev >= 142 creates it automatically. Fixes #2552.
• [matthew] Upgrade to File-5.04. Fixes #2555.
• [matthew] Upgrade to GCC-4.4.3. Fixes #2553.
• [matthew] Upgrade to Gzip-1.4. Fixes #2551.
• [matthew] Upgrade to Udev-150. Fixes #2547.
• [matthew] Upgrade to GMP-5.0.0. Fixes #2546.
• [matthew] Upgrade to Coreutils-8.4. Fixes #2545.
• [matthew] Upgrade to Util-Linux-NG-2.17. Fixes #2544.
• [matthew] Upgrade to Linux-2.6.32.5. Fixes #2542.
• [matthew] Upgrade to Psmisc-22.10. Fixes #2541.
• 2010-01-09
• [bdubbs] Grammar and spelling updates from Chris Staub. Fixes #2548.
• 2010-01-03
• [matthew] Prevent a failure in GCC's testsuite due to a conflict with Glibc's getline function.
• [matthew] Upgrade to Readline-6.1. Fixes #2540.
• [matthew] Upgrade to Bash-4.1. Fixes #2539.
• [matthew] Upgrade to Glibc-2.11.1. Fixes #2537.
• [matthew] Upgrade to Psmisc-22.9. Fixes #2536.
• [matthew] Upgrade to IPRoute2-2.6.31. Fixes #2535.
• 2009-12-21
• [matthew] Upgrade to Linux-2.6.32.2. Fixes #2534.
• [matthew] Upgrade to Inetutils-1.7. Fixes #2533.
• 2009-12-16
• [matthew] Upgrade to Linux-2.6.32.1. Fixes #2532.
• [matthew] Upgrade to Automake-1.11.1. Fixes #2529.
• [matthew] Upgrade to Coreutils-8.2. Fixes #2524.
• 2009-12-06
• [matthew] Move some of inetutils' programs to an FHS-compliant location. Fixes #2524.
• [matthew] Upgrade to Linux-2.6.32. Fixes #2526.
• [matthew] Upgrade to Udev-149. Fixes #2525.
• 2009-12-02
• [matthew] Upgrade to Util-Linux-NG-2.16.2. Fixes #2523.
• [matthew] Upgrade to MPFR-2.4.2. Fixes #2522.
• [matthew] Upgrade to Autoconf-2.65. Fixes #2520.
• 2009-11-29
• [bdubbs] Provided more information about grub configuration.
• 2009-11-24
• [bdubbs] Create separate standards and rationale pages and reformated. Provided more information about packages needed to satisfy LSB.
• 2009-11-23
• [bdubbs] Add a page describing the Linux standards LFS uses to guide its procedures. Included a sub-section on why each package is in the book. Fixes #1673 and #2196
• 2009-11-22
• [bdubbs] Update host requirements script to print a comment that makeinfo is used to identify the Texinfo package version.
• [bdubbs] Added a section to each package's dependencies in the Appendix to list external (non-LFS) dependencies for LFS packages. Fixes #1682.
• 2009-11-21
• [bdubbs] Removed paragraph in LFS Target Architectures that said that we can't build a 64-bit loader.
• 2009-11-16
• [bdubbs] Clarified explanation of why we use cross compilation techniques in the Toolchain Technical Notes. Fixes #2412.
• 2009-11-15
• [matthew] Upgraded to Patch-2.6. Fixes #2513.
• [matthew] Upgraded to Udev-147. Fixes #2512.
• [matthew] Upgraded to Linux-2.6.31.6. Fixes #2511.
• 2009-11-14
• [bdubbs] Removed obsolete note on the Host System requirements page.
• 2009-11-12
• [bdubbs] Added a note to 'About SBUs' to address parallel make procedures and how SBU values will be affected.
• [bdubbs] Minor changes to GRUB-1.97.1 instructions.
• 2009-11-09
• [bdubbs] Upgraded to GRUB-1.97.1 Fixes #2510.
• 2009-11-06
• [matthew] Upgraded to Glibc-2.11. Fixes #2509.
• [matthew] Upgraded to latest upstream patches for Bash.
• [matthew] Upgraded to Linux-2.6.31.5. Fixes #2508.
• [matthew] Upgraded to Module-Init-Tools-3.11.1. Fixes #2507.
• 2009-10-29
• [bdubbs] Upgraded to GRUB-1.97. Split the build/install portion from the configuration of /boot and the mbr and placed the build portion in Chapter 6. Expanded the discussion about the /boot mbr portion in Chapter 8. Fixes #2093. This also eliminates the need for an initramfs as specified in #2033.
• 2009-10-20
• [matthew] Upgraded to Linux-2.6.31.4. Fixes #2503.
• [matthew] Upgraded to GCC-4.4.2. Fixes #2504.
• [matthew] Upgraded to Binutils-2.20. Fixes #2505.
• 2009-10-12
• [matthew] Upgraded to Kbd-1.15.1. Fixes #2501.
• [matthew] Upgraded to Man-Pages-3.23. Fixes #2498.
• [matthew] Upgraded to Linux-2.6.31.3. Fixes #2499.
• [matthew] Upgraded to Gzip-1.3.13. Fixes #2500.
• [matthew] Install psmisc's binaries in /usr/bin instead of /bin as they are only called whilst /usr is mounted. Fixes #2469.
• 2009-09-25
• [bryan] Upgrade to udev-config-20090925. Fixes #2497.
• 2009-09-24
• [matthew] Update list of installed headers for Linux. Thanks to Chris Staub for the patch. Fixes #2495.
• [matthew] Update list of installed programs for various packages. Thanks to Chris Staub for the patch. Fixes #2494.
• 2009-09-17
• [matthew] Upgraded to Bash-4.0-fixes-4.patch. Fixes #2484.
• [matthew] Upgraded to Linux-2.6.31. Fixes #2485.
• [matthew] Upgraded to Util-Linux-NG-2.16.1. Fixes #2483.
• [matthew] Upgraded to Coreutils-7.6. Fixes #2487.
• [matthew] Upgraded to Man-DB-2.5.6. Fixes #2481.
• 2009-09-11
• [bdubbs] - Deleted the reference to the outdated and incomplete optimization hint.
• 2009-09-10
• [bdubbs] - Added a section to the Preface about LFS supported architectures.
• 2009-09-02
• [bdubbs] - Removed more documentation in the Chapter 5 stripping section.
• 2009-08-26
• [matthew] Upgraded to Udev-146. Fixes #2473.
• [matthew] Upgraded to Perl-5.10.1. Fixes #2479.
• [matthew] Upgraded to Linux-2.6.30.5. Fixes #2475.
• [matthew] - Upgraded to Less-436. Fixes 2471.
• [matthew] - Upgraded to E2fsprogs-1.41.9. Fixes 2478.
• [matthew] - Upgraded to Coreutils-7.5. Fixes #2477.
• 2009-08-19
• [bdubbs] - Reworded the notes in the General Compilation Instructions and added a note to bin-utils to have users actually read the General Compilation Instructions.
LFS 6.5 released August 16, 2009.
1.4. Resources
1.4.2. Mailing Lists
The linuxfromscratch.org server hosts a number of mailing lists used for the development of the LFS project. These lists include the main development and support lists, among others. If the FAQ does not solve the problem you are having, the next step would be to search the mailing lists at http://www.linuxfromscratch.org/search.html.
For information on the different lists, how to subscribe, archive locations, and additional information, visit http:// www.linuxfromscratch.org/mail.html.
1.4.3. IRC
Several members of the LFS community offer assistance on our community Internet Relay Chat (IRC) network. Before using this support, please make sure that your question is not already answered in the LFS FAQ or the mailing list archives. You can find the IRC network at irc.linuxfromscratch.org. The support channel is named #LFS-support.
1.4.4. Mirror Sites
The LFS project has a number of world-wide mirrors to make accessing the website and downloading the required packages more convenient. Please visit the LFS website at http://www.linuxfromscratch.org/mirrors.html for a list of current mirrors.
1.4.5. Contact Information
Please direct all your questions and comments to one of the LFS mailing lists (see above).
1.5. Help
If an issue or a question is encountered while working through this book, please check the FAQ page at http://www. linuxfromscratch.org/faq/#generalfaq. Questions are often already answered there. If your question is not answered on this page, try to find the source of the problem. The following hint will give you some guidance for troubleshooting: http://www.linuxfromscratch.org/hints/downloads/files/errors.txt.
If you cannot find your problem listed in the FAQ, search the mailing lists at http://www.linuxfromscratch.org/search. html.
We also have a wonderful LFS community that is willing to offer assistance through the mailing lists and IRC (see the Section 1.4, “Resources” section of this book). However, we get several support questions every day and many of them can be easily answered by going to the FAQ and by searching the mailing lists first. So, for us to offer the best assistance possible, you need to do some research on your own first. That allows us to focus on the more unusual support needs. If your searches do not produce a solution, please include all relevant information (mentioned below) in your request for help.
1.5.1. Things to Mention
Apart from a brief explanation of the problem being experienced, the essential things to include in any request for help are:
• The version of the book being used (in this case 6.6)
• The host distribution and version being used to create LFS
• The package or section the problem was encountered in
• The exact error message or symptom being received
• Note whether you have deviated from the book at all
Note
Deviating from this book does not mean that we will not help you. After all, LFS is about personal preference. Being upfront about any changes to the established procedure helps us evaluate and determine possible causes of your problem.
1.5.2. Configure Script Problems
If something goes wrong while running the configure script, review the config.log file. This file may contain errors encountered during configure which were not printed to the screen. Include the relevant lines if you need to ask for help.
1.5.3. Compilation Problems
Both the screen output and the contents of various files are useful in determining the cause of compilation problems. The screen output from the configure script and the make run can be helpful. It is not necessary to include the entire output, but do include enough of the relevant information. Below is an example of the type of information to include from the screen output from make:
gcc -DALIASPATH=\"/mnt/lfs/usr/share/locale:.\" -DLOCALEDIR=\"/mnt/lfs/usr/share/locale\"
-DLIBDIR=\"/mnt/lfs/usr/lib\"
-DINCLUDEDIR=\"/mnt/lfs/usr/include\" -DHAVE_CONFIG_H -I. -I. -g -O2 -c getopt1.c
gcc -g -O2 -static -o make ar.o arscan.o commands.o dir.o expand.o file.o function.o getopt.o implicit.o job.o main.o misc.o read.o remake.o rule.o signame.o variable.o vpath.o default.o remote-stub.o version.o opt1.o
-lutil job.o: In function `load_too_high':
/lfs/tmp/make-3.79.1/job.c:1565: undefined reference to `getloadavg'
collect2: ld returned 1 exit status make[2]: *** [make] Error 1
make[2]: Leaving directory `/lfs/tmp/make-3.79.1' make[1]: *** [all-recursive] Error 1
Chapter 2. Preparing a New Partition
2.1. Introduction
In this chapter, the partition which will host the LFS system is prepared. We will create the partition itself, create a file system on it, and mount it.
2.2. Creating a New Partition
Like most other operating systems, LFS is usually installed on a dedicated partition. The recommended approach to building an LFS system is to use an available empty partition or, if you have enough unpartitioned space, to create one.
A minimal system requires a partition of around 1.3 gigabytes (GB). This is enough to store all the source tarballs and compile the packages. However, if the LFS system is intended to be the primary Linux system, additional software will probably be installed which will require additional space (2-3 GB). The LFS system itself will not take up this much room. A large portion of this requirement is to provide sufficient free temporary storage. Compiling packages can require a lot of disk space which will be reclaimed after the package is installed.
Because there is not always enough Random Access Memory (RAM) available for compilation processes, it is a good idea to use a small disk partition as swap space. This is used by the kernel to store seldom-used data and leave more memory available for active processes. The swap partition for an LFS system can be the same as the one used by the host system, in which case it is not necessary to create another one.
Start a disk partitioning program such as cfdisk or fdisk with a command line option naming the hard disk on which the new partition will be created—for example /dev/hda for the primary Integrated Drive Electronics (IDE) disk. Create a Linux native partition and a swap partition, if needed. Please refer to cfdisk(8) or fdisk(8) if you do not yet know how to use the programs.
Remember the designation of the new partition (e.g., hda5). This book will refer to this as the LFS partition. Also remember the designation of the swap partition. These names will be needed later for the /etc/fstab file.
2.2.1. Other Partition Issues
Requests for advice on system partitioning are often posted on the LFS mailing lists. This is a highly subjective topic. The default size for most distributions is to use the entire drive with the exception of one small swap partition. This is not optimal for LFS for several reasons. It reduces flexibility, makes sharing of data across multiple distributions or LFS builds more difficult, makes backups more time consuming, and can waste disk space through inefficient allocation of file system structures.
2.2.1.1. The Root Partition
A root LFS partition (not to be confused with the /root directory) of ten gigabytes is a good compromise for most systems. It provides enough space to build LFS and most of BLFS, but is small enough so that multiple partitions can be easily created for experimentation.
2.2.1.2. The Swap Partition
Swapping is never good. Generally you can tell if a system is swapping by just listening to disk activity and observing how the system reacts to commands. The first reaction to swapping should be to check for an unreasonable command such as trying to edit a five gigabyte file. If swapping becomes a normal occurance, the best solution is to purchase more RAM for your system.
2.2.1.3. Convenience Partitions
There are several other partitions that are not required, but should be considered when designing a disk layout, The following list is not comprehensive, but is meant as a guide.
• /boot – Highly recommended. Use this partition to store kernels and other booting information. To minimize potential boot problems with larger disks, make this the first physical partition on your first disk drive. A partition size of 100 megabytes is quite adequate.
• /home – Highly recommended. Share your home directory and user customization across multiple distributions or LFS builds. The size is generally fairly large and depends on available disk space.
• /usr – A separate /usr partition is generally used if providing a server for a thin client or diskless workstation. It is normally not needed for LFS. A size of five gigabytes will handle most installations.
• /opt – This directory is most useful for BLFS where multiple installations of large packages like Gnome or KDE can be installed without embedding the files in the /usr hierarchy. If used, five to ten gigabytes is generally adequate.
• /tmp – A separate /tmp directory is rare, but useful if coufiguring a thin client. This partition, if used, will usually not need to exceed a couple of gigabytes.
• /usr/src – This partition is very useful for providing a location to store BLFS source files and share them across LFS builds. It can also be used as a location for building BLFS packages. A reasonably large partition of 30-50 gigabytes allows plenty of room.
Any separate partition that you want automatically mounted upon boot needs to be specified in the /etc/fstab. Details about how to specify partitions will be discussed in Section 8.2, “Creating the /etc/fstab File”.
2.3. Creating a File System on the Partition
Now that a blank partition has been set up, the file system can be created. The most widely-used system in the Linux world is the second extended file system (ext2), but with newer high-capacity hard disks, journaling file systems are becoming increasingly popular. The third extended filesystem (ext3) is a widely used enhancement to ext2, which adds journalling capabilities and is compatible with the E2fsprogs utilities. We will create an ext3 file system. Instructions for creating other file systems can be found at http://www.linuxfromscratch.org/blfs/view/svn/postlfs/ filesystems.html.
Note
Some host distributions use custom features in their filesystem creation tools (E2fsprogs). This can cause problems when booting into your new LFS in Chapter 9, as those features will not be supported by the LFS-installed E2fsprogs; you will get an error similar to “unsupported filesystem features, upgrade your e2fsprogs”. To check if your host system uses custom enhancements, run the following command:
debugfs -R feature /dev/<xxx>
If the output contains features other than has_journal, ext_attr, resize_inode, dir_index,
filetype, sparse_super, large_file or needs_recovery, then your host system may have
custom enhancements. In that case, to avoid later problems, you should compile the stock E2fsprogs package and use the resulting binaries to re-create the filesystem on your LFS partition:
cd /tmp
tar -xzvf /path/to/sources/e2fsprogs-1.41.10.tar.gz cd e2fsprogs-1.41.10
mkdir -v build cd build
../configure
make #note that we intentionally don't 'make install' here! ./misc/mke2fs -jv /dev/<xxx>
cd /tmp
rm -rfv e2fsprogs-1.41.10
If you are using an existing swap partition, there is no need to format it. If a new swap partition was created, it will need to be initialized with this command:
mkswap /dev/<yyy>
Replace <yyy> with the name of the swap partition.
2.4. Mounting the New Partition
Now that a file system has been created, the partition needs to be made accessible. In order to do this, the partition needs to be mounted at a chosen mount point. For the purposes of this book, it is assumed that the file system is mounted under /mnt/lfs, but the directory choice is up to you.
Choose a mount point and assign it to the LFS environment variable by running:
export LFS=/mnt/lfs
Next, create the mount point and mount the LFS file system by running:
mkdir -pv $LFS
mount -v -t ext3 /dev/<xxx> $LFS
If using multiple partitions for LFS (e.g., one for / and another for /usr), mount them using:
mkdir -pv $LFS
mount -v -t ext3 /dev/<xxx> $LFS mkdir -v $LFS/usr
mount -v -t ext3 /dev/<yyy> $LFS/usr
Replace <xxx> and <yyy> with the appropriate partition names.
Ensure that this new partition is not mounted with permissions that are too restrictive (such as the nosuid, nodev, or noatime options). Run the mount command without any parameters to see what options are set for the mounted LFS partition. If nosuid, nodev, and/or noatime are set, the partition will need to be remounted.
If you are using a swap partition, ensure that it is enabled using the swapon command:
/sbin/swapon -v /dev/<zzz>
Replace <zzz> with the name of the swap partition.
Chapter 3. Packages and Patches
3.1. Introduction
This chapter includes a list of packages that need to be downloaded in order to build a basic Linux system. The listed version numbers correspond to versions of the software that are known to work, and this book is based on their use. We highly recommend against using newer versions because the build commands for one version may not work with a newer version. The newest package versions may also have problems that require arounds. These work-arounds will be developed and stabilized in the development version of the book.
Download locations may not always be accessible. If a download location has changed since this book was published, Google (http://www.google.com/) provides a useful search engine for most packages. If this search is unsuccessful, try one of the alternative means of downloading discussed at http://www.linuxfromscratch.org/lfs/ packages.html#packages.
Downloaded packages and patches will need to be stored somewhere that is conveniently available throughout the entire build. A working directory is also required to unpack the sources and build them. $LFS/sources can be used both as the place to store the tarballs and patches and as a working directory. By using this directory, the required elements will be located on the LFS partition and will be available during all stages of the building process.
To create this directory, execute the following command, as user root, before starting the download session:
mkdir -v $LFS/sources
Make this directory writable and sticky. “Sticky” means that even if multiple users have write permission on a directory, only the owner of a file can delete the file within a sticky directory. The following command will enable the write and sticky modes:
chmod -v a+wt $LFS/sources
An easy way to download all of the packages and patches is by using wget-list as an input to wget.
3.2. All Packages
Download or otherwise obtain the following packages:
• Autoconf (2.65) - 1,301 KB:
Home page: http://www.gnu.org/software/autoconf/
Download: http://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.bz2 MD5 sum: a6de1cc6434cd64038b0a0ae4e252b33
• Automake (1.11.1) - 1,042 KB:
Home page: http://www.gnu.org/software/automake/
Download: http://ftp.gnu.org/gnu/automake/automake-1.11.1.tar.bz2 MD5 sum: c2972c4d9b3e29c03d5f2af86249876f
• Bash (4.1) - 6,444 KB:
• Binutils (2.20) - 17,096 KB:
Home page: http://sources.redhat.com/binutils/
Download: http://ftp.gnu.org/gnu/binutils/binutils-2.20.tar.bz2 MD5 sum: ee2d3e996e9a2d669808713360fa96f8
• Bison (2.4.1) - 1,433 KB:
Home page: http://www.gnu.org/software/bison/
Download: http://ftp.gnu.org/gnu/bison/bison-2.4.1.tar.bz2 MD5 sum: 84e80a2a192c1a4c02d43fbf2bcc4ca4
• Bzip2 (1.0.5) - 822 KB:
Home page: http://www.bzip.org/
Download: http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz MD5 sum: 3c15a0c8d1d3ee1c46a1634d00617b1a
• Coreutils (8.4) - 10,273 KB:
Home page: http://www.gnu.org/software/coreutils/
Download: http://ftp.gnu.org/gnu/coreutils/coreutils-8.4.tar.gz MD5 sum: 56f549854d723d9dcebb77919019df55
• DejaGNU (1.4.4) - 1,055 KB:
Home page: http://www.gnu.org/software/dejagnu/
Download: http://ftp.gnu.org/gnu/dejagnu/dejagnu-1.4.4.tar.gz MD5 sum: 053f18fd5d00873de365413cab17a666
• Diffutils (2.8.1) - 762 KB:
Home page: http://www.gnu.org/software/diffutils/
Download: http://ftp.gnu.org/gnu/diffutils/diffutils-2.8.1.tar.gz MD5 sum: 71f9c5ae19b60608f6c7f162da86a428
• E2fsprogs (1.41.10) - 4,363 KB:
Home page: http://e2fsprogs.sourceforge.net/
Download: http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.41.10.tar.gz MD5 sum: f9c7bb5c036a119453ce02fa871038da
• Expect (5.43.0) - 513 KB:
Home page: http://expect.nist.gov/
Download: http://expect.nist.gov/src/expect-5.43.0.tar.gz MD5 sum: 43e1dc0e0bc9492cf2e1a6f59f276bc3
• File (5.04) - 607 KB:
Home page: http://www.darwinsys.com/file/
• Findutils (4.4.2) - 2,100 KB:
Home page: http://www.gnu.org/software/findutils/
Download: http://ftp.gnu.org/gnu/findutils/findutils-4.4.2.tar.gz MD5 sum: 351cc4adb07d54877fa15f75fb77d39f
• Flex (2.5.35) - 1,227 KB:
Home page: http://flex.sourceforge.net
Download: http://prdownloads.sourceforge.net/flex/flex-2.5.35.tar.bz2 MD5 sum: 10714e50cea54dc7a227e3eddcd44d57
• Gawk (3.1.7) - 2,310 KB:
Home page: http://www.gnu.org/software/gawk/
Download: http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2 MD5 sum: 674cc5875714315c490b26293d36dfcf
• GCC (4.4.3) - 61,470 KB:
Home page: http://gcc.gnu.org/
Download: http://ftp.gnu.org/gnu/gcc/gcc-4.4.3/gcc-4.4.3.tar.bz2 MD5 sum: fe1ca818fc6d2caeffc9051fe67ff103
• GDBM (1.8.3) - 223 KB:
Home page: http://www.gnu.org/software/gdbm/
Download: http://ftp.gnu.org/gnu/gdbm/gdbm-1.8.3.tar.gz MD5 sum: 1d1b1d5c0245b1c00aff92da751e9aa1
• Gettext (0.17) - 11,368 KB:
Home page: http://www.gnu.org/software/gettext/
Download: http://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz MD5 sum: 58a2bc6d39c0ba57823034d55d65d606
• Glibc (2.11.1) - 15,302 KB:
Home page: http://www.gnu.org/software/libc/
Download: http://ftp.gnu.org/gnu/glibc/glibc-2.11.1.tar.bz2 MD5 sum: 6856d5d8b1239556687f0d1217f3f266
• GMP (5.0.0) - 1,907 KB:
Home page: http://www.gnu.org/software/gmp/
Download: http://ftp.gnu.org/gnu/gmp/gmp-5.0.0.tar.bz2 MD5 sum: 46fc3a85a3fecc98a4bbd498a83ee459
• Grep (2.5.4) - 706 KB:
Home page: http://www.gnu.org/software/grep/
Download: http://ftp.gnu.org/gnu/grep/grep-2.5.4.tar.bz2 MD5 sum: 5650ee2ae6ea4b39e9459d7d0585b315
• Groff (1.20.1) - 3,510 KB:
Home page: http://www.gnu.org/software/groff/
Download: http://ftp.gnu.org/gnu/groff/groff-1.20.1.tar.gz MD5 sum: 48fa768dd6fdeb7968041dd5ae8e2b02
• GRUB (1.97.2) - 1,219 KB:
Home page: http://www.gnu.org/software/grub/
• Gzip (1.4) - 886 KB:
Home page: http://www.gzip.org/
Download: http://ftp.gnu.org/gnu/gzip/gzip-1.4.tar.gz MD5 sum: e381b8506210c794278f5527cba0e765
• Iana-Etc (2.30) - 201 KB:
Home page: http://sethwklein.net/iana-etc
Download: http://sethwklein.net/iana-etc-2.30.tar.bz2 MD5 sum: 3ba3afb1d1b261383d247f46cb135ee8
• Inetutils (1.7) - 1,861 KB:
Home page: http://www.gnu.org/software/inetutils/
Download: http://ftp.gnu.org/gnu/inetutils/inetutils-1.7.tar.gz MD5 sum: a1d5a01b0ab8a7e596ac4cff0cce7129
• IPRoute2 (2.6.31) - 364 KB:
Home page: http://linux-net.osdl.org/index.php/Iproute2
Download: http://developer.osdl.org/dev/iproute2/download/iproute2-2.6.31.tar.bz2 MD5 sum: 230f35282a95451622f3e8394f9cd80a
• Kbd (1.15.1) - 1,081 KB:
Download: http://ftp.altlinux.com/pub/people/legion/kbd/kbd-1.15.1.tar.gz MD5 sum: f997c490fe5ede839aacf31da6c4eb06
• Less (436) - 297 KB:
Home page: http://www.greenwoodsoftware.com/less/
Download: http://www.greenwoodsoftware.com/less/less-436.tar.gz MD5 sum: 817bf051953ad2dea825a1cdf460caa4
• LFS-Bootscripts (20100124) - 42 KB:
Download: http://www.linuxfromscratch.org/lfs/downloads/6.6/lfs-bootscripts-20100124.tar.bz2 MD5 sum: 259968939ae12a0a791acbdc07f5bc52
• Libtool (2.2.6b) - 2,292 KB:
Home page: http://www.gnu.org/software/libtool/
Download: http://ftp.gnu.org/gnu/libtool/libtool-2.2.6b.tar.gz MD5 sum: 07da460450490148c6d2df0f21481a25
• Linux (2.6.32.8) - 62,864 KB:
Home page: http://www.kernel.org/
Download: http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.8.tar.bz2 MD5 sum: 82023ede52f067fcc55c5e70b02e48ae
• M4 (1.4.13) - 985 KB:
Home page: http://www.gnu.org/software/m4/
Download: http://ftp.gnu.org/gnu/m4/m4-1.4.13.tar.bz2 MD5 sum: 28f9ccd3ac4da45409251008b911d677
• Make (3.81) - 1,125 KB:
Home page: http://www.gnu.org/software/make/
Download: http://ftp.gnu.org/gnu/make/make-3.81.tar.bz2 MD5 sum: 354853e0b2da90c527e35aabb8d6f1e6
• Man-DB (2.5.6) - 2,045 KB:
Home page: http://www.nongnu.org/man-db/
Download: http://download.savannah.gnu.org/releases/man-db/man-db-2.5.6.tar.gz MD5 sum: 69585b19c5600a863f1a0d7b7f283975
• Man-pages (3.23) - 1,066 KB:
Home page: http://www.kernel.org/doc/man-pages/
Download: http://www.kernel.org/pub/linux/docs/manpages/Archive/man-pages-3.23.tar.bz2 MD5 sum: 153704ffa27160d708e0e8c56c1da58f
• Module-Init-Tools (3.11.1) - 196 KB:
Home page: http://www.kerneltools.org/KernelTools.org
Download: http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.11.1.tar.bz2 MD5 sum: 28dfcb9e24cdbeb12b99ac1eb8af7dea
• MPFR (2.4.2) - 1,053 KB:
Home page: http://www.mpfr.org/
Download: http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2 MD5 sum: 89e59fe665e2b3ad44a6789f40b059a0
• Ncurses (5.7) - 2,388 KB:
Home page: http://www.gnu.org/software/ncurses/
Download: ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.7.tar.gz MD5 sum: cce05daf61a64501ef6cd8da1f727ec6
• Patch (2.6.1) - 248 KB:
Home page: http://directory.fsf.org/project/patch/
Download: http://ftp.gnu.org/gnu/patch/patch-2.6.1.tar.bz2 MD5 sum: 0818d1763ae0c4281bcdc63cdac0b2c0
• Perl (5.10.1) - 11,336 KB:
Home page: http://cpan.org/
Download: http://cpan.org/src/5.0/perl-5.10.1.tar.bz2 MD5 sum: 82400c6d34f7b7b43d0196c76cd2bbb1
• Pkg-config (0.23) - 1,009 KB:
Home page: http://pkg-config.freedesktop.org/