Booting the System in Linux
Booting the System in Linux
Here’s a detailed overview of Booting the System in Linux, covering all the topics you’ve listed:
🔧 1. BIOS Boot Sequence
BIOS (Basic Input/Output System):
- Initializes hardware (CPU, RAM, keyboard, disk, etc.)
- Looks for a bootable device (like HDD, SSD, USB)
- Loads the first sector (MBR or GPT) into memory
- Passes control to the bootloader (GRUB/LILO)
🚀 2. Linux Boot Events Overview
Boot Process Stages:
- BIOS/UEFI initializes hardware
- Bootloader (e.g., GRUB) loads the kernel
- Kernel initializes hardware and mounts root filesystem
- init/systemd runs as PID 1 and starts user-space services
Important Utilities:
dmesg
– Displays kernel ring buffer messages (hardware detection, drivers, errors)1
dmesg | less
journalctl -k
– Shows kernel messages (systemd)lsinitrd
orlsinitramfs
– Lists content of initramfs/initrd (temporary root before real rootfs)cat /proc/cmdline
– View current kernel boot options
💻 3. Common Commands to the Boot Loader (GRUB)
At the GRUB menu:
- Press
e
to edit boot entry You can modify:
- Kernel path
- Initrd path
- Kernel parameters
Common GRUB commands:
set root=(hd0,1)
– Sets the root partitionlinux /vmlinuz root=/dev/sda1 ro
– Loads kernelinitrd /initrd.img
– Loads initramfsboot
– Boots with the current setup
⚙️ 4. Kernel Options at Boot Time
Kernel boot parameters affect system behavior:
Examples:
single
or1
– Boots into single-user modeinit=/bin/bash
– Skips init system and gives a root shellnomodeset
– Disables kernel mode setting (graphics)quiet
– Reduces boot messagesroot=/dev/sda1
– Specifies root filesystem
To apply:
- At GRUB menu, press
e
- Append options to the
linux
line - Press
Ctrl + X
orF10
to boot
🔄 5. Init Systems: SysVinit, SystemD, Upstart
Feature | SysVinit | Upstart | SystemD (modern default) |
---|---|---|---|
PID 1 process | /sbin/init | /sbin/init | /lib/systemd/systemd |
Init files | /etc/init.d/* | /etc/init/*.conf | Unit files in /etc/systemd/system/ |
Parallel | No | Yes | Yes |
Active distro | Legacy (Debian, Slackware) | Older Ubuntu (9.10–14.10) | Most modern distros (Ubuntu, Arch, RHEL) |
🔁 6. Changing Runlevels / Targets / Single User Mode
SysVinit (legacy)
Runlevels:
- 0: Halt
- 1: Single user
- 3: Multi-user
- 5: Multi-user + GUI
- 6: Reboot
Commands:
1 2 3
init 1 # Switch to single-user mode runlevel # Shows previous and current runlevel telinit 3 # Switch to runlevel 3
SystemD (modern)
Targets:
rescue.target
– Single-user modemulti-user.target
– Non-GUIgraphical.target
– GUI
Commands:
1 2 3
systemctl isolate rescue.target # Switch to single-user systemctl get-default # Show default target systemctl set-default graphical.target
🔚 7. Reboot & Shutdown (with User Alerts)
Commands:
1
2
3
4
5
shutdown -r now # Reboot immediately
shutdown -h +10 "System will shut down in 10 minutes." # Graceful halt with warning
halt # Immediate halt
poweroff # Turn off the system
reboot # Reboot the system
Alerting Logged-in Users:
wall
sends messages to all terminals:1
wall "System will reboot in 5 minutes. Please save your work."
shutdown
does this automatically when scheduled:1
shutdown -r +5 "System rebooting for maintenance."
This post is licensed under CC BY 4.0 by the author.