Next Previous Contents

4. Installing Sysvinit

4.1 Preparing Sysvinit

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.

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

4.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:
 
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

4.3 Copying 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 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.

It 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. Make sure you copy it exactly as it is.

4.4 Installing a root 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.

4.5 Testing the system

After you've completed this section, we can test the system and see if we can logon to it. Please note that you will get errors regarding the init program not being able to start the rcS and rc scripts. 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." 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).


Next Previous Contents