Skip to main content

Boot process

Three packages in the base profile boot the system: linux-virt is the kernel, mkinitfs builds its initramfs, and core-rc holds the scripts busybox init runs.

Kernel and initramfs​

mkinitfs builds the initramfs from the installed system. With no options it uses the only kernel in /lib/modules and writes /boot/initramfs-<flavor>, for example /boot/initramfs-virt.

It includes the modules for a virtio, NVMe or SATA root disk on ext4:

virtio_pci virtio_blk virtio_scsi nvme ahci sd_mod ext4

To boot from anything else, list the extra modules in /etc/mkinitfs/modules, one per line, and run mkinitfs again. The initramfs hands over to the real system with /dev, /proc and /sys already mounted.

Init​

busybox init reads /etc/inittab:

/etc/inittab
::sysinit:/etc/init.d/rcS

tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2

# a serial console, for virtual machines and headless boxes
#ttyS0::respawn:/sbin/getty -L 115200 ttyS0 vt100

::ctrlaltdel:/sbin/reboot
::shutdown:/etc/init.d/rcK
tip

For a virtual machine or a box without a screen, uncomment the ttyS0 line to get a login prompt on the serial console.

Startup: rcS​

/etc/init.d/rcS runs once at boot. In order, it:

  1. Mounts /proc, /sys and /dev if the initramfs didn't, then /dev/pts, /dev/shm and /run.
  2. Starts mdev for hotplug events and creates the device nodes that already exist.
  3. Loads drivers for the hardware it finds, plus the modules listed in /etc/modules.
  4. Remounts / read-write, mounts the rest of /etc/fstab and turns on swap.
  5. Sets the host name from /etc/hostname and the clock from the hardware clock.
  6. Brings up lo, and runs ifup -a if /etc/network/interfaces exists.
  7. Starts syslogd and klogd, which log to /var/log/messages.
  8. Runs /etc/rc.local if it exists and is executable.

Shutdown: rcK​

On halt or reboot, /etc/init.d/rcK:

  1. Asks every process to stop (SIGTERM), waits two seconds, then kills what's left.
  2. Saves the system time to the hardware clock and turns off swap.
  3. Unmounts real filesystems, last mounted first. Any that won't unmount, including /, are remounted read-only instead.

Files you can change​

FileEffect
/etc/hostnameHost name
/etc/modulesExtra kernel modules to load at boot
/etc/network/interfacesNetwork configuration for ifup -a
/etc/rc.localYour own startup commands (make it executable)
/etc/inittabLogin prompts, serial console, shutdown
/etc/mkinitfs/modulesExtra modules in the initramfs (rerun mkinitfs)