diff --git a/chapter03/creatingdirs.xml b/chapter03/creatingdirs.xml deleted file mode 100644 index fb6d61244..000000000 --- a/chapter03/creatingdirs.xml +++ /dev/null @@ -1,77 +0,0 @@ - -Creating directories - - -Before we start creating directories, we need to check the base -system's umask setting. To do this, we run -umask. The result should be 022. If it isn't, -then run the following command to ensure that the directories will be -created with the correct permissions: - -umask 022 - -We would advise you to make sure that the umask is set to 022 -throughout your LFS installation. - -Let's now create the directory tree on the LFS partition based on the FHS -standard, which can be found at http://www.pathname.com/fhs/. -Issuing the following commands will create a default directory layout: - -cd $LFS && -mkdir -p bin boot dev/pts etc/opt home lib mnt proc root sbin tmp var opt && -for dirname in $LFS/usr $LFS/usr/local -   do -   mkdir $dirname -   cd $dirname -   mkdir bin etc include lib sbin share src var -   ln -s share/man -   ln -s share/doc -   ln -s share/info -   cd $dirname/share -   mkdir dict doc info locale man nls misc terminfo zoneinfo -   cd $dirname/share/man -   mkdir man{1,2,3,4,5,6,7,8} -done && -cd $LFS/var && -mkdir -p lock log mail run spool tmp opt cache lib/misc local && -cd $LFS/opt && -mkdir bin doc include info lib man && -cd $LFS/usr && -ln -s ../var/tmp - -Normally, directories are created with permission mode 755, which isn't -desired for all directories. The first change is a mode 0750 for the -$LFS/root directory. This is to make sure that not just everybody can -enter the /root directory (the same a user would do with /home/username -directories). The second change is a mode 1777 for the tmp -directories. This way, any user can write data to the /tmp or /var/tmp -directory but cannot remove another user's files (the latter is caused -by the so-called "sticky bit" - bit 1 of the 1777 bit mask). - -cd $LFS && -chmod 0750 root && -chmod 1777 tmp var/tmp - -Now that the directories are created, copy the source files that were -downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you -will need to create the desired directory yourself). - - -FHS compliance notes - -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 needed. - - - - - diff --git a/chapter05/creatingdirs.xml b/chapter05/creatingdirs.xml new file mode 100644 index 000000000..8c0c369a5 --- /dev/null +++ b/chapter05/creatingdirs.xml @@ -0,0 +1,66 @@ + +Creating directories + + +Let's now create the directory tree on the LFS partition based on +the FHS standard, which can be found at +http://www.pathname.com/fhs/. +Issuing the following commands will create a default directory layout: + +cd $LFS && +mkdir -p bin boot dev/pts etc/opt home lib mnt proc root sbin tmp var opt && +for dirname in $LFS/usr $LFS/usr/local +   do +   mkdir $dirname +   cd $dirname +   mkdir bin etc include lib sbin share src var +   ln -s share/man +   ln -s share/doc +   ln -s share/info +   cd $dirname/share +   mkdir dict doc info locale man nls misc terminfo zoneinfo +   cd $dirname/share/man +   mkdir man{1,2,3,4,5,6,7,8} +done && +cd $LFS/var && +mkdir -p lock log mail run spool tmp opt cache lib/misc local && +cd $LFS/opt && +mkdir bin doc include info lib man && +cd $LFS/usr && +ln -s ../var/tmp + +Normally, directories are created with permission mode 755, which isn't +desired for all directories. The first change is a mode 0750 for the +$LFS/root directory. This is to make sure that not just everybody can +enter the /root directory (the same a user would do with /home/username +directories). The second change is a mode 1777 for the tmp +directories. This way, any user can write data to the /tmp or /var/tmp +directory but cannot remove another user's files (the latter is caused +by the so-called "sticky bit" - bit 1 of the 1777 bit mask). + +cd $LFS && +chmod 0750 root && +chmod 1777 tmp var/tmp + +Now that the directories are created, copy the source files that were +downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you +will need to create the desired directory yourself). + + +FHS compliance notes + +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 needed. + + + + + diff --git a/chapter05/installasroot.xml b/chapter05/installasroot.xml deleted file mode 100644 index e959ca853..000000000 --- a/chapter05/installasroot.xml +++ /dev/null @@ -1,20 +0,0 @@ - -Install all software as user root - - -It's best to log in as root or su's to root when installing the -packages. That way you are assured that all files are owned by user and -group root (and not owned by the userid of the non-root user), and if a -package wants to set special permissions, it can do so without problems -due to non-root access. - -The documentation that comes with Glibc, Gcc, and other -packages recommend not to compile the packages as user root. We -feel it's safe to ignore that recommendation and compile as user root -anyway. Hundreds of people using LFS have done so without any problems -whatsoever, and we haven't encountered any bugs in the compile processes -that cause harm. So it's pretty safe (never can be 100% safe though, so -it's up to you what you end up doing). - - - diff --git a/chapter05/installasuser.xml b/chapter05/installasuser.xml new file mode 100644 index 000000000..4fff1a36e --- /dev/null +++ b/chapter05/installasuser.xml @@ -0,0 +1,55 @@ + +Install all software as an unprivileged user + + +When you are logged in as root during chapter 5, it is possible +that some files of your host system will be overwritten by the ones +you'll build in chapter 5. There can be all kinds of reasons for this +to happen, for example because the $LFS environment variable is not +set. Overwriting some files from your host system will most likely +cause all kinds of problems, so it's a good idea to be logged in as +an unprivileged user during chapter 5. To make sure the environment +is as clean as possible, we'll create a new user lfs that can be +used while building the static installation. Issuing the following +commands as root will create a new user "lfs": + +useradd -s /bin/bash -m lfs +passwd lfs + +Now it's time to change the permissions on your LFS partitions +so user "lfs" will have write access to it. Run the following command +as root to change the ownership of the LFS partition to user "lfs": + +chown lfs $LFS + +Now you can login as user "lfs". You can do this two ways: either +the normal way through the console or the display manager, or with +su - lfs. When you're working as user "lfs", type +the following commands to setup a good environment to work in: + +cat >~/.bash_profile <<"EOF" +#!/bin/sh +umask 022 + +LFS=/mnt/lfs +LC_ALL=POSIX +export LFS LC_ALL +EOF +source ~/.bash_profile + +This profile makes sure the umask is set to 022 so newly created +files and directories will have the correct permission. It is advisable +to keep this setting throughout your LFS installation. Also, the $LFS +and $LC_ALL environment variables are set. $LFS has been explained in +previous chapters already. $LC_ALL is a variable that is used for +internationalization. + +When your host distribution uses a glibc version older than 2.2.4, +having $LC_ALL set to something else than "C" or "POSIX" while working +through chapter 5 may cause trouble when you've exited the chrooted +environment of chapter 6 and try to return to it. By setting this to +"POSIX" ("C" is an alias for "POSIX") we ensure that everything will +work as expected in the chrooted environment. + + + diff --git a/chapter06/changingowner.xml b/chapter06/changingowner.xml new file mode 100644 index 000000000..9a1592007 --- /dev/null +++ b/chapter06/changingowner.xml @@ -0,0 +1,19 @@ + +Changing ownership of the LFS partition + + +Now we're in chroot, it is a good time to change the ownership of +all files and directories that were installed in chapter 5 back to root. +Run the following commands to do so: + +chown 0.0 / /proc && +chown -R 0.0 /bin /boot /dev /etc /home /lib /mnt /opt /root /sbin /tmp /usr /var + +These commands will change the ownership of the root partition and +the /proc directory to root, plus everything under +the directories mentioned in the second line. In these commands, 0.0 is +used instead of the usual root.root, because the username root can't be +resolved because glibc is not yet installed. + + +