I started this document around May 1999. I tried a few Linux distributions and came to the conclusion that there's wasn't a distribution I totally liked. Every distribution has it's own advantages and disadvantages, but I was never satisfied with what I had (although Debian comes very close to what I want), so I decided to explore the possibility of building my own Linux distribution using nothing but source code of programs. As I found out there's quite a bit of work involved, but it's also a lot of fun and you really learn a lot by doing it, since you need to configure every single aspect of the system. This forces you to read a lot of manuals on how to configure various software. It also gives you total control over your system (well, that's the idea). You know exactly what software is installed, how it is configured and where all the configuration files reside.
I started writing a series of articles for a Dutch/Belgium E-zine on this subject. Not soon after I got stuck getting a compiler to work. I decided to give this project a rest at that point, since a lot of things at that time needed my attention (I was about to move from The Netherlands to Canada to get married. There were a lot of things to arrange regarding the move abroad and a lot of immigration stuff to sort out).
A few months after my arrival in Canada and getting married, I decided to continue my work on this project. Pretty much starting all over again from scratch and following a different approach, I got things to work out finally. The end result is what you are reading right now.
The latest version of the document can always be found at http://huizen.dds.nl/~glb/
1.3 - February 11th, 2000
1.2 - January 9th, 2000
1.1 - December 20th, 1999
1.0 - December 16th, 1999
Projects related to this HOWTO that are currently underway.
Things that need to be done for future releases. If you feel you want to help out on one of these items, let me know first (in case you end up doing something somebody else is doing already or is already finished).
There are two mailinglists you can subscribe to. The lfs-discuss and the lfs-announce list. The former is an open non-moderated list discussing anything that has got anything to do with this HOWTO (asking questions, inform about mistakes in this HOWTO and so on). The latter is an open moderated list. Anybody can subscribe to it, but you cannot post messages to it (only the moderator(s) can). This list is primarily used for announcements of new versions of the HOWTO.
If you're subscribed to the lfs-discuss list you don't need to be subscribed to the lfs-announce list as well. Everything that is sent over the lfs-announce list is also sent over the lfs-discuss list.
To subscribe to a list, send an email to majordomo@fist.org and type in the body either subscribe lfs-discuss or subscribe lfs-announce
Majordomo will send you a confirmation-request email. This email will contain an authentication code. Once you send this email back to Majordomo (instructions are provided in that email) you will be subscribed.
To unsubscribe from a list, send an email to majordomo@fist.org and type in the the body either unsubscribe lfs-discuss or unsubscribe lfs-announce
You can reach me, Gerard Beekmans, at tts-sol@dds.nl
Below is a list of all the software that you need to download for use in this document. I display the sites and directories where you can download the software, but it is up to you to make sure you download the source archive and the latest version. The version numbers correspondent to versions of the software that is known to work.
Sysvinit (2.78) : ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/
Bash (2.03) : ftp://ftp.gnu.org/gnu/bash/
Linux Kernel (2.2.14) : ftp://ftp.kernel.org/
Make (3.77) : ftp://ftp.gnu.org/gnu/make/
Sed (3.02) : ftp://ftp.gnu.org/gnu/sed/
Shell Utils (2.0) : ftp://ftp.gnu.org/gnu/sh-utils/
File Utils (4.0) : ftp://ftp.gnu.org/gnu/fileutils/
Util Linux (2.9z) : ftp://ftp.win.tue.nl/pub/linux/utils/util-linux/
Text Utils (1.22) : ftp://ftp.gnu.org/gnu/textutils/
Tar (1.12) : ftp://ftp.gnu.org/gnu/tar/
Gzip (1.2.4) : ftp://ftp.gnu.org/gnu/gzip/
Binutils (2.9.1.0) : ftp://ftp.gnu.org/gnu/binutils/
Grep (2.2) : ftp://ftp.gnu.org/gnu/grep/
Bison (1.25) : ftp://ftp.gnu.org/gnu/bison/
Mawk (1.3.3) : ftp://ftp.whidbey.net/pub/brennan/
Find Utils (4.1) : ftp://ftp.gnu.org/gnu/findutils/
Diff Utils (2.7) : ftp://ftp.gnu.org/gnu/diffutils/
Ld.so (1.9.10) : ftp://tsx-11.mit.edu/pub/linux/packages/GCC/
Perl (5.005_03) : ftp://ftp.gnu.org/gnu/perl/
M4 (1.4) : ftp://ftp.gnu.org/gnu/m4/
Texinfo (4.0) : ftp://ftp.gnu.org/gnu/texinfo/
Automake (1.3) : ftp://ftp.gnu.org/gnu/automake/
Autoconf (2.13) : ftp://ftp.gnu.org/gnu/autoconf/
Glibc (2.0.7pre6) : ftp://ftp.gwdg.de/pub/linux/glibc/2.0.7pre6/
Glibc-crypt (2.0.pre6) : ftp://ftp.gwdg.de/pub/linux/glibc/2.0.7pre6/
Glibc-linuxthreads (2.0.7pre6) : ftp://ftp.gwdg.de/pub/linux/glibc/2.0.7pre6/
Libstdc++-2.91.60 : ftp://ftp.debian.org/debian/dists/slink/main/binary-i386/base/
Libstdc++-2.91.660-dev : ftp://ftp.debian.org/debian/dists/slink/main/binary-i386/devel/
GCC (2.7.2.3) : ftp://ftp.gnu.org/gnu/gcc/
G++-2.91.60 : ftp://ftp.debian.org/debian/dists/slink/main/binary-i386/devel/
Ncurses (4.2) : ftp://ftp.gnu.org/gnu/ncurses/
Vim (5.5) : ftp://ftp.vim.org/pub/vim/
Readline Library (4.0) : ftp://ftp.gnu.org/gnu/readline/
Termcap Library (1.3) : ftp://ftp.gnu.org/gnu/termcap/
Flex (2.5.4a) : ftp://ftp.gnu.org/gnu/flex/
Less (332) : ftp://ftp.gnu.org/gnu/less/
E2fsprogs (1.12) : ftp://tsx-11.mit.edu/pub/linux/packages/ext2fs/
File (3.26) : ftp://ftp.debian.org/debian/dists/slink/main/source/utils/
Libtool (1.2) : ftp://ftp.gnu.org/gnu/libtool/
Modutils (2.3.7) : ftp://ftp.ocs.com.au/pub/modutils/v2.3/
Linux86 (0.14.3) : ftp://ftp.debian.org/debian/dists/slink/main/source/devel
Lilo (21) : ftp://sunsite.unc.edu/pub/Linux/system/boot/lilo/
DPKG (1.4.0.35) : ftp://ftp.debian.org/debian/dists/slink/main/source/base/
Sysklogd (1.3.31) : ftp://sunsite.unc.edu/pub/Linux/system/daemons/
Groff (1.11.1) : ftp://ftp.gnu.org/gnu/groff/
Man-db (2.3.10) : ftp://ftp.debian.org/debian/dists/slink/main/source/doc/
Procps (2.0.6) : ftp://tsx-11.mit.edu/pub/linux/sources/usr.bin/
Procinfo (17) : ftp://ftp.cistron.nl/pub/people/svm/
Procmisc (19) : ftp://lrcftp.epfl.ch/pub/linux/local/psmisc/
Shadow Password Suite (19990827) : ftp://piast.t19.ds.pwr.wroc.pl/pub/linux/shadow/
All software below is used in sections 13 and above and are not strictly necessary. You have to determine for yourself if you want to install certain packages. If, for example, you don't intend to go online with the LFS system, you might not want to install the email, telnet, ftp, www, etc. utilities. You can omit those. I suggest you read the sections 13 and above first to determine which software packages you want and which software packages you don't want to install.
Netkit-base : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit-devel/
Net-tools (1.53) : http://www.tazenda.demon.co.uk/phil/net-tools/
Procmail (3.13.1) : ftp://ftp.procmail.org/pub/procmail/
Sendmail (8.9.3) : ftp://ftp.sendmail.org/pub/sendmail/
Mailx (8.1.1) : ftp://ftp.debian.org/debian/dists/slink/main/source/mail/
Mutt (1.0i) : ftp://ftp.mutt.org/pub/mutt/
Fetchmail (5.2.0) : http://www.tuxedo.org/~esr/fetchmail/
Netkit-telnet : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit-devel/
Proftpd (1.2.0pre9) : ftp://ftp.tos.net/pub/proftpd/
Netkit-ftp : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit-devel/
Apache (1.3.3) : http://www.apache.org/dist/
Slang Library (1.3.10) : ftp://space.mit.edu/pub/davis/slang/
Zlib Library (1.1.3) : http://www.cdrom.com/pub/infozip/zlib/
Lynx (2.8.1) : http://www.slcc.edu/lynx/release/
Xfree86 (3.3.2.3) : ftp://ftp.xfree86.org/pub/XFree86/
libPropList (0.9.1) : ftp://ftp.windowmaker.org/pub/libs/
libXpm (4.7) : ftp://sunsite.unc.edu/pub/Linux/libs/X/
libpng (1.0.3) : http://www.cdrom.com/pub/png/
libtiff (3.4) : ftp://ftp.sgi.com/graphics/tiff/
libjpeg (6b) : http://www.ijg.org/
libungif (4.1.0) : ftp://prtr-13.ucsc.edu/pub/libungif/
WindowMaker (0.61.1) : ftp://ftp.windowmaker.org/pub/release/
PPP (2.3.10) : ftp://cs.anu.edu.au/pub/software/ppp/
We are going to build the LFS system using an already installed Linux distribution such as Debian, SuSe, Slackware, Mandrake, RedHat, etc. You don't need to have any kind of bootdisk. We will use an existing Linux system as the base (since we need a compiler, linker, text editor and other tools).
If you don't have Linux installed yet, you won't be able to put this HOWTO to use right away. I suggest you first install a Linux distribution. It really doesn't matter which one you install. It also doesn't need to be the latest version (though it shouldn't be a too old one. If it is about a year old or newer it'll do just fine).
Before we can build our new Linux system, we need to have an empty Linux partition on which we can build our new system. If you already have a Linux Native partition available, you can skip this subsection.
Start the fdisk
program (or cfdisk
if you prefer that program) with the
appropriate hard disk as the option (like /dev/hda if you want to create a
new partition on the primary master IDE disk). Create a Linux Native partition,
write the partition table and exit the (c)fdisk program. If you get the message
that you need to reboot your system to ensure that that partition table is
updated, then please reboot your system now before continuing.
Once the partition is created, we have to create a new ext2 file system on that partition. From now on I'll refer to this newly created partition as $LFS. $LFS should be substituted with the partition you have created. If you created your partition on /dev/hda4, you mounted it on /mnt/hda4 and this document tells you to copy a file to $LFS/usr/bin then you need to copy that file to /mnt/hda4/usr/bin.
To create a new ext2 file system we use the mke2fs
command. Give $LFS
as the only option and the file system will be created.
In order to be able to boot from this partition later on, we need to update
our /etc/lilo.conf
file. Add the following lines to lilo.conf:
image=<currently used image> label=<label> root=$LFS read-only
Replace <currently used image> by the kernel image file that you are using to boot your normal Linux system. <label> can be anything you want it to be. I named the label "lfs" What you enter as <label> is what you enter at the LILO-prompt when you choose with system to boot.
Now run the lilo
program to update the boot loader.
Let's create a minimal directory tree on the $LFS partition. issuing the following commands will create the necessary directories. Make sure you first mount the $LFS partition before you attempt to create the directories.
cd $LFS mkdir boot etc home lib mnt proc root tmp var usr mkdir bin sbin usr/bin usr/sbin usr/src mkdir usr/man usr/include usr/share cd usr/man mkdir man1 man2 man3 man4 man5 man6 man7 man8 cd .. ln -s . local ln -s /etc etc ln -s /var var ln -s /usr/man share/man
I am aware that a number of directories you have created above are in total violation with the FHS (File Hierarchy Standard - http://www.pathname.com/fhs/). The reason why I do this is just a preference. I want to keep certain files all together. For example the old standard was that man pages go in /usr/man and /usr/local/man. The most recent standard dictates that man pages should go in /usr/share/man (and possibly /usr/local/share/man). I just want them all to be in /usr/man so I know exactly in what directory a certain man page is and I don't have to start looking in various directories to find out where it is (although I can simply find a file with the 'locate' command I still prefer the way I do things).
If you want to create a file system that it completely according the FHS, then I urge you to take a look at www.pathname.com/fhs and create your directories accordingly.
We can create every single file that we need to be in the $LFS/dev directory using the mknod command, but that just takes up a lot of time. I choose to just simply copy the current /dev directory to the $LFS partition. Use this command to copy the entire directory while preserving original rights, symlinks and owner ships:
cp -av /dev $LFS
Feel free to strip down the $LFS/dev directory, only leaving the devices you really need.
Under normal circumstances, after the kernel's done loading and initializing
various system components, it attempts to load a program called init
which
will finalize the system boot process. The program found on most Linux systems
is called Sysvinit and that's the program we're going to install on our LFS
system.
Makefile
fileAfter applying the $(ROOT) parts to the last four lines, they should look like this:
@if [! -p $(ROOT)/dev/initctl ]; then \ echo "Creating $(ROOT)/dev/initctl" \ rm -f $(ROOT)/dev/initctl; \ mknod -m 600 $(ROOT)/dev/initctl p; fi
make LDFLAGS=-static
make install
In order for Sysvinit to work, we need to create it's configuration file.
Create the $LFS/etc/inittab
file containing the following:
# Begin /etc/inittab id:2:initdefault: si::sysinit:/etc/init.d/rcS ~~: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 z6:6:wait:/sbin/sulogin ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now 1:2345:respawn:/sbin/sulogin # End /etc/inittab
As you can see from the inittab file, when we boot the system, init will start the sulogin program and sulogin will ask you for root's password. This means we need to have at least a passwd file present on the LFS system. We'll use the passwd and group files from the current running Linux system. Since the passwords are encoded it's just easier to copy the already present file and use that, instead of retyping the encoded password. Mistakes are easily made and this way we can avoid extra hassle afterwards.
/etc/passwd
and /etc/group
files to $LFS/etc/
$LFS/etc/passwd
file and remove every line, except the
line for the user root$LFS/etc/group
file and remove every line, except the line
for the group rootIt might be the case that your system uses shadowed passwords. In that case the /etc/passwd files will not contain the root password, but the /etc/shadow file does (this file is only accessible by user root and programs who run as root). The password field of /etc/passwd contains a x usually (the first field after the username). Remove that x and replace it with the encoded password you have in /etc/shadow. The encoded password is the second field in the /etc/shadow file (so the first field after the username, without the colons). Make sure you copy it exactly as it is. Remember: it is case sensitive.
When sulogin asks you for the root password and you've entered the password, a shell needs to be started. Usually this is the bash shell. Since there are no libraries installed yet, we need to link bash statically, just like we did with Sysvinit.
configure --enable-static-link
make
bash
to $LFS/bin
$LFS/bin/sh
to $LFS/bin/bash
After you've completed this section, we can test the system and see if we can log on to it. Please note that you will get errors regarding the init program not being able to start the rcS and rc scripts. Ignore those error s for now. It is normal. We will install these scripts in a later stage.
Also note that you won't be able to shutdown the system with a program like shutdown. Although the program is present, it will give you the following error: "You don't exist. Go away." when you try to use the program. The meaning of this error is that the system isn't able to locate the password file. Although the shutdown program is statically linked against the libraries it needs, it still depends on the nss library (Name Server Switch) which is part of the GNU C Library, which also will be installed in a later stage. This NSS library passes on information where (in this case) the passwd file can be found.
For now you can reboot the system using the reboot -f
command. This will
bypass shutting down the system using the shutdown program and reboot immediately.
Since the file system is mounted read-only this will not harm our system in
any way (though you might get a warning next time you try to mount the system
that it wasn't unmounted cleanly the last time and that you should run e2fsck
to make sure the file system is OK).
In section 2 above I mentioned you can download a new kernel from ftp://ftp.kernel.org/ However, this site is often too busy to get through and the maintainers of this site encourage you to download the kernel from a location near you. You can access a mirror site by going to ftp://ftp.<country code>.kernel.org/ (like ftp.ca.kernel.org).
/usr/src/
directory make dep
make bzImage
arch/<cpu>/boot/bzImage
file to the /boot
directory (or
some place else if your Linux system uses a different convention where kernel
images and the like are stored)/boot/bzImage
file to something like /boot/lfskernel
cp -av /usr/src/linux $LFS/usr/src
ln -s $LFS/usr/include/linux
/usr/src/linux/include/linux
ln -s $LFS/usr/include/asm
/usr/src/linux/include/asm
/etc/lilo.conf
file and go to the LFS sectionlfskernel
(or whatever you've named the originally
called bzImage file)lilo
to update the boot loader.Reboot your system and start your LFS system. Verify that the newly installed kernel doesn't perform out-of-the-ordinary actions (like crashing).
In this section we're going to install Glibc. But before we'll be able to install these libraries, we need to have a bunch of other software installed on the LFS system. Therefore all these programs need to be linked statically. This means quite a bit of extra work, because after Glibc and the GNU CC compilers are installed, we're going to re-install all these programs so they'll be linked dynamically. If somebody knows of a better way to accomplish this, without first building all the software statically and then rebuild them dynamically, please let me know.
I know of one other way and that's by installing Glibc using pre-compiled binaries. But that would be directly against what we're doing here. So that's not an option.
All software that is being installed in this section will be compiled on our normal working Linux system and then copied to the LFS system.
You'll notice that the installation of this software is very straightforward is most cases. I also won't explain what this software does, since it's all trivial software and if you don't know what some program does, you can always read the README file and other documentation.
configure
make LDFLAGS=-static
make
binary to $LFS/usr/bin
configure
make LDFLAGS=-static
sed/sed
binary to $LFS/usr/binThere is a possibility you will experience compilation problems. If this is teh case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/lfs-howto/sed-3.02-lfs.tar.gz
configure
make LDFLAGS=-static
date echo false pwd sleep stty su true uname
chroot
basename dirname env expr factor groups id logname nice nohup pathchk printenv
printf seq tee test tty uptime users who whoami yes
configure
make LDFLAGS=-static
chgrp chmod chown cp dd df dir dircolors du ln ls mkdir mkfifo mknod mv rm
rmdir sync touch vdir
ginstall
cd $LFS/usr/bin;
ln -s ginstall install
configure
make
make
LDFLAGS=-static
osetup mount swapon umount
$LFS/sbin/swapoff
to $LFS/sbin/swapon
configure
make LDFLAGS=-static
cat
cksum comm csplit cut expand fmt fold head join md5sum nl od paste pr sort
split sum tac tail tr unexpand uniq wc
configure
make LDFLAGS=-static
After compiling the programs in the src directory you will have two programs: tar and rmt. Tar is obvious. Rmt stands for ReMote Tapeserver. If you don't need this program (ie; you don't have a tapestreamer in your network or on your machine) then you don't need to copy this program.
src/tar
binary to $LFS/binsrc/rmt
binary to $LFS/bin (if you need it)
configure
make LDFLAGS=-static
gzexe.in zdiff.in zforce.in
zgrep.in zmore.in znew.in
gunzip gzexe gzip zcat zdiff
zforce zgrep zmore znew
There is a possibility you will experience compilation problems. If this is the case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/lfs-howto/gzip-1.2.4-lfs.tar.gz
configure
make LDFLAGS=-all-static
as-new gasp-new
$LFS/usr/bin/as
and $LFS/usr/bin/gasp
ld-new
$LFS/usr/bin/ld
addr2line ar c++filt nm-new objcopy objdump ranlib size strings strip-new
$LFS/usr/bin/nm
$LFS/usr/bin/strip
configure
make LDFLAGS=-static
egrep fgrep grep
There is a possibility you will experience compilation problems. If this is the case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/grep-2.2-lfs.tar.gz
configure
make LDFLAGS=-static
bison
bison.hairy bison.simple
configure
make CFLAGS="-O -static"
mawk
$LFS/usr/bin/awk
to $LFS/usr/bin/mawk
configure
make LDFLAGS=-static
find
There is a possibility you will experience compilation problems. If this is the case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/lfs-howto/findutils-4.1-lfs.tar.gz
configure
make LDFLAGS=-static
cmp diff diff3 sdiff
There is a possibility you will experience compilation problems. If this is the case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/lfs-howto/diffutils-2.7-lfs.tar.gz
make ldd
make ldconfig
$LFS/bin:ldd
$LFS/sbin: ldconfig
Configure
You can stick to all the default questions, except to the following.
When asked What is the file extension used for shared libraries? [so]
Answer with: none
When asked Any additional ld flags (NOT including libraries)? [-L/usr/local/lib]
Answer with: -L/usr/local/lib -static
When asked Do you wish to use dynamic loading? [y]
Answer with: n
make
perl
configure
make LDFLAGS=-static
m4
There is a possibility you will experience compilation problems. If this is the case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/lfs-howto/m4-1.4-lfs.tar.gz
configure --disable-nls
make LDFLAGS=-static
makeinfo
configure
automake aclocal
$LFS/usr/share/automake
config.guess
config.sub install-sh mdate-sh missing mkinstalldirs elisp-comp ylwrap acinstall
*.am
files$LFS/usr/share/aclocal
*.m4
files
configure
make
autoconf autoheader autoreconf
autoscan autoupdate ifnames
$LFS/usr/share/autoconf
*.m4*
files
(in effect this means all *m4 and all *.m4f files)acconfig.h
acfunctions acheaders acidentifiers acprograms acmakevars
We're not going to installed the latest Glibc version, 2.1.2, but version 2.0.7pre6. The reason is that glibc 2.1.2 requires at least gcc 2.8 (or egcs 1.1). My system has gcc 2.7.2.3 thus I can't compile the glibc2.1.2 library. And I also don't want to upgrade my working Linux system to gcc 2.95.2 (which is the latest version at the time of writing this document). Upgrading a compiler isn't as easy as it sounds and I don't want to break things on this working system.
So therefore I have to install glibc 2.0.7pre6. However, we are going to install the gcc 2.95.2 compiler. We also need to install the gcc 2.7.2.3 compiler because certain software can't be compiled with gcc 2.95.2 (due to bugs in the programs that aren't really bugs but the gcc 2.95.2 compiler defines them as bugs. This is not a bug in the compiler, but changes in the C standard (if I understood it correctly)).
A note on the glibc-crypt package. The following is quoted from the glibc-crypt-README file on ftp://ftp.gnu.org/gnu/glibc:
-*-*-*-*-*- 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/2.0.7pre6/. 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.
configure
--with-gnu-binutils --enable-shared --enable-add-ons=linuxthreads,crypt
configparms
containing the following:
# Begin configparms prefix=/usr slibdir=/lib sysconfdir=/etc # End configparms
make
/usr/lib/gcc-lib
to the usr/lib/gcc-lib
directory
on the normal Linux system.make install
/usr/lib/gcc-lib
symlinkYou can check if the GNU C Library seems to be working by running a dynamically
linked program that uses this library (like almost every program). A simple
test is running the ls
program that resides in the bin directory on your normal
Linux partition. If you can run this program without any errors, then the GNU
C Library seems to be installed correctly.
Please not that if your normal Linux system uses a differnet library version that the one you just installed on your LFS system, that program will most likely crash and reported a 'Segmentation Fault' or something similar. If so, just continue with the installation of the C++ Library and the compilers. After the compilers are done you will compile a small test program and execute it for the sake of testing the compiler. If those two little programs execute without crashing, it means that 1) the compiler works 2) the C Library works too. So don't worry too much right now if programs from your normal Linux system don't work due to C Library incompatibilities.
If you have used a previous version of this HOWTO to install a LFS system and you wish to update your LFS system conforming the changes made in this version of the HOWTO, you first need to remove the existing files regarding the previously installed C++ library before continuing with this section.
This HOWTO used to install the C++ library from sources, but that has been changed and is an exception. The C++ library is installed from pre-compiled binaries. The reason is that I have not been able to find the sources for the C++ library version that I prefer to use. So until then we'll use pre-compiled binaries.
ar x libstdc++2.9_2.91.66-0slink2.deb
tar xvfz data.tar.gz
cp -av usr /
usr data.tar.gz control.tar.gz
debian-binary
ar x libstdc++2.9-dev_2.91.66-0slink2.deb
tar xvfz data.tar.gz
cp -av usr /
usr data.tar.gz control.tar.gz
debian-binary
You need to restart your system back into the normal Linux system to compile
the gcc compiler. Before you reboot, unmount the partitions you mounted (that
contained the glibc sources) and mount the LFS root partition read only by
running mount -o remount,ro / /
If you have used a previous version of this HOWTO to install a LFS system and you wish to update your LFS system conforming the changes made in this version, you first need to remove the existing files regarding the previously installed compilers before continuing with this section.
This HOWTO used to install the C++ compiler from source, but that has been changed and is an exception. The C++ compiler is installed using pre-compiled binaries. The reason is that I have not been able to find the sources for the C++ compiler version that I prefer to use. So until then we'll use pre-compiled binaries.
We also will link the C compiler statically. Although Glibc is installed on our LFS system, we still are compiling the compiler on our normal Linux system. The normal Linux system may contain a different version of Glibc and the compiler will be linked against that version. Therefore we will link the compiler statically and later on when all statically linked software is being re-installed we also will re-install the compiler. This procedure is not necessary if both your normal Linux system and the LFS system use the same Library version, but since I don't know that we will do it this way. This ensures this document is usable on every Linux system, no matter what version of libraries they use.
We'll create a little C and a little C++ program which we will use after the installations to determine if the compilers can find the necessary files in order to successfully compile a program.
// Begin test.c #include <stdio.h> int main() { printf("Hello World!\n"); return 0; } // End test.c
// Begin test2.cpp #include <iostream.h> int main() { cout << "Hello World!" << endl; return 0; } // End test2.cpp
configure
make LANGUAGES=c make stage1 make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2 -static" LANGUAGES=c make stage2 make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2 --static" LANGUAGES=c make compare
make CC="stage2/xgcc -Bstage2/" CFLAGS="-g
-O2" LANGUAGES=c install
ar x g++_2.91.66-0slink2.deb
tar xvfz data.tar.gz
cp -av usr /
usr data.tar.gz control.tar.gz
debian-binary
Note that this g++ compiler is already pre-compiled and linked against glibc 2.0.7. Therefore there is no need to re-install this package in a later stage.
ln -s /usr/lib/gcc-lib/<host>/2.7.2.3/cpp
/lib/cpp
ln -s /usr/lib/gcc-lib/<host>/2.7.2.3/cpp
/usr/bin/cpp
ln -s /usr/bin/gcc /usr/bin/cc
Replace <host> with the directory where the gcc-2.7.2.3 files were installed (i686-unknown-linux in my case).
We will compile two small programs which we will use to test if the compilers compile. Note that this is by no means an exhaustive test. It's just a little test to see if the compiler can find the necessary files in order to compile a basic program.
gcc test1.c -o test1
g++ test2.cpp -o test2
You need the Util Linux package again for this section. If you haven't deleted the Util Linux source directory, you can skip the first two steps.
configure
make agetty login
agetty
login
You have to reboot back into your normal Linux system for this step because we need a text editor which isn't installed yet.
The next step is modifying the $LFS/etc/inittab file so that agetty is started on a virtual console every time we start the system. This is how it works on most if not every Linux system.
$LFS/etc/inittab
file
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
Every time you log onto a Linux system, the /var/run/utmp file is modified. When this file isn't present, a lot of programs will start complaining, including agetty and login. So we just create an empty $LFS/var/run/utmp file and those programs won't complain anymore.
$LFS/var/run
directorytouch $LFS/var/run/utmp
If you want you can test the system now. Restart the system and boot into the LFS system. After the kernel and sysvinit are done loading, agetty should start and prompt you with a username. Since the only user we currently have is 'root', you login as root.
Restart your system in the LFS system. From now on you don't need to start your normal Linux system anymore. The reason we had to do this is because the LFS system was lacking a text editor.
In order to install Vim we need to have the ncurses libraries installed.
configure --with-shared
make
make install.data
make install
Vim comes in two separate parts: A 'src' package and a 'rt' (run-time) package. You need both in order to install Vim. If you put both archives in the same directory, the unpacked files of both archives will appear in the same directory that will be created when you unpack the first (it doesn't matter which one you unpack first).
configure
make
make install
You need the Sysvinit package again for this section.
Create the necessary directories by issuing these commands:
cd /etc mkdir rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d init.d rcS.d
debian/etc/init.d/rc
file to: /etc/init.drcS
containing the following:
#!/bin/sh # Begin /etc/init.d/rcS runlevel=S prevlevel=N umask 022 export runlevel prevlevel trap ":" INT QUIT TSTP for i in /etc/rcS.d/S??* do if [ ! -f "$i" ] && continue $i start done # End /etc/init.d/rcS
reboot
containing the following:
#!/bin/sh # Begin /etc/init.d/reboot echo -n "System reboot in progress..." /sbin/reboot -d -f -i # End /etc/init.d/reboot
halt
containing the following:
#!/bin/sh # Begin /etc/init.d/halt /sbin/halt -d -f -i -p # End /etc/init.d/halt
mountfs
containing the following:
#!/bin/sh # Begin /etc/init.d/mountfs check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } echo -n "Remounting root file system in read-write mode..." /sbin/mount -n -o remount,rw / check_status > /etc/mtab /sbin/mount -f -o remount,rw / echo -n "Mounting proc file system..." /sbin/mount proc check_status # End /etc/init.d/mountfs
umountfs
containing the following:
#!/bin/sh # Begin /etc/init.d/umountfs check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } echo -n "Unmounting file systems..." /sbin/umount -a -r check_status echo -n "Remounting root file system in read-only mode..." /sbin/mount -o remount,ro / check_status # End /etc/init.d/umountfs
sendsignals
containing the following:
#!/bin/sh # Begin /etc/init.d/sendsignals check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } echo -n "Sending all processes the TERM signal..." /sbin/killall5 -15 check_status echo -n "Sending all processes the KILL signal..." /sbin/killall5 -9 check_status
chmod 755 reboot halt mountfs
umountfs sendsignals
cd ../rc6.d; ln -s ../init.d/umountfs S90umountfs ln -s ../init.d/reboot S99reboot ln -s ../init.d/sendsignals S80sendsignals cd ../rc0.d; ln -s ../init.d/umountfs S90umountfs ln -s ../init.d/halt S99halt ln -s ../init.d/sendsignals S80sendsignals cd ../rcS.d; ln -s ../init.d/mountfs S10mountfs
/etc/fstab
containing the following:
/dev/<LFS-partition device> / ext2 defaults 0 1 /dev/<swap-partition device> none swap sw 0 0 proc /proc proc defaults 0 0
You can test the system by restarting your computer and boot into LFS again. Any errors should be gone now and your root partition should be mounted in read-write mode automatically.
You can now finally restart your computer with a command like shutdown
-r now
In this section we're going to reinstall all software that has been linked statically before dynamically. It's pretty straightforward like it was when we prepared our system for the Glibc installation.
It's important that you take a close look at this section. If you decide you can't be bothered reinstalling all the previously installed software, at least look at the new libraries and programs in this section. A few programs that are already installed depend on certain libraries when dynamically linked. But these libraries aren't only used by the already installed programs; other software might require it as well, so you want to install those. Also, a few programs recommend other programs to be installed. We didn't require those programs for the Glibc and GCC installation, but we might as well install them now to avoid problems later.
Make sure you remove the old source tree first for best result (to make sure all programs are linked dynamically).
configure
make LANGUAGES=c make stage1 make "CC=stage1/xgcc -Bstage1/" "CFLAGS="-g -O2" LANGUAGES=c make stage2 make "CC=stage2/xgcc -Bstage2/" "CFLAGS="-g -O2" LANGUAGES=c make compare
make CC="stage2/xgcc -Bstage2/" "CFLAGS="-g
-O2" LANGUAGES=c install
configure
make
make install
configure
make shared
make install
make install-shared
configure --with-installed-readline
make
Makefile
file and find the variable: bindirmake install
The just installed Bash version is compiled with the -g compiler flag, which means it's compiled with debugging information. This means that when you ever need to run bash through a debugger, the output is human readable, whereas a binary compiled without debugger information is very hard to debug. The downside is that the Bash executable is now about 1MB in size. If you remove the debug information, you'll have an executable of around 340KB in size. This is quite a difference and worth it if you don't debug programs at all.
You can edit the Makefile files whenever you compile a program so you can remove the -g compiler flags (often found in a CFLAGS variable), or you can run the strip program with one or more executables as the parameter(s). All debugging information will be deleted (this won't affect the program itself in any way whatsoever). The choice is yours.
make
make install
configure
make
make install
configure
make
make install
configure
make
date echo false
pwd sleep stty su true uname
chroot
basename
dirname env expr factor groups id logname nice nohup pathchk printenv printf
seq tee test tty uptime users who whoami yes
configure
make
Makefile
filemake install
/bin/install
file to the /usr/bin
directory
configure
make
make mkswap
mkswap
make fdisk
make cfdisk
cfdisk fdisk
cfdisk.8 fdisk.8
make agetty
make login
login.1
agetty.8
make
mount umount swapon losetup
*.8
files/sbin/swapoff
to /sbin/swapon
make dmesg
make rdev
dmesg
rdev
dmesg.8 rdev.8 swapdev.8 ramsize.8
vidmode.8 rootflags.8
/sbin/rdev, /sbin/swapdev, /sbin/ramsize,
/sbin/vidmode
and /sbin/rootflags
to /sbin/rdev
make more MOREHELPDIR=/usr/share/more
more
more.1
/usr/share/more
directorymore.help
configure
make
src/Makefile
file and find the variable: bindirmake install
/bin/cat
configure
make
make install
/usr/bin/rmt
program
configure
make
Makefile
file and find the variable: bindirmake install
There is a possibility you will experience compilation problems. If this is the case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/lfs-howto/gzip-1.2.4-lfs.tar.gz
configure
make
make install
configure
make
make install
configure
make
make install
configure
make
make install
configure
make
make install
configure
make
make install
There is a possibility you will experience compilation problems. If this is the case, you can download a fixed version of this package from the following URL: http://tts.ookhoi.dds.nl/download/lfs-howto/findutils-4.1-lfs.tar.gz
configure
make
make install
configure
make
make install
Configure
If you agree on all default values, you might want to configure the package
by running Configure -d
. This way you don't have to press enter all the time
to accept the default values.
make
make test
make install
configure
make
make install
configure
make
make install
The rest of the software that's part of our basic system will be installed in this section. You don't need all the software, but it's recommended to have it.
configure
make
When compiling I'm getting this error: mke2fs.c:142:SCSI_DISK_MAJOR not defined. I solved it the following way:
misc/mke2fs.c
file and find the first occurrence of SCSI_DISK_MAJORPlease note that I have no idea what this does when you're using a SCSI system, but I can guess not a heck of a lot of good. Since I'm using an IDE system this doesn't harm me. If you're using SCSI you're on your own I'm afraid since I have no idea on how to fix this. Perhaps you don't even get it when using (a) SCSI disk(s).
make install
We'll create a checkroot bootscript so that whenever we boot our LFS system, the root file system will be checked by fsck.
/etc/init.d/checkroot
containing the following:
#!/bin/sh # Begin /etc/init.d/checkroot echo "Activating swap..." /sbin/swapon -av if [ -f /fastboot ] then echo "Fast boot, no file system check" else mount -n -o remount,ro / if [ $? = 0 ] then if [ -f /forcecheck ] then force="-f" else force="" fi echo "Checking root file system..." fsck $force -a / if [ $? -gt 1 ] then echo echo "fsck failed. Please repair your file system manually by" echo "running fsck without the -a option" echo "Please note that the file system is currently mounted in" echo "read-only mode." echo " echo "I will start sulogin now. CTRL+D will reboot your system." /sbin/sulogin /reboot -f fi else echo "Cannot check root file system because it is not mounted in" echo "read-only mode." fi fi # End /etc/init.d/checkroot
/etc/init.d/umounts
file and put these lines as the first commands
(under the "# Begin /etc/init.d/umountfs" line)
echo "Deactivating swap..." /sbin/swapoff -av
chmod 755 /etc/init.d/checkroot
cd /etc/rcS.d; ln -s ../init.d/checkroot
S05checkroot
configure
make
make install
configure
make
make install
configure
make
make
as86
make
ld86
make
make install
/etc/lilo.conf
file from your normal Linux system to the /etc
directory on the LFS system
/boot
directory from your normal Linux
system to /boot on the LFS systemWe don't install the Debian Package manger itself, but a small program that is shipped with this package; the start-stop-daemon program. This program is very useful in boot scripts so we're going to use it.
make start-stop-daemon
start-stop-daemon
start-stop-daemon.8
make
make INSTALL=/bin/install install
/etc/syslog.conf
containing the following:Please note that the white spaces must be tabs and not just hitting the space bar a few times.
#!/bin/sh # Begin /etc/syslog.conf auth,authpriv.* /var/log/auth.log *.*;auth,authpriv.none /var/log/syslog daemon.* /var/log/daemon.log kern.* /var/log/kern.log mail.* /var/log/mail.log user.* /var/log/user.log mail.info /var/log/mail.info mail.warn /var/log/mail.warn mail.err /var/log/mail.err *.=info;*.=notice;*.=warn; \ auth,authpriv.none; \ daemon.none /var/log/messages *.emerg * # End /etc/syslog.conf
/etc/init.d/sysklogd
containing the following:
#!/bin/sh # Begin /etc/init.d/sysklogd test -f /usr/sbin/klogd || exit 0 test -f /usr/sbin/syslogd || exit 0 check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } case "$1" in start) echo -n "Starting system log daemon..." start-stop-daemon -S -q -o -x /usr/sbin/syslogd -- -m 0 check_status echo -n "Starting kernel log daemon..." start-stop-daemon -S -q -o -x /usr/sbin/klogd check_status ;; stop) echo -n "Stopping kernel log daemon..." start-stop-daemon -K -q -o -p /var/run/klogd.pid check_status echo -n "Stopping system log daemon..." start-stop-daemon -K -q -o -p /var/run/syslogd.pid check_status ;; reload) echo -n "Reloading system load daemon configuration file..." start-stop-daemon -K -q -o -s 1 -p /var/run/syslogd.pid check_status ;; restart) echo -n "Stopping kernel log daemon..." start-stop-daemon -K -q -o -p /var/run/klogd.pid check_status echo -n "Stopping system log daemon..." start-stop-daemon -K -q -o -p /var/run/syslogd.pid check_status sleep 1 echo -n "Starting system log daemon..." start-stop-daemon -S -q -o -x /usr/sbin/syslogd -- -m 0 check_status echo -n "Starting kernel log daemon..." start-stop-daemon -S -q -o -x /usr/sbin/klogd check_status ;; *) echo Usage: $0 {start|stop|reload|restart} exit 1 ;; esac # End /etc/init.d/sysklogd
chmod 755 /etc/init.d/sysklogd
cd /etc/rc2.d; ln -s ../init.d/sysklogd S03sysklogd cd ../rc6.d; ln -s ../init.d/sysklogd K90sysklogd cd ../rc0.d; ln -s ../init.d/sysklogd K90sysklogd
configure
make
make install
configure
make
make install
make install
make
make install
make
make install
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.
configure
make
make install
limits login.access
login.defs.linux shells suauth
/etc/login.defs.linux
to /etc/login.defs
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, but you can avoid a hassle by testing properly and reading manuals ;)
configure
make
make install
services protocols
make
make install
/etc/init.d/localnet
containing the following:
#!/bin/sh # Begin /etc/init.d/localnet check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } echo -n "Setting up loopback device..." /sbin/ifconfig lo 127.0.0.1 check_status echo -n "Setting up hostname..." /bin/hostname --file /etc/hostname check_status # End /etc/init.d/localnet
chmod 755 /etc/init.d/localnet
cd /etc/rcS.d; ln -s ../init.d/network
S03localnet
Create a new file /etc/hostname
and put the hostname in it. This is not
the FQDN (Fully Qualified Domain Name). This is the name you wish to call your
computer in a network.
If you want to configure a network card, you have to decide on the IP-address, FQDN and possible aliases for use in the /etc/hosts file. An example is:
<myip> myhost.mydomain.org somealiases
Make sure the IP-address is in the private network IP-address range. Valid ranges are:
Class Networks A 10.0.0.0 B 172.16.0.0 through 172.31.0.0 C 192.168.0.0 through 192.168.255.0
A valid IP address could be 192.168.1.1. A valid FQDN for this IP could be me.lfs.org
If you're not going to use a network card, you still need to come up with a FQDN. This is necessary for programs like Sendmail to operate correctly (in fact; Sendmail won't run when it can't determine the FQDN).
Here's the /etc/hosts
file if you don't configure a network card:
# Begin /etc/hosts (no network card version) 127.0.0.1 me.lfs.org <contents of /etc/hostname> localhost # End /etc/hosts (no network card version)
Here's the /etc/hosts
file if you do configure a network card:
# Begin /etc/hosts (network card version) 127.0.0.1 localhost 192.168.1.1 me.lfs.org <contents of /etc/hostname> # End /etc/hosts (network card version)
Of course, change the 192.168.1.1 and me.lfs.org to your own liking (or requirements if you are assigned an IP-address by a network/system administrator and you plan on connecting this machine to that network).
This sub section only applies if you are going to configure a network card. If not, skip this sub section and read on.
Create a new file /etc/init.d/ethnet
containing the following:
#!/bin/sh # Begin /etc/init.d/ethnet check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } /sbin/ifconfig eth0 <ipaddress> check_status # End /etc/init.d/ethnet
chmod 755 ethnet
cd ../rc2.d; ln -s ../init.d/ethnet
S10ethnet
/etc/init.d/localnet
/etc/init.d/ethnet
ping <your FQDN> ping <what you choose for hostname> ping localhost ping 127.0.0.1 ping 192.168.1.1 (only when you configured your network card)
All these five ping command's should work without failures. If so, the basic network is working.
We need to add a few groups and a user which will be used by the email utilities.
groupadd -g 1 bin
groupadd -g 2 kmem
groupadd -g 3 mail
useradd -u 1 -g bin -d /bin -s /bin/sh bin
There are two directories used by the email sub system, thus we need to create them and give them the proper permissions.
/var/spool
directory/var/spool/mqueue
directory/var/spool/mail
directorychmod 777 /tmp
chmod 700 /var/spool/mqueue
chmod 775 /var/spool/mail
chgrp mail /var/spool/mail
make
make install
make install-suid
Build
Build install
Configuring Sendmail isn't as easily said as done. There are a lot of things you need to consider while configuring Sendmail and I can't take everything into account. That's why at this time we'll create a very basic and standard setup. If you want to tweak Sendmail to your own liking, go right ahead, but this is not the right article. You could always use your existing /etc/sendmail.cf (or /etc/mail/sendmail.cf) file if you need to use certain features.
cf/lfs.mc
containing the following:
OSTYPE(LFS) FEATURE(nouucp) define(`LOCAL_MAILER_PATH', /usr/bin/procmail) MAILER(local) MAILER(smtp)
ostype/lfs.m4
by running touch ostype/lfs.m4
m4 m4/cf.m4 cf/lfs.cf > cf/lfs.cf
/etc/sendmail.cf
touch /etc/aliases
sendmail -v -bi
make *.c -o mail
Ignore possible 'comparison between pointer and integer' and 'assignments makes integer from pointer without a cast' warnings. You'll probably get quite a few of these. Though, the program seems to work just fine nevertheless.
mail
chgrp mail
/usr/bin/mail
chmod 2755 /usr/bin/mail
/etc/init.d/sendmail
containing the following:
#!/bin/sh # Begin /etc/init.d/sendmail check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } case "$i" in start) echo -n "Starting Sendmail..." start-stop-daemon -S -q -p /var/run/sendmail.pid \ -x /usr/sbin/sendmail -- -bd check_status ;; stop) echo -n "Stopping Sendmail..." start-stop-daemon -K -q -p /var/run/sendmail.pid check_status ;; reload) echo -n "Reloading Sendmail configuration file..." start-stop-daemon -K -q -s 1 -p /var/run/sendmail.pid check_status ;; restart) echo -n "Stopping Sendmail..." start-stop-daemon -K -q -p /var/run/sendmail.pid check_status sleep 1 echo -n "Starting Sendmail..." start-stop-daemon -S -q -p /var/run/sendmail.pid \ -x /usr/sbin/sendmail -- -bd check_status ;; *) echo "Usage: $0 {start|stop|reload|restart}" exit 1 ;; esac # End /etc/init.d/sendmail
chmod 755 /etc/init.d/sendmail
cd /etc/init.d/rc2.d; ln -s ../init.d/sendmail S20sendmail cd ../rc0.d; ln -s ../init.d/sendmail K20sendmail cd ../rc6.d; ln -s ../init.d/sendmail K20sendmail
My favorite email client is Mutt, so that's why we're installing this one. Feel free to skip the installation of Mutt and install your own favorite client. After all, this is going to be your system. Not mine.
If your favorite client is an X Window client (such as Netscape Mail) then you'll have to sit tight a little while till we've installed X.
configure
make
make install
configure
make
make install
It's time to test the email system now.
/usr/sbin/sendmail -bd
(you need to start sendmail
using the full path. If you don't, you can't let sendmail reload the sendmail.cf
by with kill -1 <sendmail pid>).echo "this is an email test"
| mail -s test root
mail
program and you should see your email there.useradd -m testuser
echo "test mail to testuser"
| mail -s test testuser
If this all worked just fine, you have a working email system for local email. It's not necessarily ready for Internet yet. You can remove the testuser by running userdel -r testuser
In this section we're going to install three of the most used Internet servers, together with the necessary clients. These are going to be installed:
telnetd with the standard telnet client
proftpd with the standard ftp client
apache with lynx as client
configure
make
make install
configure
make
make install
configure
make
make install
Apache isn't that easily configured. Like with Sendmail, a lot depends on your own preference and system setup. Therefore, once I again I stick with a very basic installation. If this doesn't work well enough for you, read the documentation and modify whatever you need to.
configure
make
make install
The Slang library is an alternative to the Ncurses library. We're going to use this library to link Lynx against. Though Lynx works fine with the Ncurses library, people recommend using the Slang library. I myself can't find a difference between a Lynx linked against the Slang library or against the Ncurses library. However, I'll just follow that advise and use Slang.
configure
make elf
make install-elf
make install-links
Zlib is a compression library, used by programs like PKware's zip and unzip utilities. Lynx can use this library to compress certain files.
configure
make
make install
configure --libdir=/etc --with-zlib --with-screen=slang
make
make install
make install-help
make install-doc
It's possible to run the daemons in either stand-alone mode or via the Internet Server daemon (inetd). Where possible, I choose to run the daemons in stand-alone mode. This makes it easier to start and stop individual processes without modifying the /etc/inetd.conf file constantly.
However, in the telnetd case it's better to run it via inetd, since telnetd doesn't seem to respawn itself when the last user logs out. This would mean as soon as the last person logs out from the telnet session, the telnet daemon stops as well. This isn't desirable, so we let telnetd run using inetd to spawn a telnet process whenever somebody logs on.
/etc/inetd.conf
containing the following:
# Begin /etc/inetd.conf telnet stream tcp nowait root /usr/sbin/in.telnetd # End /etc/inetd.conf
/etc/init.d/inetd
containing the following:
#!/bin/sh # Begin /etc/init.d/inetd check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } case "$1" in start) echo -n "Starting Internet Server daemon..." start-stop-daemon -S -q -p /var/run/inetd.pid \ -x /usr/sbin/inetd check_status ;; stop) echo -n "Stopping Internet Server daemon..." start-stop-daemon -K -q -p /var/run/inetd.pid check_status ;; reload) echo -n "Reloading Internet Server configuration file..." start-stop-daemon -K -q -s 1 -p /var/run/inetd.pid check_status ;; restart) echo -n "Stopping Internet Server daemon..." start-stop-daemon -K -q -p /var/run/inetd.pid check_status sleep 1 echo -n "Starting Internet Server daemon..." start-stop-daemon -S -q -p /var/run/inetd.pid \ -x /usr/sbin/inetd check_status ;; *) echo "Usage: $0 {start|stop|reload|restart}" ;; esac # End /etc/init.d/inetd
chmod 755 /etc/init.d/inetd
cd /etc/rc2.d; ln -s ../init.d/inetd S30inetd cd ../rc0.d; ln -s ../init.d/inetd K30inetd cd ../rc6.d; ln -s ../init.d/inetd K30 inetd
groupadd -g 65534 nogroup groupadd -g 4 ftp
useradd -u 65534 -g nogroup -d /home nobody useradd -u 4 -g ftp -m ftp
/etc/init.d/proftpd
containing the following:
#!/bin/sh # Begin /etc/init.d/proftpd check_status() { if [ $? = 0 ] then echo "OK" else echo "FAILED" fi } case "$1" in start) echo -n "Starting Pro FTP daemon..." start-stop-daemon -S -q -x /usr/sbin/proftpd check_status ;; stop) echo -n "Stopping Pro FTP daemon..." start-stop-daemon -K -q -x /usr/sbin/proftpd check_status ;; restart) echo -n "Stopping Pro FTP daemon..." start-stop-daemon -K -q -x /usr/sbin/proftpd check_status sleep 1 echo -n "Starting Pro FTP daemon..." start-stop-daemon -S -q -x /usr/sbin/proftpd check_status ;; *) echo "Usage: $0 {start|stop|restart}" ;; esac # End /etc/init.d/proftpd
chmod 755 /etc/init.d/proftpd
cd /etc/rc2.d; ln -s ../init.d/proftpd S40proftpd cd ../rc0.d; ln -s ../init.d/proftpd K40proftpd cd ../rc6.d; ln -s ../init.d/proftpd K40proftpd
Edit the files in the /usr/apache/etc directory and modify them according to your own needs.
httpd.conf
file and find the variable: Group
/etc/init.d/apache
containing the following:
#!/bin/sh # Begin /etc/init.d/apache case "$1" in start) echo -n "Starting Apache HTTP daemon..." /usr/apache/sbin/apachectl start ;; stop) echo -n "Stopping Apache HTTP daemon..." /usr/apache/sbin/apachectl stop ;; restart) echo -n "Restarting Apache HTTP daemon..." /usr/apache/sbin/apachectl restart ;; force-restart) echo -n "Stopping Apache HTTP daemon..." /usr/apache/sbin/apachectl stop sleep 1 echo -n "Starting Apache HTTP daemon..." /usr/apache/sbin/apachectl start ;; *) echo "Usage: $0 {start|stop|restart|force-restart}" ;; esac # End /etc/init.d/apache
chmod 755 /etc/init.d/apache
cd /etc/rc2.d; ln -s ../init.d/apache S50apache cd ../rc0.d; ln -s ../init.d/apache K50apache cd ../rc6.d; ln -s ../init.d/apache K50apache
The last step in this section is testing the just installed and configured daemons.
/etc/init.d/inetd
start
telnet localhost
/etc/init.d/proftpd start
ftp localhost
/etc/init.d/apache start
lynx http://localhost
If these tests ran without trouble, the daemons are all working fine.
make World
During the compilation process you will encounter a few errors about the "makedepend" script not being able to find the stddef.h stdarg.h and float.h header files. The script just isn't as smart as the compiler is apparently, since the compilation itself does work fine without compilation errors. Though, creating a few temporary symlinks won't solve the problem; they only will cause more problems for some reason.
So you just ignore the many makedepend errors you most likely will be getting. Also errors similar to "pointer targets in passing arg x of somefunction differ in signedness". You can rewrite those files if you feel like it. I won't.
make install
make install.man
Create a new file /etc/ld.so.conf
containing the following:
# Begin /etc/ld.so.conf /lib /usr/lib /usr/X11R6/lib # End /etc/ld.so.conf
ldconfig
ln
-s /usr/X11R6/include/X11 /usr/include/X11
Often software copies files to /usr/X11 so it doesn't have to know which release of X you are using. This symlink hasn't been created by the X installation, so we have to create it by ourselves.
ln -s /usr/X11R6 /usr/X11
There are a few ways to add the /usr/X11/bin path to the $PATH environment variable. One way of doing so is the following:
/root/.bashrc
with it's contents as follows: export PATH=$PATH:/usr/X11/binYou need to login again for this change to become effective. Or you can
update the path by running export PATH=$PATH:/usr/X11/bin manually
xf86config
If the XF86Config file created by xf86config doesn't suffice, then you better copy the already existing XF86Config from your normal Linux system to /etc. Cases wherein you need to make special changes to the file which aren't supported by the xf86config program force you to do this. You can always modify the created XF86Config file by hand. This can be very time consuming, especially if you don't quite remember what needs to be changed.
Now that X is properly configured it's time for our first test run.
startx
The X server should start and display 3 xterm's on your screen. If this is true in your case, X is running fine.
I choose to install Window Maker as the Window Manager. This is because I've used WindowMaker for quite a while now and I'm very satisfied with it. As usual, you don't have to do what I'm doing; install whatever you want. As you might know, you can install several Window Managers simultaneously and choose which one to start by specifying it in the $HOME/.xinitrc (or $HOME/.xsession in case you decide to use xdm) file.
configure
make
make install
xmkmf; make Makefiles; make includes;
make depend
Ignore the warning about not being able to find the X11/xpm.h file from make depend.
make
The compilation process will abort because the X11/xpm.h file cannot be found. So we install this file now and then recompile.
make install
make
make install
make -f scripts/makefile.lnx
make -f scripts/makefile.lnx install
configure
make
make install
configure --enable-shared --enable-static
make libjpg.la
make install
configure
make
make install
configure
make
make install
ldconfig
Every user who wishes to use WindowMaker has to run the wmaker.inst script before he or she can use it. This script will copy the necessary files into the user's home directory and modify the $HOME/.xinitrc file (or create it if it's not there yet).
wmaker.inst
startx
Before you can logon to the Internet, the kernel must be ppp-aware. You can accomplish this by compiling ppp-support directly into the kernel, or compiling the ppp drivers are modules which you load when you need them. Whatever you prefer, do it now by re-configuring the kernel if necessary. If your LFS kernel is already ppp-aware than you don't have to re-configure the kernel.
groupadd -g 5 daemon
mkdir /var/lock
configure
make
make install
/etc/resolv.conf
containing the following:
# Begin /etc/resolv.conf nameserver <IP address of your ISP's primairy DNS server> nameserver <IP address of your ISP's secundairy DNS server> # End /etc/resolv.conf
/usr/bin/pon
file containing the following:
#!/bin/sh # Begin /usr/bin/pon /usr/sbin/pppd call provider # End /usr/bin/pon
/usr/bin/poff
file containing the following:
#!/bin/sh # Begin /usr/bin/poff set -- `cat /var/run/ppp*.pid` case $# in 0) kill -15 `ps axw|grep "pppd call [[allnum:]]+"|grep -v grep|awk '{print $1}'` exit 0 ;; 1) kill -15 $1 exit 0 ;; esac # End /usr/bin/poff
/etc/ppp/peers
directory/etc/ppp/peers/provider
containing the following:
# Begin /etc/ppp/peers/provider noauth connect "/usr/sbin/chat -v -f /etc/chatscripts/provider" /dev/ttyS1 115200 defaultroute noipdefault # End /etc/ppp/peers/provider
/etc/chatscripts
directory/etc/chatscripts/provider
containing the following:
# Begin /etc/chatscripts/provider ABORT BUSY ABORT "NO CARRIER" ABORT VOICE ABORT "NO DIALTONE" ABORT "NO ANSWER" "" ATZ OK ATDT <ISP's phonenumber> TIMEOUT 35 CONNECT '' TIMEOUT 10 ogin: \q<username> TIMEOUT 10 assword: \q<mysecretpassword> # End /etc/chatscripts/provider
As you see from the sample scripts (these are the actual scripts I'm using myself) above I logon to my ISP using this chatscripts in stead of authenticating via pap or chap. Though my ISP supports pap, I choose to do it this slightly different way which has it's disadvantages and advantages. In my case the advantages outweigh the disadvantages. This way I have more control over my logon procedure and I can see closer what is happening when.
For example most times when I connect I have a window running tail -f /var/log/syslog
so I can keep an eye on when things like the username and password are sent.
For a far more detailed guide on how to set up Internet, I refer to Egil Kvaleberg's ISP-Hookup-HOWTO which is available from the LDP site at http://www.linuxdoc.org/
This section is only to be used by people who have installed a LFS system using previous versions of this HOWTO. If a major change in an installation approach has taken place, you first need to take some actions such as removing existing files from a package before you can re-install that package. This section is used to assist people who obtained an old, obsolete version of this HOWTO and after installing the LFS system noticed that there's a new HOWTO (like this one) fixing things that went wrong in the older versions.
This section only applies to people who have previously installed the C++ Library using LFS-HOWTO version 1.0, 1.1 or 1.2.
This section only applies to people who have previously installed compilers using LFS-HOWTO 1.0, 1.1 or 1.2.
Copyright (C) 1999 by Gerard Beekmans. This document may be distributed only subject to the terms and conditions set forth in the LDP License at http://www.linuxdoc.org/COPYRIGHT.html.
It is not necessary to display the license notice, as described in the LDP License, when only a small part of this document (the HOWTO) is quoted for informational or similar purposes. However, I do require you to display with the quotation(s) a line similar to the following line: "Quoted from the LFS-HOWTO at http://huizen.dds.nl/~glb/