Master Linux Boot Process: From BIOS to Init with Practical Commands
This guide walks through Linux system startup fundamentals, covering nohup usage, nice value adjustments, runlevel inspection, initramfs handling, detailed boot sequence steps, chkconfig and GRUB configuration, and hands‑on exercises for creating services and building a custom Linux system.
1. nohup command
Run commands without hanging up; output is appended to nohup.out in the current directory or the home directory if unwritable. Use nohup COMMAND & to run in background and manage with jobs.
2. Setting and adjusting nice value
Change process priority with nice and renice. Example: # nice -n -5 ping 127.0.0.1 Result shows increased priority. Ordinary users can only increase the nice value (lower priority).
3. rc#.d run‑level scripts
Services prefixed with K (kill) or S (start) are executed in numeric order; lower numbers run first.
4. ramdisk (initramfs) handling
Use mkinitrd initramfs-`uname -r`.img `uname -r` to generate an initramfs image. The image can be inspected with file and cpio -vt < initramfs‑…img to view its contents.
5. Viewing runlevel
# who -rDisplays the current runlevel (e.g., 3). runlevel shows the previous and current levels.
6. Inspecting initramfs files
# file initramfs-2.6.32-642.el6.x86_64.imgShows compression type and confirms it is a CPIO archive.
7. /etc/inittab and ctrl‑alt‑del
In CentOS 5, /etc/inittab defines the Ctrl‑Alt‑Del reboot; in CentOS 6 this is moved to /etc/init/control‑alt‑delete.conf. The mingetty respawn setting is now in /etc/init/serial.conf.
System boot process details
Step 1: Power‑On Self‑Test (POST) and BIOS – BIOS checks CPU, memory, disks, and loads configuration from CMOS.
Step 2: Read MBR – The first 512‑byte sector contains the boot loader and partition table.
Step 3: Boot Loader – Loads kernel and initramfs; legacy GRUB uses stage1, stage1.5, and stage2.
Step 4: Load Kernel – Kernel image is decompressed; initramfs provides necessary drivers for the real root filesystem.
Step 5: Init process – /sbin/init reads /etc/inittab to determine the default runlevel.
Step 6: System initialization – Scripts in /etc/rc.d/rc.sysinit set hostname, load udev, SELinux, mount filesystems, configure swap, set kernel parameters, and start LVM/RAID.
Step 7: Load kernel modules – Modules listed in /etc/modules.conf or /etc/modules.d are loaded.
Step 8: Execute run‑level scripts – Scripts in /etc/rc?.d run according to the current runlevel.
Step 9: rc.local – Final user‑custom script executed after all other init steps.
Step 10: Login – mingetty spawns /bin/login for user authentication.
2. chkconfig command (graphical interface)
Use ntsysv for a GUI view. Command‑line examples:
# chkconfig --list name # chkconfig --add name # chkconfig --del name # chkconfig --level 2345 name on|off|reset3. GRUB command‑line interface
If grub.conf is corrupted, the system drops to the GRUB prompt. Commands such as kernel and initrd can be entered manually; help lists available commands.
4. grub.conf configuration options
default=#– default menu entry (starting from 0) timeout=# – wait time before auto‑boot splashimage=(hd#,#)/path/to/image – background image hiddenmenu – hide menu unless a key is pressed password [--md5] STRING – protect menu editing title, root, kernel, initrd – define boot entries
5. Installing or repairing GRUB
Two methods:
Use grub-install --root-directory=/PATH /dev/sdX from a rescue shell.
Enter GRUB, set root (hd#,#) and run setup (hd#).
# grub-install --root-directory=/ /dev/sda3. Post‑lab exercises
Exercise 1: Add a system service
Create a script in /etc/init.d/ with header lines:
#!/bin/bash
# chkconfig: 2345 10 90
# description: AThen run chkconfig --add myservice.sh and manage it with service myservice.sh start|stop|status.
Exercise 2: Build a custom Linux system
Steps include creating a separate disk image, partitioning it for /boot and root, mounting, copying kernel and initramfs, installing GRUB to the new disk, creating /etc/fstab, and using a script ( copycmd0.sh) to copy required binaries and libraries into the new root filesystem.
#!/bin/bash
ch_root="/mnt/sysroot"
[ ! -d $ch_root ] && mkdir $ch_root
# functions bincopy and libcopy defined …
read -p "Please input a command or quit: " command
while [ "$command" != "quit" ]; do
if bincopy $command; then
libcopy $command
fi
read -p "Please input a command or quit: " command
doneAfter copying, chroot sysroot/ can be used to test the new system.
Images illustrating key steps
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
