LFCS — Linux Foundation System Administrator
The Boot Sequence and Process Signals
Goal
You organize the boot stages and the GRUB and target concepts in documents, read /proc directly to make a system summary, and send signals to background processes to confirm the state changes.
Why it matters
Where to look when a boot fails is decided by "how far control got handed over". If nothing appears on the screen, it is between the firmware and the bootloader; if the menu appears but there is a kernel panic, it is between the kernel and initramfs; and if it stops just before the login prompt, it is after init. So it is not about memorizing the order; you have to know what changes at each boundary. When you put kernel parameters in GRUB, the directive also differs depending on whether they should apply only to the regular entry or to the recovery entry as well. The signal lab in the latter part is a process of confirming the state table from the earlier reading by hand. Stopped is not terminated, and a signal goes only to the PID you specify.
Steps
- In
/root/lfcs-boot/boot-order.txt, write the four boot stages in order, one per line:firmware,bootloader,kernel,init. - In
/root/lfcs-boot/grub.default, write four lines:GRUB_TIMEOUT=5,GRUB_DEFAULT=0,GRUB_CMDLINE_LINUX_DEFAULT="quiet splash", andGRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0". - Put the content of
/proc/cmdlineas it is into/root/lfcs-boot/cmdline.txt. - In
/root/lfcs-boot/sysinfo.txt, write three lines:kernel=<커널 릴리스>,memtotal_kb=<MemTotal 값>, andswaptotal_kb=<SwapTotal 값>(kernel= followed by the kernel release, and the others followed by the MemTotal and SwapTotal values). Write only numbers for the values. - In
/root/lfcs-boot/targets.txt, write the correspondence between runlevels and targets in four lines:0=poweroff.target,1=rescue.target,3=multi-user.target,5=graphical.target. - Start
sleep 4000in the background, write its PID to/root/lfcs-boot/stopped_pid.txt, and send that process a stop signal. Then write one line,state=<현재 상태 문자>(state= followed by the current state character), to/root/lfcs-boot/stopped.txt. - Start a second
sleep 4000, write its PID to/root/lfcs-boot/term_pid.txt, and send a terminate signal to only that process to get rid of it. Then write two lines,pid=<그 PID>(pid= followed by that PID) andalive=no, to/root/lfcs-boot/term.txt. The process you stopped in step 6 must still be alive.
Notes
- The PID of the process you just started in the background is in the special variable
$!. - You can read the state character with
ps -o stat=or as the third item of/proc/<PID>/stat. - The stop signal and the forced-kill signal can neither be caught nor ignored by the application.
- A common mistake: if you send a signal by name in step 7, the
sleepfrom step 6 dies too and grading fails. Specify the PID.
Organizing the boot stages
In /root/lfcs-boot/boot-order.txt, write the four boot stages in order, one per line: firmware, bootloader, kernel, init.
Write, in four stages, the order in which control is handed over after power comes on. One lowercase word per line.
The GRUB default settings file
In /root/lfcs-boot/grub.default, write four lines: GRUB_TIMEOUT=5, GRUB_DEFAULT=0, GRUB_CMDLINE_LINUX_DEFAULT="quiet splash", and GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0".
There are two directives that carry kernel parameters. One applies only to the regular entry, and the other applies including the recovery entry. If the value has a space, wrap it in quotes.
The parameters the kernel received this time
Put the content of /proc/cmdline as it is into /root/lfcs-boot/cmdline.txt.
The string actually passed to the kernel at boot is sitting as it is in one file under proc. Do not process it; put it in as it is.
Making a system summary from /proc
In /root/lfcs-boot/sysinfo.txt, write three lines: kernel=<커널 릴리스>, memtotal_kb=<MemTotal 값>, and swaptotal_kb=<SwapTotal 값> (kernel= followed by the kernel release, and the others followed by the MemTotal and SwapTotal values). Write only numbers for the values.
Read the kernel release with uname, and the total memory and total swap from the corresponding lines of meminfo. The unit is kB and you write only the number.
Runlevel and target correspondence
In /root/lfcs-boot/targets.txt, write the correspondence between runlevels and targets in four lines: 0=poweroff.target, 1=rescue.target, 3=multi-user.target, 5=graphical.target.
Write SysV runlevel numbers paired with systemd target unit names. The four are halt, single-user, multi-user, and graphical.
Stopping a process
Start sleep 4000 in the background, write its PID to /root/lfcs-boot/stopped_pid.txt, and send that process a stop signal. Then write one line, state=<현재 상태 문자> (state= followed by the current state character), to /root/lfcs-boot/stopped.txt.
There is a special variable that holds the PID right after you start something in the background. The stop signal cannot be caught by the application, and the state character can also be read from stat in proc.
Terminating only the second process
Start a second sleep 4000, write its PID to /root/lfcs-boot/term_pid.txt, and send a terminate signal to only that process to get rid of it. Then write two lines, pid=<그 PID> (pid= followed by that PID) and alive=no, to /root/lfcs-boot/term.txt. The process you stopped in step 6 must still be alive.
Start one more new process and send the terminate signal only to that PID. The process you stopped in the earlier step must be alive.