Next Previous Contents

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.

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
 

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.

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.

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

5.6 Testing the system

After you've completed this section, we can test the system by rebooting into LFS and see if we can log on to it. When you reboot and are at the LILO prompt, enter the label you have entered in the lilo.conf file to start the LFS system. Then enter root's password and you should be on the bash-prompt now. 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 will be installed in a later chapter. 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 still intact).


Next Previous Contents