Download   Online Shop   Red Hat Network
Home  |  Products  |  Shop  |  Services  |  Training  |  Support   
Red Hat Documentation

Linux From Scratch: Installing basic system software Next Previous Contents

7. Installing basic system software

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.

7.1 About debugging symbols

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:

  • A static Bash binary with debugging symbols: 2.3MB
  • A static Bash binary without debugging symbols: 645KB
  • A dynamic Bash binary with debugging symbols: 1.2MB
  • A dynamic Bash binary without debugging symbols: 478KB
  • $LFS/usr/lib (glibc and gcc files) with debugging symbols: 87MB
  • $LFS/usr/lib (glibc and gcc files) without debugging symbols: 16MB

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.

7.2 Preparing LFS system for installing basic system software

Installing Binutils

  • Unpack the binutils archive
  • Install the package by running:

./configure
make -e LDFLAGS=-all-static
make -e prefix=$LFS/usr install

Installing Bzip2

  • Unpack the Bzip2 archive
  • Edit the Makefile file in a text editor
  • Find the lines that start with : $(CC) $(CFLAGS) -o
  • Replace those parts with: $(CC) $(CFLAGS) $(LDFLAGS) -o
  • Install the package by running:

make -e LDFLAGS=-static
make -e PREFIX=$LFS/usr install
cd $LFS/usr/bin
mv bunzip2 bzip2 $LFS/bin

Install Diffutils

  • Unpack the diffutils archive
  • Install the package by running:

./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

Installing Fileutils

  • Unpack the fileutils archive
  • Install the package by running:

./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

Installing GCC on the normal system if necessary

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.

  • Unpack the GCC archive
  • Install the package by running:

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

Installing GCC on the LFS system

  • Unpack the GCC archive
  • Install the package by running:

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

Creating necessary symlinks

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.

  • Create those symlinks by running:

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.

Installing Glibc

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.

  • Unpack the Glibc archive
  • Copy the glibc-crypt and glibc-linuxthreads archives into the unpacked glibc directory
  • Unpack the glibc-crypt and glibc-linuxthreads there, but don't enter these directories. Just ungzip and untar them.
  • Create a new file configparms containing:

# Begin configparms
slibdir=/lib
sysconfdir=/etc
# End configparms

  • If your normal system already had a gcc version suitable to compile glibc with, install the package by running:

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

  • If your normal didn't had a suitable gcc version and you installed gcc-2.95.2 on your normal system, install the package by running:

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

Copying old NSS Library files

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

Installing grep

  • Unpack the grep archive
  • Install the package by running:

./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

Installing gzip

  • Unpack the gzip archive
  • Install the package by running:

./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

Installing Make

  • Unpack the Make archive
  • Install the package by running:

./configure
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install

Installing Sed

  • Unpack the sed archive
  • Install the package by running:

./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

Installing Sh-utils

  • Unpack the sh-utils archive
  • Install the package by running:

./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

Installing Tar

  • Unpack the tar archive
  • Install the package by running:

./configure --disable-nls
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install
mv $LFS/usr/bin/tar $LFS/bin

Installing Textutils

  • Unpack the textutils archive
  • Install the package by running:

./configure --disable-nls
make -e LDFLAGS=-static
make -e prefix=$LFS/usr install
mv $LFS/usr/bin/cat $LFS/bin

Installing Util-linux

  • Unpack the util-linux archive
  • Install the package by running:

./configure
cd lib;make
cd ../mount;make -e LDFLAGS=-static
cp mount umount $LFS/bin
cp swapon $LFS/sbin

7.3 Installing basic systsem software

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.

Remounting partition and activating swap

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>

Installing GCC

  • Unpack the GCC archive and install it by running:

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

Installing Bison

  • Unpack the bison archive and install it by running:

./configure --datadir=/usr/share/bison
make; make install

Installing Mawk

  • Unpack the mawk archive and install it by running:

./configure
make; make install
cd /usr/bin; ln -s mawk awk

Installing Findutils

  • Unpack the findutils archive and install it by running:

./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

Installing Termcap

  • Unpack the Termcap archive and install it by running:

./configure
make; make install

Installing Ncurses

  • Unpack the ncurses archive and install it by running:

./configure --with-shared
make; make install

Installing Less

  • Unpack the Less archive and install it by running:

./configure
make; make install
mv /usr/bin/less /bin

Installing Perl

  • Unpack the Perl archive and install it by running:

./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.

Installing M4

  • Unpack the M4 archive and install it by running:

./configure
make; make install

Installing Texinfo

  • Unpack the Texinfo archive and install it by running:

./configure
make; make install

Installing Autoconf

  • Unpack the Autoconf archive and install it by running:

./configure
make; make install

Installing Automake

  • Unpack the Automake archive and install it by running:

./configure
make install

Installing Bash

  • Unpack the Bash archive and install it by running:

./configure
make; make install
mv /usr/bin/bash /bin

Installing Flex

  • Unpack the Flex archive and install it by running:

./configure
make; make install

Installing Binutils

  • Unpack the Binutils archive and install it by running:

./configure
make; make install

Installing Bzip2

  • Unpack the Bzip2 archive and install it by running:

