diff --git a/appendixa/makedev-desc.xml b/appendixa/makedev-desc.xml index beae1f727..28a59484f 100644 --- a/appendixa/makedev-desc.xml +++ b/appendixa/makedev-desc.xml @@ -8,10 +8,11 @@ Descriptions MAKEDEV -MAKEDEV is a script that can help in creating the necessary static -device files that usually reside in the /dev directory. More -information on device nodes can be found in the Linux Kernel source tree -in Documentation/devices.txt. +MAKEDEV is a script that creates the necessary +static device nodes usually residing in the +/dev directory. +Detailed information on device nodes can be found in the Linux kernel source +tree in Documentation/devices.txt. diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 0992e30c8..803188c8e 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -53,6 +53,9 @@ +September 8th, 2002 [timothy]: Chapter 06: Applied Alex's +grammar changes patch. + September 7th, 2002 [timothy]: Chapter 06 - Gzip: Added gzip-1.2.4b.patch. diff --git a/chapter06/aboutdebug.xml b/chapter06/aboutdebug.xml index a4ffefc52..8d03387fe 100644 --- a/chapter06/aboutdebug.xml +++ b/chapter06/aboutdebug.xml @@ -2,49 +2,49 @@ About debugging symbols -Most programs and libraries by default are compiled with debugging -symbols (gcc option -g). +Most programs and libraries are by default compiled with debugging +symbols included (with gcc option -g). -A program compiled with debugging symbols means a user can run a program -or library through a debugger and the debugger's output will be user -friendly. These debugging symbols also enlarge the program or library -significantly. - -Before you start wondering whether these debugging symbols really make a -big difference, here are some statistics. Use them to draw your own -conclusion. +When debugging a program or library that was compiled with debugging +information included, the debugger can give you not only memory addresses +but also the names of the routines and variables. + +But the inclusion of these debugging symbols enlarges a program or +library significantly. To get an idea of the amount of space these symbols +occupy, have a look at the following: -A dynamic Bash binary -with debugging symbols: 1.2 MB +a bash binary +with debugging symbols: 1200 KB -A dynamic Bash binary -without debugging symbols: 478 KB +a bash binary +without debugging symbols: 480 KB -/lib and /usr/lib (glibc -and gcc files) with debugging symbols: 87 MB +glibc and gcc files (/lib and /usr/lib) +with debugging symbols: 87 MB -/lib and /usr/lib (glibc -and gcc files) without debugging symbols: 16 MB +glibc and gcc files +without debugging symbols: 16 MB -Sizes vary depending on which compiler was used and which C library -version was used to link dynamic programs against, but results will be -similar if you compare programs with and without debugging symbols. +Sizes may vary a little, depending on which compiler was used and +which C library. But when comparing programs with and without debugging +symbols, the difference will generally be a factor between 2 and 5. -To remove debugging symbols from a binary (must be an a.out or ELF -binary) run strip --strip-debug filename. Wildcards -can be used to strip debugging symbols from multiple files (use something -like strip --strip-debug $LFS/usr/bin/*). Most -people will probably never use a debugger on software, so by removing -those symbols a lot of disk space can be regained. +As most people will probably never use a debugger on their system +software, a lot of disk space can be regained by removing these symbols . + +To remove debugging symbols from a binary (which must be an a.out +or ELF binary), run strip --strip-debug filename. +Wildcards can be used to treat multiple files (use something like +strip --strip-debug $LFS/static/bin/*). For your convenience, chapter 9 includes one simple command to strip -all debugging symbols from the programs and libraries on your system. You -might find additional information in the optimization hint which can be -found at . +all debugging symbols from all programs and libraries on your system. +Additional information on optimization you can find in the hint at +. diff --git a/chapter06/changingowner.xml b/chapter06/changingowner.xml index f0bdee09e..b909b5207 100644 --- a/chapter06/changingowner.xml +++ b/chapter06/changingowner.xml @@ -2,15 +2,20 @@ Changing ownership -Now we're in chroot, it is time to change the ownership of -the files and directories that were installed in chapter 5 to root. -Run the following command to do so: +The first thing we'll do, now that we're root, +is change the ownership of the files and directories installed in chapter 5 +to root -- because when later we don't delete the +/static directory and start adding +new users, one of these users might end up owning the statically linked +programs, which is not a good idea. -chown -R 0:0 / +Run the following command to make root the owner of all the statically +linked programs: -This command changes the ownership of the root partition to -root. The command uses 0:0 instead of root:root, because the user name -"root" can't be resolved, as glibc is not installed yet. +chown -R 0:0 /static + +The command uses "0:0" instead of "root:root", because there is no way +to resolve the name "root", as glibc hasn't been installed yet. diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 8f6e8f3d9..d211ee230 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -7,10 +7,10 @@ &c6-chroot; &c6-changingowner; &c6-creatingdirs; -&c6-pwdgroup; -&c6-mtablink; &c6-mountproc; +&c6-mtablink; &c6-createfiles; +&c6-pwdgroup; &c6-makedev; &c6-kernel; &c6-manpages; diff --git a/chapter06/chroot.xml b/chapter06/chroot.xml index af525df62..dd220020a 100644 --- a/chapter06/chroot.xml +++ b/chapter06/chroot.xml @@ -2,35 +2,41 @@ Entering the chroot'ed environment -It's time to enter our chroot'ed environment in order to install the -rest of the software we need. Before you can chroot you need to change to -the root user since only user -root can use the chroot -command. +It is time to enter the chroot'ed environment in order to begin installing +the packages we need. Before you can chroot, however, you need to become +root, since only root +can execute the chroot command. -Enter the following commands to enter the chroot'ed environment. From -this point on there's no need to use the $LFS variable anymore, because -everything a user does will be restricted to the LFS partition (since / is -actually /mnt/lfs, but the shell doesn't know that). +Become root and run the following command +to enter the chroot'ed environment: -&c6-chrootcmd; +chroot $LFS /static/bin/env -i \ +    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \ +    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/static/bin \ +    /static/bin/bash --login + -The -i option will clear all environment variables for as long as you -are in the chroot'ed environment and only the HOME, TERM, PS1 and PATH -variables are set. The TERM=$TERM construction will set the TERM variable -inside chroot to the same value as outside chroot which is needed for -programs like vim and less to operate properly. If you need other variables -present, such as CFLAGS or CXXFLAGS, you need to set them again. +The -i option given to the +env command will clear all variables of the chroot'ed +environment. After that, only the HOME, TERM, PS1 and PATH variables are +set again. The TERM=$TERM construct will set the TERM variable inside chroot +to the same value as outside chroot; this variable is needed for programs +like vim and less to operate properly. If you need other variables present, +such as CFLAGS or CXXFLAGS, this is a good place to set them again. -Now that we are inside a chroot'ed environment, we can continue to -install all the basic system software. You have to make sure all the -following commands in this and following chapters are run from within the -chroot'ed environment. If you ever leave this environment for any reason -(when rebooting for example) you must remember to enter chroot and mount -$LFS/proc again (as will be discussed later) before continuing with the -book. +From this point on there's no need anymore to use the $LFS variable, +because everything you do will be restricted to the LFS file system -- since +what the shell thinks is / is actually +/mnt/lfs. -Note that the bash prompt will contain "I have no name!" This is -normal because Glibc hasn't been installed yet. +You have to make sure all the commands in the rest of this chapter and +in the following chapters are run from within the chroot'ed environment. +If you ever leave this environment for any reason (rebooting for example), +you must remember to again enter chroot and mount proc (discussed later) +before continuing with the installations. + +Note that the bash prompt will say "I have no name!" This is +normal, as the Glibc package hasn't been installed yet. + diff --git a/chapter06/chrootcmd.xml b/chapter06/chrootcmd.xml index 7e26287f8..7564165da 100644 --- a/chapter06/chrootcmd.xml +++ b/chapter06/chrootcmd.xml @@ -1,4 +1,3 @@ -chroot $LFS /static/bin/env -i HOME=/root TERM=$TERM \ -    PS1='\u:\w\$ ' \ -    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/static/bin \ -    /static/bin/bash --login + +[delete me] + diff --git a/chapter06/createfiles.xml b/chapter06/createfiles.xml index d71a19491..47ccefb90 100644 --- a/chapter06/createfiles.xml +++ b/chapter06/createfiles.xml @@ -3,11 +3,12 @@ Some programs hard-wire paths to programs which don't exist yet. In -order to satisfy these programs, we create the /bin/bash -and /bin/sh symlinks. +order to satisfy these programs, we create the symbolic links +/bin/bash and /bin/sh, both +pointing to the static bash program. -Create the /bin/bash and /bin/sh symlinks by running the following -commands: +Create the /bin/bash and /bin/sh +symlinks by running the following commands: ln -s /static/bin/bash /bin/bash && ln -s bash /bin/sh diff --git a/chapter06/creatingdirs.xml b/chapter06/creatingdirs.xml index ac15f0077..cb5431214 100644 --- a/chapter06/creatingdirs.xml +++ b/chapter06/creatingdirs.xml @@ -2,10 +2,9 @@ Creating directories -Let's now create the directory tree on the LFS partition based on -the FHS standard, which can be found at -. -Issuing the following commands will create a default directory layout: +Let's now create some structure in our LFS file system, let's create +a directory tree. Issuing the following commands will create a more or less +standard tree: mkdir -p /{bin,boot,dev/pts,etc/opt,home,lib,mnt,proc} && mkdir -p /{root,sbin,tmp,usr/local,var,opt} && @@ -23,35 +22,39 @@ mkdir /opt/{bin,doc,include,info} && mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}} && ln -s ../var/tmp /usr -Normally, directories are created with permission mode 755, which isn't -desired for all directories. The first change is a mode 0750 for the -/root directory. This is to make sure that not just everybody can -enter the /root directory (the same a user would do with his /home/username -directory). The second change is a mode 1777 for the tmp -directories. In this way any user can write to the /tmp and /var/tmp -directories, but cannot remove other users's files from them (the latter is prohibited -by the so-called "sticky bit" -- bit 1 in the 1777 bit mask). +Directories are by default created with permission mode 755, but this +isn't desirable for all directories. We will make two changes: one to the home +directory of root, and another to the directories for temporary files. chmod 0750 /root && chmod 1777 /tmp /var/tmp +The first mode change ensures that not just everybody can enter the +/root directory -- the same +a normal user would do with his or her home directory. +The second mode change makes sure that any user can write to the +/tmp and +/var/tmp directories, but +cannot remove other users's files from them. The latter is prohibited +by the so-called "sticky bit" -- the highest bit in the 1777 bit mask. + Now that the directories are created, copy the source files that were -downloaded in chapter 3 to some subdirectory under /usr/src (you -will need to create the desired directory yourself). +downloaded in chapter 3 to some subdirectory under +/usr/src (you +will have to create the desired subdirectory yourself). -FHS compliance notes +FHS compliance note -The FHS stipulates that the /usr/local directory should contain the -bin, games, include, lib, man, sbin, and share subdirectories. You can -alter your /usr/local directory yourself if you want your system to be -FHS-compliant. - -Also, the standard says that there should exist a /usr/share/games -directory, which we don't much like for a base system. But feel free to -make your system FHS-compliant if you wish. The FHS isn't precise as -to the structure of the /usr/local/share subdirectories, so we took the -liberty of creating the directories that we felt were needed. +We have based our directory tree on the FHS standard (available at +). Besides the above created +tree this standard stipulates the existence of +/usr/local/games and +/usr/share/games, but we don't +much like these for a base system. However, feel free to make your system +FHS-compliant. As to the structure of the +/usr/local/share subdirectory the FHS +isn't precise, so we created here the directories that we think are needed. diff --git a/chapter06/introduction.xml b/chapter06/introduction.xml index fec62f4b3..dfe834c24 100644 --- a/chapter06/introduction.xml +++ b/chapter06/introduction.xml @@ -7,29 +7,31 @@ constructing our LFS system in earnest. That is, we chroot into our temporary mini Linux system, create some auxiliary things, and then start installing all the packages, one by one. -The installation of all the software is pretty straightforward, and -you will probably think it would be so much easier and shorter to give -the generic installation instructions for a package here and only explain -in full the installation of those packages that require an alternate -method. Although we agree with that, we choose to give the -full instructions for each and every package, simply to avoid any -possible confusion and errors. +The installation of all this software is pretty straightforward, +and you will probably think it would be much shorter to give here +the generic installation instructions and explain in full only the +installation of those packages that require an alternate method. +Although we agree with that, we nevertheless choose to give the +full instructions for each and every package, simply to minimize +the possibilities for mistakes. -If you plan to use compiler optimization for the packages -installed in this chapter, take a look at the optimization hint -at . -Compiler optimization can make a program run -faster, but may also cause compilation problems. If you run into problems -when using optimization, always try it without optimization to see if -the problem persists. +If you plan to use compiler optimizations in this chapter, +take a look at the optimization hint at +. +Compiler optimizations can make a program run faster, but they +may also cause compilation difficulties. If a package refuses +to compile when using optimization, try to compile it without +optimization and see if the problem goes away. -Please refrain from installing more than one package at a time, even -if it may save you time (especially with dual CPU machines). If you install -the wrong package at the wrong time, it may hard-wire program paths to -$LFS/static which will cause the -programs to stop working once the static directory is removed. The order -packages are installed in this chapter have to be followed exactly to be -sure nothing is hard-wiring the static paths. +The order in which packages are installed in this chapter has +to be strictly followed, to ensure that no program gets a path referring +to /static hard-wired into it. +For the same reason, do not compile packages +in parallel. Compiling in parallel may save you some time (especially on +dual-CPU machines), but it could result in a program containing a +hard-wired path to /static, +which will cause the program to stop working when the static directory +is removed. diff --git a/chapter06/makedev-exp.xml b/chapter06/makedev-exp.xml index 95e0242d0..aa8e4b05d 100644 --- a/chapter06/makedev-exp.xml +++ b/chapter06/makedev-exp.xml @@ -2,11 +2,12 @@ Command explanations ./MAKEDEV -v generic: This creates a whole -bunch of generic devices. Normally, these are all the devices you need. It's possible -that you are missing some special devices that are needed for your hardware -configuration. Create them with ./MAKEDEV -v <device>. -The generic-nopty option does a similar job, but skips -some devices which are not needed if you are using devpts. +bunch of devices. Normally, these are all the devices you will need. But it +is possible that some special devices needed for your hardware configuration +are missing. Create these with ./MAKEDEV -v <device>. +The generic-nopty option mostly creates the same +devices as generic-nopty, but skips those that aren't +needed if you are using devpts. diff --git a/chapter06/makedev-inst.xml b/chapter06/makedev-inst.xml index a5d093dc5..3b93899d7 100644 --- a/chapter06/makedev-inst.xml +++ b/chapter06/makedev-inst.xml @@ -1,33 +1,31 @@ Creating devices -Note: the MAKEDEV-&makedev-version;.bz2 file you have unpacked is not -an archive, so it won't create a directory for you to cd into. +(Note that unpacking the MAKEDEV-&makedev-version;.bz2 file doesn't create +a directory for you to cd into, as the file only contains a script.) -Create the device files by running the following commands: +Prepare for the creation of the device files by running the +following commands: cp MAKEDEV-&makedev-version; /dev/MAKEDEV && cd /dev && chmod 754 MAKEDEV -Now, depending on whether you are going to use devpts or not, you -can run one of two commands: - -If you do not intend to use devpts, run: +Most people will now want to create devices by running: ./MAKEDEV -v generic -If you do intend to use devpts, then run: +But if you intend to use devpts, then run this instead: ./MAKEDEV -v generic-nopty -Note that if you aren't sure, it's best to use -the ./MAKEDEV -v generic command as this will -ensure you have the devices you need. If you are sure you are going to -use devpts however, the other command makes sure that you don't create a -set of devices which you don't require. +Note that if you aren't sure, it's best to use the +./MAKEDEV -v generic command as this will ensure you +have all the devices you need. But if you are certain you are going to use +devpts, the other command skips creating a set of devices you won't need. -MAKEDEV will create hda[1-20] to hdh[1-20] and such, but keep in mind -that you may not be able to use all of these devices due to kernel -limits on the maximum number of partitions. +MAKEDEV will create hda[1-20] to hdh[1-20] and +many more of such disk device nodes, but keep in mind that you probably won't +be able to use all of these, due to kernel limits on the maximum number of +partitions. diff --git a/chapter06/mountproc.xml b/chapter06/mountproc.xml index 060859899..e7fc85ec6 100644 --- a/chapter06/mountproc.xml +++ b/chapter06/mountproc.xml @@ -1,16 +1,17 @@ -Mounting /proc file system +Mounting the proc file system In order for certain programs to function properly, the proc file -system must be available from within the chroot'ed environment. -A file system can be mounted as many times and in as many places -as you'd like, so it's not a problem that the proc file system is already -mounted on your host system, especially so because proc is a +system must be available within the chroot'ed environment. +As a file system can be mounted as many times and in as many places +as you like, it's not a problem that the proc file system is already +mounted on your host system -- especially so because proc is a virtual file system. -The proc file system is mounted under /proc by running the -following command. +The proc file system is mounted under +/proc by running the +following command: mount proc /proc -t proc diff --git a/chapter06/mtablink.xml b/chapter06/mtablink.xml index a573bd62b..e40e9bc10 100644 --- a/chapter06/mtablink.xml +++ b/chapter06/mtablink.xml @@ -1,24 +1,25 @@ -Creating the /etc/mtab symlink +Creating the mtab symlink The next thing to do is to create a symlink pointing from -/etc/mtab to /proc/mounts. This is done using the following -command: +/etc/mtab to /proc/mounts. +This is done using the following command: ln -s /proc/mounts /etc/mtab -Creating this symlink avoids problems which can occur if / is -mounted read-only and the information in /etc/mtab is stale (i.e. out of -date). By creating the symlink to /proc/mounts, we ensure that -/etc/mtab will always be up-to-date. +Creating this symlink avoids problems which can occur if +/ is mounted read-only and the +information in /etc/mtab is stale (i.e. out of date). +By creating the symlink to /proc/mounts, we ensure that +the information on currently mounted devices is always up-to-date. -Note that using this symlink requires that you have /proc -filesystem support compiled into your kernel. This is included by -default and should not be removed unless you really -know what you are doing as many more things than just the /etc/mtab -symlink depend on /proc being present. In summary, make sure you have -/proc filesystem support in your kernel. +Note that using this symlink requires that you have support for the +proc filesystem compiled into your kernel. This support is included by +default, and should not be removed unless you really +know what you are doing, as some more things besides the +/etc/mtab symlink depend on proc being present. +In short, make sure you have proc filesystem support in your kernel. diff --git a/chapter06/pwdgroup.xml b/chapter06/pwdgroup.xml index bf2f0315d..f9c648b8c 100644 --- a/chapter06/pwdgroup.xml +++ b/chapter06/pwdgroup.xml @@ -1,25 +1,21 @@ -Creating passwd and group files +Creating the passwd and group files -In order for the user and the group "root" to be recognized and to be -able to login, there need to be entries in the /etc/passwd and /etc/group file. -Besides the group "root", a couple of other groups are recommended or needed -by some packages. The groups created below aren't part of any standard. -The LSB only recommends a group "bin" with GID 1 to be present besides -"root". Other group names and GIDs can be chosen by the user. -Well-written packages don't depend on GID numbers, but use the group's -name; so it doesn't matter which GID a group has. Since there -aren't any standards for groups, the groups created here are the groups the -MAKEDEV script (the script that creates the device files in the /dev -directory) mentions. +In order for root to be able to login and for the name "root" to be +recognized, there need to be relevant entries in the +/etc/passwd and +/etc/group files. -Create a new file /etc/passwd by running the +Create the /etc/passwd file by running the following command: echo "root:x:0:0:root:/root:/bin/bash" > /etc/passwd -Create a new file /etc/group by running the +The actual password for root (the "x" here is just a placeholder) will +be set later. + +Create the /etc/group file by running the following command: cat > /etc/group << "EOF" @@ -37,5 +33,12 @@ dialout:x:10: audio:x:11: EOF +The created groups aren't part of any standard -- they are the groups +that the MAKEDEV script in the next section uses. +Besides the group "root", the LSB recommends only a group "bin" with a GID +of 1 to be present. All other group names and GIDs can be chosen freely by +the user, as well-written packages don't depend on GID numbers but use the +group's name. +