FSU

Booting Unix

UNIX/Linux Kernel initialization

3.x and 4.x boot

3.2.0 boot log

3.11 boot log

3.13 boot log

4.0.4 boot log

4.0.4 boot log

4.4 boot log

Linux booting

Most Linux installations use the very flexible multi-operating system boot loader grub (GRand Unified Bootloader) that can be used to boot different operating systems. Like Windows bootloaders, it can also sit on the Master Boot Record (MBR) of the boot device and transfer control to specific operating system kernels depending on either a user type-in or a default. Grub comes in two flavors, 1.0 and 2.0.

Previously, there was lilo, which is still seen occasionally (especially when booting from cd/dvd).

There's also syslinux, which is my current favorite. It's not nearly as heavy-weight as grub.

Sample grub.cfg

This is the nicely minimal grub.cfg file from LFS:

# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd0,2)

menuentry "GNU/Linux, Linux 4.9.9-lfs-8.0" {
        linux   /boot/vmlinuz-4.9.9-lfs-8.0 root=/dev/sda2 ro
}

Sample grub.cfg

Here's a grub configuration file on a Linux Mint 17.1 machine:


# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

UNIX/Linux init and bootup scripts

UNIX/Linux bootup scripts

Old style UNIX/Linux bootup scripts

The idea for init is that soft-links that start with a capital ``S'' are executed at startup; soft-links with a leading capital ``K'' are executed at shutdown (you can see this behavior in /sbin/rc2 on Solaris and /etc/rc.d/rc on RedHat).

The Linux init package usually includes a utility named runlevel that you can run to determine the current machine's run level.

Old style UNIX bootup scripts

Notice the location of the actual init shell scripts can vary (/etc, /etc/rc.d, etc.), even between different versions of UNIX. For instance, Solaris: /etc/rc?.d (/etc/rc2.d is typical), CentOS Linux: /etc/rc.d

UNIX/Linux Controlling init link sprawl

On some systems, you can use chkconfig to control the maze of links.

# chkconfig --list   # show what is on and what is off for runlevels
anacron        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
atd            	0:off	1:off	2:off	3:on	4:on	5:on	6:off
atieventsd     	0:off	1:off	2:off	3:off	4:off	5:on	6:off
auditd         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
autofs         	0:off	1:off	2:off	3:on	4:on	5:on	6:off

# chkconfig --level 2345 sendmail on    # have sendmail start 2345

# chkconfig --del sendmail      # remove sendmail from chkconfig management
# chkconfig --add sendmail      # add sendmail to chkconfig management

Typical process tree for a small Debian 8 server

# pstree | cat
init-+-agetty
     |-atd
     |-11*[busybox]
     |-cron
     |-dbus-daemon
     |-exim4
     |-getty
     |-15*[httpd]
     |-ntpd
     |-rpc.idmapd
     |-rpc.statd
     |-rpcbind
     |-sshd---sshd---bash-+-cat
     |                    `-pstree
     |-udevd---2*[udevd]
     `-xinetd

systemd

Wikipedia on systemd

A version of the systemd(1) man page

Typical problems with UNIX booting

Upshot

Upshot

Beware that older versions of UNIX/Linux used symbolic links between a common script directory and the particular runlevel directory. Treat any modifications to the startup shell scripts as you would any other program -- edit, test (reboot), document, debug until it works.

Upshot

In a major site, you may find that weekly reboots at an off time (such as early on Sunday morning) are automatically done to discover any bad interactions among system modifications that might have been made recently.