make; make install
cd /usr/bin; mv bunzip2 bzip2 /bin

Installing Diffutils

  • Unpack the Diffutils archive and install it by running:

./configure
make; make install

Installing E2fsprogs

  • Unpack the E2fsprogs archive and install it by running:

./configure
make; make install
mv /usr/sbin/mklost+found /sbin

Installing File

  • Unpack the File archive and install it by running:

./configure
make; make install

Installing Fileutils

  • Unpack the Fileutils archive and install it by running:

./configure
make; make install
cd /usr/bin
mv chgrp chmod chown cp dd df ln ls mkdir mknod mv rm rmdir sync /bin

Installing Grep

  • Unpack the Grep archive and install it by running:

./configure
make; make install

Installing Groff

  • Unpack the Groff archive and install it by running:

./configure
make; make install

Installing Gzip

  • Unpack the Gzip archive and install it by running:

./configure
make; make install
cd /usr/bin; mv z* gunzip gzip /bin

Installing Ld.so

  • Unpack the Ld.so archive and install it by running:

cd util; make ldd ldconfig
cp ldd /bin; cp ldconfig /sbin
rm /usr/bin/ldd

Installing Libtool

  • Unpack the Libtool archive and install it by running:

./configure
make; make install

Installing Linux86

  • Unpack the Linux86 archive and install it by running:

cd as
make; make install
cd ../ld
make ld86; make install

Installing Lilo

  • Unpack the Lilo archive and install it by running:

make; make install

Installing Make

  • Unpack the Make archive and install it by running:

./configure
make; make install

Instaling Sh-Utils

  • Unpack the Sh-utils archive and install it by running:

./configure
make; make install
cd /usr/bin
mv date echo false pwd stty su true uname hostname /bin

Installing Shadow Password Suite

  • Unpack the Shadow archive and install it by running:

./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

Installing Man

  • Unpack the Man archive and install it by running:

./configure -default
make all; make install

Installing Modutils

  • Unpack the Modutils archive and install it by running:

./configure
make; make install

Installing Procinfo

  • Unpack the Procinfo archive and install it by running:

make; make install

Installing Procps

  • Unpack the Procps archive and install it by running:

gcc -O3 -Wall -Wno-unused -c watch.c
make; make -e XSCPT="" install
mv /usr/bin/kill /bin

Installing Psmisc

  • Unpack the Psmisc archive and install it by running:

make; make install

Installing Sed

  • Unpack the Sed archive and install it by running:

./configure
make; make install
mv /usr/bin/sed /bin

Installing start-stop-daemon

  • Unpack the start-stop-daemon archive and install it by running:

make start-stop-daemon
cp start-stop-daemon /sbin
cp start-stop-daemon.8 /usr/share/man/man8

Installing Sysklogd

  • Unpack the Sysklogd archive and install it by running:

make; make install

Installing Sysvinit

  • Unpack the Sysvinit archive and install it by running:

cd src
make; make install

Install Tar

  • Unpack the Tar archive and install it by running:

./configure
make; make install
mv /usr/bin/tar /bin

Installing Textutils

  • Unpack the Textutils archive and install it by running:

./configure
make; make install
mv /usr/bin/cat /bin

Installing Vim

  • Unpack the Vim-rt and Vim-src archives and install it by running:

./configure
make; make install

Installing Util-linux

  • Unpack the Util-linux package
  • Edit the MCONFIG file, find and modify the following variables as follows:

HAVE_PASSWD=yes
HAVE_SLN=yes
HAVE_TSORT=yes

  • Install the package by running:

groupadd -g 5 tty
./configure
make; make install

7.4 Removing old NSS Library files

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*

7.5 Configuring the software

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.

Configuring Glib

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.

  • Create a new file /etc/nsswitch.conf containing:

# 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

  • Run the tzselect script and answer the questions regarding your timezone
  • When you're done, the program will give you the file location you need.
  • Create the localtime symlink by running: ln -s /usr/share/zoneinfo/<tzselect's output> /etc/localtime

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

Configuring LILO

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.

  • Create the /mnt/original directory
  • Mount your normal Linux system on this mount point by running mount /dev/xxx /mnt/original (replace /dev/xxx with your normal partition's designation).
  • Copy the lilo configuration file and kernel images that lilo uses by running:

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.

Configuring Sysklogd

  • Create the /var/log directory by running: mkdir /var/log
  • Create the /etc/syslog.conf file containing the following:

# 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

Configuring Shadow Password Suite

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 ;)

Configuring Sysvinit

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.

  • Edit the /etc/inittab file and modify it so it contains the following:

# 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

Creating /var/run/utmp file

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.

  • Create the /var/run/utmp file by running: touch /var/run/utmp
  • Give it the proper file permissions by running: chmod 644 /var/run/utmp

Next Previous Contents

 

 
 
Search for:  on    Powered by Google
Products & Services   :   Download   :   Support   :   Training   :   Partners & Programs
© 2000 Red Hat, Inc. All right reserved.       About Red Hat   :   Legal statement   :   Privacy statement   :   Y2K statement   :   Contact Red Hat