Linux From Scratch HOWTO Gerard Beekmans v1.2, 9 January 2000 This document describes the process of creating your own Linux system from scratch, using nothing but the sources of needed software. ______________________________________________________________________ Table of Contents 1. Introduction 1.1 What's this all about? 1.2 New versions 1.3 Version history 1.4 TODO 1.5 Contact info 2. Software packages you need to download 3. Preparing a new partition 3.1 Creating a new partition 3.2 Creating an ext2 file system on the new partition 3.3 Adding an entry to LILO 3.4 Creating directories 3.5 Copying the /dev directory 4. Installing Sysvinit 4.1 Preparing Sysvinit 4.2 Configuring Sysvinit 4.3 Copying passwd & group files 4.4 Installing a root shell 4.5 Testing the system 5. Installing a kernel 5.1 Note on ftp.kernel.org 5.2 Configuring the kernel 5.3 Updating LILO 5.4 Copying the new kernel source tree to $LFS 5.5 Updating symlinks 5.6 Testing the system 6. Installing the GNU C Library 6.1 Preparing the system for the GNU C Library installation 6.1.1 Installing Make 6.1.2 Installing Sed 6.1.3 Installing Shell Utils 6.1.4 Installing File Utils 6.1.5 Installing Util Linux 6.1.6 Installing Text Utils 6.1.7 Installing Tar 6.1.8 Installing Gzip 6.1.9 Installing Binutils 6.1.10 Installing Grep 6.1.11 Installing Bison 6.1.12 Installing Mawk 6.1.13 Installing Find Utils 6.1.14 Installing Diff Utils 6.1.15 Installing Ld.so 6.1.16 Installing Perl 6.1.17 Installing M4 6.1.18 Installing Texinfo 6.1.19 Installing Automake 6.1.20 Installing Autoconf 6.2 Installing the GNU C Library 7. Installing the GNU CC compilers 7.1 Installing GCC 2.95.2 7.2 Installing GCC 2.7.2.3 8. Installing login utilities 8.1 Installing agetty + login 8.2 Modifying $LFS/etc/inittab 8.3 Creating the UTMP record file 8.4 Testing the system 9. Installing Vim 9.1 Preparing the system for the Vim installation 9.1.1 Installing Ncurses 9.2 Installing Vim 10. Creating initial boot scripts 10.1 Preparing the directories and master files 10.2 Creating the reboot script 10.3 Creating the halt script 10.4 Creating the mountfs script 10.5 Creating the umountfs script 10.6 Creating the sendsignals script 10.7 Set file permissions and create symlinks 10.8 Creating the /etc/fstab file 10.9 Testing the system 11. Reinstalling statically linked software 11.1 Installing the Termcap library 11.2 Installing the Readline library 11.3 Reinstalling Bash 11.4 Reinstalling Sysvinit 11.5 Reinstalling Make 11.6 Reinstalling Sed 11.7 Reinstalling Shell Utils 11.8 Reinstalling File Utils 11.9 Reinstalling + Installing Util Linux 11.10 Reinstalling Text Utils 11.11 Reinstalling Tar 11.12 Reinstalling Gzip 11.13 Reinstalling Bison 11.14 Installing Flex 11.15 Reinstalling Binutils 11.16 Reinstalling Grep 11.17 Reinstalling Mawk 11.18 Reinstalling Find Utils 11.19 Reinstalling Diff Utils 11.20 Installing Less 11.21 Reinstalling Perl 11.22 Reinstalling M4 11.23 Reinstalling Texinfo 12. Installing the rest of the basic system software 12.1 Installing E2fsprogs 12.1.1 Installing E2fsprogs 12.1.2 Creating the checkroot bootscript 12.1.3 Updating /etc/init.d/umountfs 12.1.4 Creating proper permissions and creating symlink 12.2 Installing File 12.3 Installing Libtool 12.4 Installing Modutils 12.5 Installing Linux86 12.6 Installing Lilo 12.6.1 Installing Lilo 12.6.2 Configuring Lilo 12.6.3 Copying kernel image files 12.7 Installing DPKG 12.8 Installing Sysklogd 12.8.1 Installing Sysklogd 12.8.2 Configuring Sysklogd 12.8.3 Creating the Sysklogd bootscript 12.8.4 Setting up symlinks and permissions 12.9 Installing Groff 12.10 Installing Man-db 12.11 Installing Procps 12.12 Installing Procinfo 12.13 Installing Procmisc 12.14 Installing Shadow Password 12.15 Installing GNU C++ Library 13. Setting up basic networking 13.1 Installing Netkit-base 13.2 Installing Net-tools 13.2.1 Creating the /etc/init.d/localnet bootscript 13.2.2 Setting up permissions and symlink 13.2.3 Creating the /etc/hostname file 13.2.4 Creating the /etc/hosts file 13.2.5 Creating the /etc/init.d/ethnet file 13.2.6 Setting up permissions and symlink for /etc/init.d/ethnet 13.2.7 Testing the network setup 14. Setting up Email sub system 14.1 Preparing system for Email sub system 14.1.1 Creating extra groups and user 14.1.2 Creating directories 14.2 Installing Procmail 14.3 Installing Sendmail 14.3.1 Installing Sendmail 14.3.2 Configuring Sendmail 14.4 Installing Mailx 14.5 Creating /etc/init.d/sendmail bootscript 14.6 Setting up permissions and symlinks 14.7 Installing Mutt 14.8 Installing Fetchmail 14.9 Testing the Email sub system 15. Installing Internet Servers 15.1 Installing telnet daemon + client 15.2 Installing Proftpd 15.3 Installing Netkit-ftp 15.4 Installing Apache 15.5 Installing Slang Library 15.6 Installing Zlib 15.7 Installing Lynx 15.8 Configuring the daemons 15.9 Configuring telnetd 15.9.1 Creating the /etc/inetd.conf configuration file 15.9.2 Creating the /etc/init.d/inetd bootscript 15.9.3 Setting up permissions and symlinks 15.10 Configuring proftpd 15.10.1 Creating necessary groups and users 15.10.2 Creating the /etc/init.d/proftpd bootscript 15.10.3 Setting up permissions and symlinks 15.11 Configuring apache 15.11.1 Editing apache configuration file 15.11.2 Creating /etc/init.d/apache bootscript 15.11.3 Setting up permissions and symlinks 15.12 Testing the daemons 16. Installing X Window System 16.1 Creating missing symlink 16.2 Installing X 16.3 Creating /etc/ld.so.conf 16.4 Modifying /etc/man_db.config 16.5 Creating the /usr/include/X11 symlink 16.6 Creating the /usr/X11 symlink 16.7 Adding /usr/X11/bin to the $PATH environment variable 16.8 Configuring X 16.9 Testing X 17. Installing Window Maker 17.1 Preparing the system for the Window Maker installation 17.1.1 Installing libPropList 17.1.2 Installing libXpm 17.1.3 Installing libpng 17.1.4 Installing libtiff 17.1.5 Installing libjpeg 17.1.6 Installing libungif 17.1.7 Installing WindowMaker 17.2 Updating dynamic loader cache 17.3 Configuring WindowMaker 17.4 Testing WindowMaker 18. Configuring system for Internet 18.1 Configuring Kernel 18.2 Creating groups and directories 18.3 Installing PPP 18.4 Creating /etc/resolv.conf 18.5 Creating the connect and disconnect scripts 18.6 Creating /etc/ppp/peers/provider 18.7 Creating /etc/chatscripts/provider 18.8 Note on password authentication 18.9 Other resources 19. Copyright & Licensing Information ______________________________________________________________________ 11.. IInnttrroodduuccttiioonn 11..11.. WWhhaatt''ss tthhiiss aallll aabboouutt?? 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. 11..22.. NNeeww vveerrssiioonnss The latest version of the document can always be found at http://huizen.dds.nl/~glb/ 11..33.. VVeerrssiioonn hhiissttoorryy 1.2 - January 9th, 2000 +o Section 2: Owen Cook pointed out that the link for the sysvinit package was wrong. It said cistron.nl. It should be ftp.cistron.nl +o Section 3.4: Added the usr/include directory to the list of directories that need to be created +o Section 4.3: Made a notion of the posibility that somebody's system might be using shadowed passwords. +o Section 6.1.3: The majority of the files that need to be copied was missing (the files that need to be copied to $LFS/usr/bin). +o Section 6.1.4: Forgot to mention that the mv program needs to be copied aswell +o Section 6.1.14: Forgot to mention that the cmp program needs to be copied aswell +o Section 7: Just to make sure nobody runs into problems, I added the comment that all file systems must be unmounted and the root file system must be mounted read-only before the computer is rebooted +o Section 7.2: Added the --local-prefix=/usr/gcc2723 swith to the configure command line +o Section 11.7: Fixed a typo in one of the programs: patchchk should be pathchk +o Section 11.9: Added compilation and copying of the mkswap program 1.1 - December 20th, 1999 +o Fixed a few typo's +o Modified section 18 (Configuring system for Internet) from just a reference to the ISP-Hookup-HOWTO to a basic explanation on how to setup Internet +o Fixed error in /etc/syslog.conf (in section 12.8.2) 1.0 - December 16th, 1999 +o Initial release 11..44.. TTOODDOO Things that need to be done for future releases +o Adding a section about Pam +o Adding a section about SSH 11..55.. CCoonnttaacctt iinnffoo You can reach me, Gerard Beekmans, at tts-sol@dds.nl 22.. SSooffttwwaarree ppaacckkaaggeess yyoouu nneeeedd ttoo ddoowwnnllooaadd 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, unless mentioned otherwise. The list is ordered on usage, meaning that the first program you see in the list is the first program we'll build in this document. Sysvinit : ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/ Bash : ftp://ftp.gnu.org/gnu/bash/ Linux Kernel : ftp://ftp.kernel.org/ Make : ftp://ftp.gnu.org/gnu/make/ Sed : ftp://ftp.gnu.org/gnu/sed/ Shell Utils : ftp://ftp.gnu.org/gnu/sh-utils/ File Utils : ftp://ftp.gnu.org/gnu/fileutils/ Util Linux : ftp://ftp.win.tue.nl/pub/linux/utils/util-linux/ Text Utils : ftp://ftp.gnu.org/gnu/textutils/ Tar : ftp://ftp.gnu.org/gnu/tar/ Gzip : ftp://ftp.gnu.org/gnu/gzip/ Binutils : ftp://ftp.gnu.org/gnu/binutils/ Grep : ftp://ftp.gnu.org/gnu/grep/ Bison : ftp://ftp.gnu.org/gnu/bison/ Mawk : ftp://ftp.gnu.org/gnu/mawk/ Find Utils : ftp://ftp.gnu.org/gnu/findutils/ Diff Utils : ftp://ftp.gnu.org/gnu/diffutils/ Ld.so : ftp://tsx-11.mit.edu/pub/linux/packages/GCC/ Perl : ftp://ftp.gnu.org/gnu/perl/ M4 : ftp://ftp.gnu.org/gnu/m4/ Texinfo : ftp://ftp.gnu.org/gnu/texinfo/ Automake : ftp://ftp.gnu.org/gnu/automake/ Autoconf : ftp://ftp.gnu.org/gnu/autoconf/ Glibc-2.0.7pre6 : ftp://ftp.gwdg.de/pub/linux/glibc/2.0.7pre6/ Glibc-crypt-2.0.7pre6 : 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/ GCC-2.95.2 : ftp://ftp.gnu.org/gnu/gcc/ GCC-2.7.2.3 : ftp://ftp.gnu.org/gnu/gcc/ Ncurses : ftp://ftp.gnu.org/gnu/ncurses/ Vim : ftp://ftp.vim.org/pub/vim/ Readline Library : ftp://ftp.gnu.org/gnu/readline/ Termcap Library : ftp://ftp.gnu.org/gnu/termcap/ Flex : ftp://ftp.gnu.org/gnu/flex/ Less : ftp://ftp.gnu.org/gnu/less/ E2fsprogs : ftp://tsx-11.mit.edu/pub/linux/packages/ext2fs/ File : ftp://ftp.debian.org/debian/dists/slink/main/source/utils/ Libtool : ftp://ftp.gnu.org/gnu/libtool/ Modutils : ftp://ftp.ocs.com.au/pub/modutils/v2.3/ Linux86 : ftp://ftp.debian.org/debian/dists/slink/main/source/devel Lilo : ftp://sunsite.unc.edu/pub/Linux/system/boot/lilo/ DPKG : ftp://ftp.debian.org/debian/dists/slink/main/source/base/ Sysklogd : ftp://sunsite.unc.edu/pub/Linux/system/daemon/ Groff : ftp://ftp.gnu.org/gnu/groff/ Man-db : ftp://ftp.debian.org/debian/dists/slink/main/source/doc/ Procps : ftp://tsx-11.mit.edu/pub/linux/sources/usr.bin/ Procinfo : ftp://ftp.cistron.nl/pub/people/svm/ Procmisc : ftp://lrcftp.epfl.ch/pub/linux/local/psmisc/ Shadow Password Suite : ftp://piast.t19.ds.pwr.wroc.pl/pub/linux/shadow/ libstdc++ : ftp://ftp.gnu.org/gnu/libstdc++/ Netkit-base : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit- devel/ Net-tools : http://www.tazenda.demon.co.uk/phil/net-tools/ Procmail : ftp://ftp.procmail.org/pub/procmail/ Sendmail : ftp://ftp.sendmail.org/pub/sendmail/ Mailx : ftp://ftp.debian.org/debian/dists/slink/main/source/mail/ Mutt : ftp://ftp.mutt.org/pub/mutt/ Fetchmail : http://www.tuxedo.org/~esr/fetchmail/ Netkit-telnet : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit- devel/ Proftpd : ftp://ftp.tos.net/pub/proftpd/ Netkit-ftp : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit-devel/ Apache : http://www.apache.org/dist/ Slang Library : ftp://space.mit.edu/pub/davis/slang/ Zlib Library : http://www.cdrom.com/pub/infozip/zlib/ Lynx : http://www.slcc.edu/lynx/release/ Xfree86 : ftp://ftp.xfree86.org/pub/XFree86/ libPropList : ftp://ftp.windowmaker.org/pub/libs/ libXpm : ftp://sunsite.unc.edu/pub/Linux/libs/X/ libpng : http://www.cdrom.com/pub/png/ libtiff : ftp://ftp.sgi.com/graphics/tiff/ libjpeg : http://www.ijg.org/ libungif : ftp://prtr-13.ucsc.edu/pub/libungif/ WindowMaker : ftp://ftp.windowmaker.org/pub/release/ PPP : ftp://cs.anu.edu.au/pub/software/ppp/ 33.. PPrreeppaarriinngg aa nneeww ppaarrttiittiioonn 33..11.. CCrreeaattiinngg aa nneeww ppaarrttiittiioonn 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. 33..22.. CCrreeaattiinngg aann eexxtt22 ffiillee ssyysstteemm oonn tthhee nneeww ppaarrttiittiioonn 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. 33..33.. AAddddiinngg aann eennttrryy ttoo LLIILLOO 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= label=