In this chapter we will install all the software that belongs to a basic Linux system. After you're done with this chapter you have a fully working Linux system. The remaining chapters deals with optional issues such as setting up networking, Internet servers + clients (telnet, ftp, http, email), setting up Internet itself and the X Window System. You can skip chapters at your own discretion. If you don't plan on going online with the LFS system there's little use to setup Internet for example.
There are a number of packages that need to be already installed before we can start installing all the basic system software. A typical configure scripts needs programs like rm, grep, sed, mv, cat, cp, diff. You need to be able to ungzip and untar archives, you need to link programs after you have compiled the objects files. All these (and a few more) programs needs to be available before we can install anything else. These programs are going to be linked statically. The reasoning behind this is that your normal Linux system may have a different C Library version than the LFS system is going to have. The programs you install in this section will be linked against the C Library of your normal Linux system. This may cause library conflicts if you run those programs on the LFS system. Therefore we have to link those programs statically. During the installation of the basic system software set, we will re-install the statically linked software so that they are linked dynamically against the C library on the LFS system.
Every program and library is default compiled with debugging symbols. This
means you can run a program or library through a debugger and the debugger's
output will be more user friendly. These debugging symbols also enlarge the
program or binary significantly. This document will not install software without
debugging symbols (as I don't know if the majority of readers do or don't debug
software). In stead, you can remove those symbols manually if you want with
the strip
program.
To remove debugging symbols from a binary (must be an a.out or ELF binary)
run strip --strip-debug filename
You can use wild cards if you need to strip
debugging symbols from multiple files (use something like strip --strip-debug
$LFS/usr/bin/*
).
Before you wonder if these debugging symbols would make a big difference, here are some statistics:
Sizes may vary depending on which compiler has been used and which C library version is used to link dynamic programs against, but your results will be very similar if you compare programs with and without debugging symbols. After I was done with this chapter and stripped all debugging symbols from all LFS binaries and libraries I regained a little over 102 MB of disk space. Quite the difference. The difference would be even greater when I would do this at the end of this document when everything is installed.
./configure make -e LDFLAGS=-all-static make -e prefix=$LFS/usr install
make -e LDFLAGS=-static make -e PREFIX=$LFS/usr install cd $LFS/usr/bin mv bunzip2 bzip2 $LFS/bin
./configure make -e LDFLAGS=-static make -e prefix=$LFS/usr install
This package is known to cause static linking problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/diffutils-2.7-fixed.tar.gz
./configure --disable-nls make -e LDFLAGS=-static make -e prefix=$LFS/usr install cd $LFS/usr/bin mv chgrp chmod chown cp dd df ln ls mkdir mknod mv rm rmdir sync $LFS/bin
In order to compile Glibc-2.1.3 you need to have gcc-2.95.2 installed.
Any version from 2.8 and up would do, but 2.95.2 is recommended. Many glibc-2.0
based systems have gcc-2.7.2.3 installed and you can't compile glibc-2.1 with
that compiler. Therefore we will install gcc-2.95.2. also on the normal system,
but without overwriting the existing compiler. Before you install gcc on your
normal system, make sure whether you need it or not. Run gcc --version
and
check if the version number it reports equals or is higher than 2.8. If not,
you need to install gcc-2.95.2. If you experience difficulties compiling glibc
later on, you might want to install gcc-2.95.2 anyways.
mkdir $LFS/usr/src/gcc-build; cd $LFS/usr/src/gcc-build ../gcc-2.95.2/configure --prefix=/usr/gcc2952 \ --with-local-prefix=/usr/gcc2952 --with-gxx-include-dir=/usr/gcc2952/include/g++ \ --enable-shared --enable-languages=c,c++ make bootstrap; make install
mkdir $LFS/usr/src/gcc-build;cd $LFS/usr/src/gcc-build ../gcc-2.95.2/configure --enable-languages=c --disable-nls make -e LDFLAGS=-static bootstrap make -e prefix=$LFS/usr local_prefix=$LFS/usr install
The system needs a few symlinks to ensure every program is able to find the compiler and the pre-processor. Some programs run the cc program, others run the gcc program, some programs expect the cpp program to be in /lib (which is /usr/lib on the LFS system) and others expect to find it in /usr/bin.
cd $LFS/lib; ln -s ../usr/lib/gcc-lib/<host>/2.95.2/cpp cpp cd $LFS/usr/lib; ln -s gcc-lib/<host>/2.95.2/cpp cpp cd $LFS/usr/bin; ln -s gcc cc
Replace <host> with the directory where the gcc-2.95.2 files were installed (i686-unknown-linux in my case). You will most likely find two different directories.
A note on the glibc-crypt package:
-*-*-*-*-*- The add-on is not included in the main distribution of the GNU C library because some governments, mostly notable those of France, Russia and the US, have very restrictive rules governing the distribution and use of encryption software. Please read the node "Legal Problems" in the manual for more details. In particular, the US does not allow export of this software without a license, including via the Internet. So please do not download it from the main FSF FTP site at ftp.gnu.org if you are outside of the US. This software was completely developed outside the US. -*-*-*-*-*-
"This software" refers to the glibc-crypt package at ftp://ftp.gwdg.de/pub/linux/glibc/. This law only affects people who don't live in the US. It's not prohibited to import DES software, so if you live in the US you can import it from that German site.
configparms
containing:
# Begin configparms slibdir=/lib sysconfdir=/etc # End configparms
mkdir $LFS/usr/src/glibc-build;cd $LFS/usr/src/glibc-build ../glibc-2.1.3/configure --enable-add-ons make; make install_root=$LFS install
mkdir $LFS/usr/src/glibc-build; cd $LFS/usr/src/glibc-build CC=/usr/gcc2952/bin/gcc ../glibc-2.1.3/configure --enable-add-ons make; make install_root=$LFS install
If your normal Linux system runs libc-2.0.x, you need to copy the NSS library
files to the LFS partition. Certain statically linked programs still depend
on the NSS library, especially programs that need to lookup usernames, userid's
and groupid's. You can check which C Library version your normal Linux system
uses by running: ls -l libc.so.*
Your system uses glibc-2.0 if the output looks like: /lib/libc.so.6 -> libc-2.0.7.so
Your system uses glibc-2.1 is the output looks like: /lib/libc.so.6 -> libc-2.1.2.so
If your have a libc-2.0.x.so file (where x is the micro version number
such as 7) copy the NSS Library files by running: cp -av /lib/*nss* $LFS/lib
./configure --disable-nls make -e LDFLAGS=-static make -e prefix=$LFS/usr install
This package is known to cause static linking problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/grep-2.4-fixed.tar.gz
./configure make -e LDFLAGS=-static make -e prefix=$LFS/usr install cd $LFS/usr/bin mv gunzip gzip $LFS/bin
This package is known to cause compilation problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/gzip-1.2.4-fixed.tar.gz
./configure make -e LDFLAGS=-static make -e prefix=$LFS/usr install
./configure make -e LDFLAGS=-static make -e prefix=$LFS/usr install mv $LFS/usr/bin/sed $LFS/bin
This package is known to cause static linking problems on certain platforms. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/sed-3.02-fixed.tar.gz
./configure --disable-nls make -e LDFLAGS=-static make -e prefix=$LFS/usr install cd $LFS/usr/bin mv date echo false pwd stty su true uname hostname $LFS/bin
./configure --disable-nls make -e LDFLAGS=-static make -e prefix=$LFS/usr install mv $LFS/usr/bin/tar $LFS/bin
./configure --disable-nls make -e LDFLAGS=-static make -e prefix=$LFS/usr install mv $LFS/usr/bin/cat $LFS/bin
./configure cd lib;make cd ../mount;make -e LDFLAGS=-static cp mount umount $LFS/bin cp swapon $LFS/sbin
The installation of all the software is pretty straightforward and you'll think it's so much easier and shorter to give the generic installation instructions for each package and only explain how to install something if a certain package requires an alternate installation method. Although I agree with you on this aspect, I, however, choose to give the full instructions for each and every package. This is simply to avoid any possible confusion and errors. Before you continue with this document you have to restart your system and boot into the LFS system. But before you do that, you need to determine which partition is used as your swap partition. This information can usually be found in the /etc/fstab file. Check this file for a line similar to this one: /dev/hda6 none swap sw 0 0
The 4th field in a line must contain 'sw'. That line represents a swap partition. All you need to remember is it's designation (which is /dev/hda6 in my case but this will probably be different on your system). When you have determined which partition is the swap partition, you can reboot your computer now and continue from here.
Before the software can be installed we need to remount the partition in read-write mode. Also, we need to activate the swap partition so that we won't risk running out of memory during large compilation processes (such as compiling gcc):
mount -o remount,rw / / /sbin/swapon <swap device>
mkdir $LFS/usr/src/gcc-build;cd $LFS/usr/src/gcc-build ../gcc-2.95.2/configure --with-gxx-include-dir=/usr/include/g++ \ --enable-shared --enable-languages=c,c++ make bootstrap; make install
./configure --datadir=/usr/share/bison make; make install
./configure make; make install cd /usr/bin; ln -s mawk awk
./configure make; make install
This package is known to cause compilation problems. If you're having trouble compiling this package as well, you can download a fixed package from http://www.linuxfromscratch.org/download/findutils-4.1-fixed.tar.gz
./configure make; make install
./configure --with-shared make; make install
./configure make; make install mv /usr/bin/less /bin
./Configure make; make install
Note that we skip the 'make test' step. This is because at this moment the system isn't ready yet for running the perl test. At this time we'll trust that perl compiled fine.
./configure make; make install
./configure make; make install
./configure make; make install
./configure make install
./configure make; make install mv /usr/bin/bash /bin
./configure make; make install
./configure make; make install
make; make install cd /usr/bin; mv bunzip2 bzip2 /bin
./configure make; make install
./configure make; make install mv /usr/sbin/mklost+found /sbin
./configure make; make install
./configure make; make install cd /usr/bin mv chgrp chmod chown cp dd df ln ls mkdir mknod mv rm rmdir sync /bin
./configure make; make install
./configure make; make install
./configure make; make install cd /usr/bin; mv z* gunzip gzip /bin
cd util; make ldd ldconfig cp ldd /bin; cp ldconfig /sbin rm /usr/bin/ldd
./configure make; make install
cd as make; make install cd ../ld make ld86; make install
make; make install
./configure make; make install
./configure make; make install cd /usr/bin mv date echo false pwd stty su true uname hostname /bin
./configure make; make install cd etc cp limits login.access login.defs.linux shells suauth /etc mv /etc/login.defs.linux /etc/login.defs cd /usr/sbin mv chpasswd dpasswd groupadd groupdel groupmod logoutd mkpasswd \ newusers useradd userdel usermod grpck pwck vipw grpconv grpunconv \ pwconv pwunconv /sbin
./configure -default make all; make install
./configure make; make install
make; make install
gcc -O3 -Wall -Wno-unused -c watch.c make; make -e XSCPT="" install mv /usr/bin/kill /bin
make; make install
./configure make; make install mv /usr/bin/sed /bin
make start-stop-daemon cp start-stop-daemon /sbin cp start-stop-daemon.8 /usr/share/man/man8
make; make install
cd src make; make install
./configure make; make install mv /usr/bin/tar /bin
./configure make; make install mv /usr/bin/cat /bin
./configure make; make install
HAVE_PASSWD=yes HAVE_SLN=yes HAVE_TSORT=yes
groupadd -g 5 tty ./configure make; make install
If you have copied the NSS Library files from your normal Linux system to the LFS system (because your normal system runs glibc-2.0) it's time to remove them now by running:
rm /lib/libnss*.so.1 /lib/libnss*2.0*
Now that all software is installed, all that we need to do to get a few programs running properly is to create their configuration files.
We need to create the /etc/nsswitch.conf file. Although glibc should provide defaults when this file is missing or corrupt, it's defaults don't work work well with networking which will be dealt with in a later chapter. Also, our timezone needs to be setup.
# Begin /etc/nsswitch.conf passwd: files group: files shadow: files hosts: files dns networks: files protocols: db files services: db files ethers: db files rpc: db files netgroup: db files # End /etc/nsswitch.conf
tzselect's output can be something like "EST5EDT" or "Canada/Eastern". The symlink you would create with that information would be ln -s /usr/share/zoneinfo/EST5EDT /etc/localtime or ln -s /usr/share/zoneinfo/Canada/Eastern /etc/localtime
We're not going to create lilo's configuration file from scratch, but we'll use the file from your normal Linux system. This file is different on every machine and thus I can't create it here. Since you would want to have the same options regarding lilo as you have when you're using your normal Linux system you would create the file exactly as it is on the normal system.
cp /mnt/original/etc/lilo.conf /etc cp /mnt/original/boot/* /boot
If your normal Linux system does not have (all of) it's kernel images in /mnt/original/boot, then check your /etc/lilo.conf file for the location of those files and copy those as well to the location where /etc/lilo.conf expects them to be. Or you can copy them to /boot regardless and modify the /etc/lilo.conf file so it contains the new paths for the images as you have them on the LFS system. Either way works fine, it's up to you how you want to do it.
# Begin /etc/syslog.conf auth,authpriv.* -/var/log/auth.log *.*;auth,authpriv.none -/var/log/sys.log daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log mail.* -/var/log/mail.log user.* -/var/log/user.log *.emerg * # End /etc/syslog.conf
This package contains the utilities to modify user's passwords, add new users/groups, delete users/groups and more. I'm not going to explain to you what 'password shadowing' means. You can read all about that in the doc/HOWTO file. There's one thing you should keep in mind, if you decide to use shadow support, that programs that need to verify passwords (examples are xdm, ftp daemons, pop3d, etc) need to be 'shadow-compliant', eg. they need to be able to work with shadowed passwords.
If you decide you don't want to use shadowed passwords (after you're read the doc/HOWTO document), you still use this archive since the utilities in this archive are also used on system which have shadowed passwords disabled. You can read all about this in the HOWTO. Also note that you can switch between shadow and non-shadow at any point you want.
Now is a very good moment to read section #5 of the doc/HOWTO file. You can read how you can test if shadowing works and if not, how to disable it. If it doesn't work and you haven't tested it, you'll end up with an unusable system after you logout of all your consoles, since you won't be able to login anymore. You can easily fix this by passing the init=/sbin/sulogin parameter to the kernel, unpack the util-linux archive, go to the login-utils directory, build the login program and replace the /bin/login by the one in the util-linux package. Things are never hopelessly messed up (at least not under Linux), but you can avoid a hassle by testing properly and reading manuals ;)
After you have made the following modification to the /etc/inittab file, you will be able to logon to it as you are used to (using the agetty and login programs). Sulogin won't be used anymore for normal logins.
# Begin /etc/inittab id:2:initdefault: si::sysinit:/etc/init.d/rcS su:S:wait:/sbin/sulogin l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6:6:wait:/etc/init.d/rc 6 ft:6:respawn:/sbin/sulogin ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now 1:2345:respawn:/sbin/agetty /dev/tty1 9600 2:2345:respawn:/sbin/agetty /dev/tty2 9600 3:2345:respawn:/sbin/agetty /dev/tty3 9600 4:2345:respawn:/sbin/agetty /dev/tty4 9600 5:2345:respawn:/sbin/agetty /dev/tty5 9600 6:2345:respawn:/sbin/agetty /dev/tty6 9600 # End /etc/inittab
Programs like login, shutdown and others want to write to the /var/run/utmp file. This file contains information about who is currently logged in. It also contains information on when the computer was last shutdown.