Linux From Scratch Gerard Beekmans Version 2.2, April 3rd, 2000 This document describes the process of creating your own Linux system from scratch from an already installed Linux distribution, using noth- ing but the source code of software that we need ______________________________________________________________________ Table of Contents 1. Introduction 1.1 What's this all about? 1.2 New versions 1.3 Version history 1.4 Mailinglists 1.4.1 Subscribing 1.4.2 Unsubscribing 1.5 Contact info 2. Conventions used in this document 2.1 About $LFS 2.2 How to download the software 2.3 How to install the software 3. Packages you need to download 3.1 Mandatory software 3.2 Optional software 4. Preparing the new system 4.1 How we are going to do things 4.2 Creating a new partition 4.3 Creating an ext2 file system on the new partition 4.4 Mounting the new partition 4.5 Creating directories 4.6 Copying the /dev directory 5. Making the LFS system bootable 5.1 Installing Sysvinit 5.2 Configuring Sysvinit 5.3 Creating passwd & group files 5.4 Installing the Bash shell 5.5 Adding an entry to LILO 5.6 Testing the system 6. Installing a kernel 6.1 Note on ftp.kernel.org 6.2 Configuring the kernel 6.3 Updating LILO 6.4 Testing the system 7. Installing basic system software 7.1 About debugging symbols 7.2 Preparing LFS system for installing basic system software 7.2.1 Installing Binutils 7.2.2 Installing Bzip2 7.2.3 Install Diffutils 7.2.4 Installing Fileutils 7.2.5 Installing GCC on the normal system if necessary 7.2.6 Installing GCC on the LFS system 7.2.6.1 Creating necessary symlinks 7.2.7 Installing Glibc 7.2.7.1 Copying old NSS Library files 7.2.8 Installing grep 7.2.9 Installing gzip 7.2.10 Installing Make 7.2.11 Installing Sed 7.2.12 Installing Sh-utils 7.2.13 Installing Tar 7.2.14 Installing Textutils 7.2.15 Installing Util-linux 7.3 Installing basic systsem software 7.3.1 Remounting partition and activating swap 7.3.2 Installing GCC 7.3.3 Installing Bison 7.3.4 Installing Mawk 7.3.5 Installing Findutils 7.3.6 Installing Termcap 7.3.7 Installing Ncurses 7.3.8 Installing Less 7.3.9 Installing Perl 7.3.10 Installing M4 7.3.11 Installing Texinfo 7.3.12 Installing Autoconf 7.3.13 Installing Automake 7.3.14 Installing Bash 7.3.15 Installing Flex 7.3.16 Installing Binutils 7.3.17 Installing Bzip2 7.3.18 Installing Diffutils 7.3.19 Installing E2fsprogs 7.3.20 Installing File 7.3.21 Installing Fileutils 7.3.22 Installing Grep 7.3.23 Installing Groff 7.3.24 Installing Gzip 7.3.25 Installing Ld.so 7.3.26 Installing Libtool 7.3.27 Installing Linux86 7.3.28 Installing Lilo 7.3.29 Installing Make 7.3.30 Instaling Sh-Utils 7.3.31 Installing Shadow Password Suite 7.3.32 Installing Man 7.3.33 Installing Modutils 7.3.34 Installing Procinfo 7.3.35 Installing Procps 7.3.36 Installing Psmisc 7.3.37 Installing Sed 7.3.38 Installing start-stop-daemon 7.3.39 Installing Sysklogd 7.3.40 Installing Sysvinit 7.3.41 Install Tar 7.3.42 Installing Textutils 7.3.43 Installing Vim 7.3.44 Installing Util-linux 7.4 Removing old NSS Library files 7.5 Configuring the software 7.5.1 Configuring Glib 7.5.2 Configuring LILO 7.5.3 Configuring Sysklogd 7.5.4 Configuring Shadow Password Suite 7.5.5 Configuring Sysvinit 7.5.6 Creating /var/run/utmp file 8. Creating system boot scripts 8.1 Preparing the directories and master files 8.2 Creating the reboot script 8.3 Creating the halt script 8.4 Creating the mountfs script 8.5 Creating the umountfs script 8.6 Creating the sendsignals script 8.7 Creating the checkroot bootscript 8.8 Creating the Sysklogd bootscript 8.9 Setting up symlinks and permissions 8.10 Creating the /etc/fstab file 9. Setting up basic networking 9.1 Installing Netkit-base 9.2 Installing Net-tools 9.2.1 Creating the /etc/init.d/localnet bootscript 9.2.2 Setting up permissions and symlink 9.2.3 Creating the /etc/hostname file 9.2.4 Creating the /etc/hosts file 9.2.5 Creating the /etc/init.d/ethnet file 9.2.6 Setting up permissions and symlink for /etc/init.d/ethnet 9.2.7 Testing the network setup 9.3 Testing the system 10. Installing Network Daemons 10.1 Setting up SMTP 10.1.1 Creating groups and user 10.1.2 Creating directory 10.1.3 Installing Sendmail 10.1.4 Configuring Sendmail 10.1.5 Installing Procmail 10.1.6 Creating /etc/init.d/sendmail bootscript 10.1.7 Setting up permissions and symlinks 10.2 Setting up FTP 10.2.1 Creating groups and users 10.2.2 Installing Proftpd 10.2.3 Creating the /etc/init.d/proftpd bootscript 10.2.4 Setting up permissions and symlinks 10.3 Setting up HTTP 10.3.1 Installing Apache 10.3.2 Configuring Apache 10.3.3 Creating /etc/init.d/apache bootscript 10.3.4 Setting up permissions and symlinks 10.4 Setting up Telnet 10.4.1 Installing telnet daemon + client 10.4.2 Creating the /etc/inetd.conf configuration file 10.4.3 Creating the /etc/init.d/inetd bootscript 10.4.4 Setting up permissions and symlinks 10.5 Setting up PPP 10.5.1 Configuring the Kernel 10.5.2 Creating group 10.5.3 Installing PPP 10.5.4 Creating /etc/resolv.conf 10.5.5 Creating /etc/ppp/peers/provider 10.5.6 Creating /etc/chatscripts/provider 10.5.7 Note on password authentication 11. Installing Network Clients 11.1 Installing Email clients 11.1.1 Installing Mailx 11.1.2 Installing Mutt 11.1.3 Installing Fetchmail 11.1.4 Testing the email system 11.2 Installing FTP client 11.2.1 Installing Netkit-ftp 11.2.2 Testing FTP system 11.3 Installing HTTP client 11.3.1 Installing Zlib 11.3.2 Installing Lynx 11.3.3 Testing HTTP system 11.4 Installing Telnet client 11.4.1 Testing Telnet system 11.5 Installing PPP clients 11.5.1 Creating the connect script 11.5.2 Creating the disconnect script 11.5.3 Testing PPP system 12. Installing X Window System 12.1 Installing X 12.2 Creating /etc/ld.so.conf 12.3 Creating the /usr/include/X11 symlink 12.4 Creating the /usr/X11 symlink 12.5 Adding /usr/X11/bin to the $PATH environment variable 12.6 Configuring X 12.7 Testing X 12.8 Installing Window Maker 12.9 Preparing the system for the Window Maker installation 12.9.1 Installing libPropList 12.9.2 Installing libXpm 12.9.3 Installing libpng 12.9.4 Installing libtiff 12.9.5 Installing libjpeg 12.9.6 Installing libungif 12.9.7 Installing WindowMaker 12.10 Updating dynamic loader cache 12.11 Configuring WindowMaker 12.12 Testing WindowMaker 13. Resources 13.1 Books 13.2 HOWTOs 13.3 Other 14. The End 15. Copyright & Licensing Information ______________________________________________________________________ 1. Introduction 1.1. What's this all about? Having used a number of different Linux distributions, I was never fully satisfied with either of those. I didn't like the way the bootscripts were arranged, or I didn't like the way certain programs were configured by default and more of those things. I came to realize that when I want to be totally satisfied with a Linux system, I have to build my own Linux system from scratch. Ideally only using the source code. No pre-compiled packages of any kind. No help from some sort of cdrom or bootdisk that would install some basic utilities. You would use your current Linux system and use that one to build your own. This, at one time, wild idea seemed very difficult and at times almost impossible. The reason for most problems were due to my lack of knowledge about certain programs and procedures. After sorted out all kinds of dependency problems, compilation problems, etcetera, a manually Linux system was created and fully operational. I called this system and LFS system which stands for LinuxFromScratch. 1.2. New versions The latest version of the document can always be found at http://www.linuxfromscratch.org 1.3. Version history 2.1.5 - March 26th, 2000 This is not a full list of modified things. Because v2.0 is a major release, only the major changes are mentioned and not the minor ones. o Directory structure modified - LFS is FHS compliant now. Perhaps not 100%, but getting there. o New Glibc installation method o New GCC installation method o Eliminated the need for the pre-compiled Debian packages. o Totally revised software installation method - eliminated the need of all the statically linked packages in former chapter 6.1. o Various bugs fixed in software installation o Installed a few more programs from the util-linux package o Added the installation of the Bzip2 program o Explained in greater detail what the $LFS is all about - how to and how not to use it. o Simplified installation procedures for all packages in chapters 5 through 9.1 o Moved the installation of Glibc and GCC to chapter 7 in stead of having their own chapters which isn't necessary. o Modified Internet servers chapter: separated into Network Daemons and Network Clients chapter. Internet chapter has merged with these two new chapters. o Switched chapters 13 and 14 (X and Internet) and merged the chapters about X and Window Maker into chapter 14. o We're using a new Man program. This one is easier to use and configure than the man-db one we previously used. Both versions perform nearly the same jobs. o Added new chapter 13: Resources. This chapter contains a number of books and HOWTOs you'll find useful to read during or after building an LFS system. o Chapter 3: Fixed bzip2 link o Chapter 7.2.42: Simplified Util-Linux installation method o Chapter 3.1: Changed procps location o Chapter 7.2: Switched installation of Vim and Util-Linux (as we need an editor to install Util-Linux) o Chapter 7.3.33: Fixed procps installation. o Chapter 5.2: stripped inittab file so it won't complain about missing files at boot time. o Chapter 6: Rewrote kernel installation o Chapter 10.3: Fixed Apache bootscript o Chapter 10.3.2: Removed section about modifying the httpd.conf file. No longer necessary. Added the addition of /usr/apache/man to the /usr/share/misc/man.conf file o Chapter 11.1: Provided a fixed mailx package with a working Makefile file to simplify the installation procedure o Chapter 11.3.1: Added the --shared switch to configure so that Zlib is installed as a dynamic library rather than a static one. o Chapter 11.6: Have Lynx link against the Ncurses library in stead of the Slang. o Chapter 12: The newer man-db already has the X11/man directory in it's man_db.config file 2.2 - April 3rd, 2000 o The linuxfromscratch.org and linuxfromscratch.com domains are now operational. All former links to huizen.dds.nl/~glb and tts.ookhoi.dds.nl have been replaced by the appropriate links on www.linuxfromscratch.org o After the reboot in chapter 7.3, the swap partition is made active before we start compiling software. 1.4. Mailinglists There are two mailing lists 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 document. The latter is an open moderated list. Anybody can subscribe to it, but you cannot post messages to it (only the moderator(s) can do this). This list is primarily used for announcements of new versions of this document. 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. 1.4.1. Subscribing 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. 1.4.2. Unsubscribing 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 1.5. Contact info Direct all your questions preferably to the mailing list. If you need to reach me personally, send an email to gerard@linuxfromscratch.org 2. Conventions used in this document 2.1. About $LFS Please read the following carefully: throughout this document you will frequently see the variable name $LFS. $LFS must at all times be replaced by the directory where the partition that contains the LFS system is mounted. How to create and where to mount the partition will be explained later on in full detail in chapter 4. In my case the LFS partition is mounted on /mnt/hda5. If I read this document myself and I see $LFS somewhere, I will pretend that I read /mnt/hda5. If I read that I have to run this command: cp inittab $LFS/etc I actually will run this: cp inittab /mnt/hda5/etc It's important that you do this no matter where you read it; be it in commands you enter on the prompt, or in some file you edit or create. If you want, you can set the environment variable LFS. This way you can literally enter $LFS in stead of replacing it by something like /mnt/hda5. This is accomplished by running: export LFS=/mnt/hda5 If I read cp inittab $LFS/etc, I literally can type cp inittab $LFS/etc and the shell will replace this command by cp inittab /mnt/hda5/etc automatically. Do not forget to set the LFS variable at all times. If you haven't set the variable and you use it in a command, $LFS will be ignored and whatever is left will be executed. The command cp inittab $LFS/etc without the LFS variable set, will result in copying the inittab file to the /etc directory which will overwrite your system's inittab. A file like inittab isn't that big a problem as it can easily be restored, but if you would make this mistake during the installation of the C Library, you can break your system badly and might have to reinstall it if you don't know how to repair it. So that's why I strongly advise against using the LFS variable. You better replace $LFS yourself by something like /mnt/hda5. If you make a typo while entering /mnt/hda5, the worst thing that can happen is that you'll get an error saying "no such file or directory" but it won't break your system. Don't say I didn't warn you ;) 2.2. How to download the software Throughout this document I will assume that you have stored all the packages you have downloaded in a subdirectory under $LFS/usr/src. I myself have use the convention of having a $LFS/usr/src/sources directory. Under sources you'll find the directory 0-9 and the directories a through z. A package as sysvinit-2.78.tar.gz is stored under $LFS/usr/src/sources/s/ A package as bash-3.02.tar.gz is stored under $LFS/usr/src/sources/b/ and so forth. You don't have to follow this convention of course, I was just giving an example. It's better to keep the packages out of $LFS/usr/src and move them to a subdirectory, so we'll have a clean $LFS/usr/src directory in which we will unpack the packages and work with them. The next chapter contains the list of all the packages you need to download, but the partition that is going to contain our LFS system isn't created yet. Therefore store the files temporarily somewhere where you want and remember to copy them to $LFS/usr/src/ when you have finished chapter 4. 2.3. How to install the software Before you can actually start doing something with a package, you need to unpack it first. Often you will find the package files being tar'ed and gzip'ed (you can see this from a .tar.gz or .tgz extension). I'm not going to write down every time how to ungzip and how to untar an archive. I will tell you how to that once, in this paragraph. There is also the possibility that you have the possibility of downloading a .tar.bz2 file. Such a file is tar'ed and compressed with the bzip2 program. Bzip2 achieves a better compression than the commonly used gzip does. In order to use bz2 archives you need to have the bzip2 program installed. Most if not every distribution comes with this program so chances are high it is already installed on your system. If not, install it using your distribution's installation tool. o Start by copying the package from wherever you have stored it to the $LFS/usr/src directory o When you have a file that is tar'ed and gzip'ed, you unpack it by running: tar xvfz filename.tar.gz; rm filename.tar.gz or tar xvfz filename.tgz; rm filename.tgz o When you have a file that is tar'ed and bzip'ed, you unpack it by running: tar --use-compress-prog=bzip2 -xvf filename.tar.bz2; rm filename.tar.bz2 o When you have a file that is only tar'ed, you unpack it by running tar xvf filename.tar; rm filename.tar Note that immediately after we have unpacked the archive, we delete the package file as we don't need it anymore. That's why you have to copy the file and not move it. If you move it and then delete it, you will need to re-download it when you need it again. When the archive is unpacked a new directory will be created under the current directory (and this document assumes that you unpack the archives under the $LFS/usr/src directory). You have to enter that new directory before you continue with the installation instructions. All the above will be summarized as 'Unpack the xxx archive'. So, when you read it, you copy the package to $LFS/usr/src, you run the tar program to ungzip/unbzip and untar it, then you enter the directory that was created and then you read the next line of the installation instructions. After you have installed a package you can do two things with it. You can either delete the directory that contains the sources or you can keep it. If you decide to keep it, that's fine by me. But if you need the same package again in a later chapter (all software up to chapter 7.2 will be re-installed in chapter 7.3) you need to delete the directory first before using it again. If you don't do this, you might end up in trouble because old settings will be used (settings that apply to your normal Linux system but which don't apply anymore when you have restarted your computer into the LFS system). Doing a simple make clean does not always guarantee a totally clean source tree. The configure script also has files lying around in various subdirectories which are rarely removed by the make clean process. 3. Packages you need to download 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 and which this document is going to be based on. If you experience problems which you can't solve yourself, download the version that is assumed in this document (in case you download a newer version). 3.1. Mandatory software 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/pub/linux/kernel/ Binutils (2.9.1) : ftp://ftp.gnu.org/gnu/binutils/ Bzip2 (0.9.5d) : http://sourceware.cygnus.com/bzip2/ Diff Utils (2.7) : ftp://ftp.gnu.org/gnu/diffutils/ File Utils (4.0) : ftp://ftp.gnu.org/gnu/fileutils/ GCC (2.95.2) : ftp://ftp.gnu.org/gnu/gcc/ Glibc (2.1.3) : ftp://ftp.gnu.org/gnu/glibc/ Glibc-crypt (2.1.2) : ftp://ftp.gwdg.de/pub/linux/glibc/ Glibc-linuxthreads (2.1.3) : ftp://ftp.gnu.org/gnu/glibc/ Grep (2.4) : ftp://ftp.gnu.org/gnu/grep/ Gzip (1.2.4) : ftp://ftp.gnu.org/gnu/gzip/ Make (3.78.1) : 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/ Tar (1.13) : ftp://ftp.gnu.org/gnu/tar/ Text Utils (2.0) : ftp://ftp.gnu.org/gnu/textutils/ Util Linux (2.10f) : ftp://ftp.win.tue.nl/pub/linux/utils/util-linux/ Bison (1.28) : 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/ Ncurses (5.0) : ftp://ftp.gnu.org/gnu/ncurses/ Less (340) : ftp://ftp.gnu.org/gnu/less/ 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/ Autoconf (2.13) : ftp://ftp.gnu.org/gnu/autoconf/ Automake (1.4) : ftp://ftp.gnu.org/gnu/automake/ Flex (2.5.4a) : ftp://ftp.gnu.org/gnu/flex/ E2fsprogs (1.18) : ftp://tsx-11.mit.edu/pub/linux/packages/ext2fs/ File (3.26) : http://www.linuxfromscratch.org/download/file-3.26-lfs.tar.gz Groff (1.15) : ftp://ftp.gnu.org/gnu/groff/ Ld.so (1.9.9) : ftp://tsx-11.mit.edu/pub/linux/packages/GCC/ Libtool (1.3.4) : ftp://ftp.gnu.org/gnu/libtool/ Linux86 (0.14.3) : http://www.linuxfromscratch.org/download/linux86-0.14.3-lfs.tar.gz Lilo (21) : ftp://sunsite.unc.edu/pub/Linux/system/boot/lilo/ Shadow Password Suite (19990827) : ftp://piast.t19.ds.pwr.wroc.pl/pub/linux/shadow/ Man (1.5h1) : ftp://ftp.win.tue.nl/pub/linux-local/utils/man/ Modutils (2.3.9) : ftp://ftp.ocs.com.au/pub/modutils/ Termcap (1.3) : ftp://ftp.gnu.org/gnu/termcap/ Procinfo (17) : ftp://ftp.cistron.nl/pub/people/svm/ Procps (2.0.6) : ftp://people.redhat.com/johnsonm/procps/ Psmisc (19) : ftp://lrcftp.epfl.ch/pub/linux/local/psmisc/ Start-stop-daemon (0.4.1) : http://www.linuxfromscratch.org/download/ssd-0.4.1-lfs.tar.gz Sysklogd (1.3.31) : ftp://sunsite.unc.edu/pub/Linux/system/daemons/ Vim (5.6) : ftp://ftp.vim.org/pub/editors/vim/unix/ 3.2. Optional software 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. Netkit-base (0.17) : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit-devel/ Net-tools (1.54) : http://www.tazenda.demon.co.uk/phil/net-tools/ Procmail (3.14) : ftp://ftp.procmail.org/pub/procmail/ Sendmail (8.9.3) : ftp://ftp.sendmail.org/pub/sendmail/ Mailx (8.1.1) : http://www.linuxfromscratch.org/download/mailx-8.1.1-fixed.tar.gz Mutt (1.0i) : ftp://ftp.mutt.org/pub/mutt/ Fetchmail (5.2.0) : http://www.tuxedo.org/~esr/fetchmail/ Netkit-telnet (0.17) : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit-devel/ Proftpd (1.2.0pre9) : ftp://ftp.tos.net/pub/proftpd/ Netkit-ftp (0.17) : ftp://ftp.uk.linux.org/pub/linux/Networking/netkit-devel/ Apache (1.3.11) : http://www.apache.org/dist/ Zlib Library (1.1.3) : http://www.cdrom.com/pub/infozip/zlib/ Lynx (2.8.2) : http://www.slcc.edu/lynx/release/ PPP (2.3.11) : ftp://cs.anu.edu.au/pub/software/ppp/ Xfree86 (3.3.5) : 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/ 4. Preparing the new system 4.1. How we are going to do things 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 document 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. You will safe yourself a lot of trouble if your normal system uses glibc-2.0 or newer. Libc5 can cause some problems and is not supported in this document as I don't have access to such a machine anymore. 4.2. Creating a new partition Before we can build our new Linux system, we need to have an empty Linux partition on which we can build our new system. I recommend a partition size of at least 5 00 MB. You can get away with around 250MB for a bare system with no extra whistles and bells (such as software for emailing, networking, Internet, X Window System and such). If you already have a Linux Native partition available, you can skip this subsection. Start the fdisk program (or some other fdisk program if you prefer) 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 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. Remember what your new partition's designation is. It could be something like hda5 (as it is in my case). This newly created partition will be referred to as the LFS partition in this document. 4.3. Creating an ext2 file system on the new partition Once the partition is created, we have to create a new ext2 file system on that partition. To create a new ext2 file system we use the mke2fs command. Enter the new partition as the only option and the file system will be created. If your partition was hda5, you would run the command as mke2fs /dev/hda5 4.4. Mounting the new partition Once we have created the ext2 file system, it is ready for use. All we have to do to be able to access it (as in reading from and writing date to it) is mounting it. If you mount it under /mnt/hda5, you can access this partition by going to the /mnt/hda5 directory and then do whatever you need to do. This document will assume that you have mounted the partition on a subdirectory under /mnt. It doesn't matter which subdirectory you choose (or you can use just the /mnt directory as the mounting point), but a good practice is to create a directory with the same name as the partition's designation. In my case the LFS partition is called hda5 and therefore I mount it on /mnt/hda5 o Create the /mnt directory if it doesn't exist yet o Create the /mnt/xxx directory where xxx is to be replaced by your LFS partition's designation. o Mount the LFS partition by running: mount /dev/xxx /mnt/xxx and replace xxx by your LFS partition's designation. This directory (/mnt/xxx) is the $LFS you have read about earlier. So if you read somewhere to "cp inittab $LFS/etc" you actually will type "cp inittab /mnt/xxx/etc" where xxx is replaced by your partition's designation. 4.5. Creating directories Let's create the directory tree on the LFS partition according to the FHS standard which can be found at http://www.pathname.com/fhs/. Issuing the following commands will create the necessary directories. cd $LFS mkdir bin boot dev etc home lib mnt proc root sbin tmp usr var cd $LFS/usr mkdir bin include lib sbin share src ln -s share/man man ln -s share/doc doc ln -s . local ln -s ../etc etc ln -s ../var var cd $LFS/usr/share mkdir dict doc info locale man nls misc terminfo zoneinfo cd $LFS/usr/share/man mkdir man1 man2 man3 man4 man5 man6 man7 man8 cd $LFS/var mkdir lock log run spool tmp Now that the directories are created, copy the source files you have downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you will need to create this subdirectory yourself). 4.6. Copying the /dev directory 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 ownerships: cp -av /dev $LFS chown root.root $LFS/dev/* 5. Making the LFS system bootable 5.1. Installing Sysvinit Under normal circumstances, after the kernel is done loading and initializing various system components, it attempts to load a program called init which will finalize the system boot process. The package found on most if not every single Linux system is called Sysvinit and that's the program we're going to install on our LFS system. o Unpack the Sysvinit archive o Enter the src directory o Edit the Makefile file o Somewhere in this file, but before the rule all: put this line: ROOT = $LFS o Precede every /dev on the last four lines in this file by $(ROOT) After 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 o Install the package by running: make -e LDFLAGS=-static; make install 5.2. Configuring Sysvinit 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: ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now 1:2345:respawn:/sbin/sulogin # End /etc/inittab 5.3. Creating passwd & group files 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 user root's password. This means we need to have at least a passwd file present on the LFS system. o Create the $LFS/etc/passwd file containing the following: root:s394ul1Bkvmq2:0:0:root:/root:/bin/bash o Create the $LFS/etc/group file containing the following: root::0: The encoded password string above is: lfs123 When you logon to your LFS system, enter lfs123 when asked to enter user root's password. 5.4. Installing the Bash shell 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. o Unpack the Bash archive o Install Bash by running: ./configure --enable-static-link make; make -e prefix=$LFS/usr install mv $LFS/usr/bin/bash $LFS/bin cd $LFS/bin; ln -s bash sh 5.5. Adding an entry to LILO In order to being able to boot from this partition, we need to update our /etc/lilo.conf file. Add the following lines to lilo.conf: image= label=