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:
::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
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:
- Mounts
/proc,/sysand/devif the initramfs didn't, then/dev/pts,/dev/shmand/run. - Starts
mdevfor hotplug events and creates the device nodes that already exist. - Loads drivers for the hardware it finds, plus the modules listed in
/etc/modules. - Remounts
/read-write, mounts the rest of/etc/fstaband turns on swap. - Sets the host name from
/etc/hostnameand the clock from the hardware clock. - Brings up
lo, and runsifup -aif/etc/network/interfacesexists. - Starts
syslogdandklogd, which log to/var/log/messages. - Runs
/etc/rc.localif it exists and is executable.
Shutdown: rcK
On halt or reboot, /etc/init.d/rcK:
- Asks every process to stop (
SIGTERM), waits two seconds, then kills what's left. - Saves the system time to the hardware clock and turns off swap.
- Unmounts real filesystems, last mounted first. Any that won't unmount,
including
/, are remounted read-only instead.
Files you can change
| File | Effect |
|---|---|
/etc/hostname | Host name |
/etc/modules | Extra kernel modules to load at boot |
/etc/network/interfaces | Network configuration for ifup -a |
/etc/rc.local | Your own startup commands (make it executable) |
/etc/inittab | Login prompts, serial console, shutdown |
/etc/mkinitfs/modules | Extra modules in the initramfs (rerun mkinitfs) |