Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github

LinkedIn

To diagnose and troubleshoot getting started

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

This article describes the boot-up process on Linux so you can better diagnose and troubleshoot issues.

One-hour Rocky Linux sandbox

https://learning.oreilly.com/interactive-lab/rocky-linux-sandbox/9781098154349/lab/


Bootup

  1. View the System boot log:

    more /var/log/boot.log

    Example response:

    Starting udev:                                               [  OK  ]
    Setting hostname localhost.localdomain:                      [  OK  ]
    Setting up Logical Volume Management:   3 logical volume(s) in volume group "Vol Group" now active [  OK  ]
    Checking filesystems
    /dev/mapper/VolGroup-lv_root: clean, 188360/1068960 files, 2692948/4287488 blocks
    /dev/sda1: clean, 46/128016 files, 111454/512000 blocks      [  OK  ]
    Remounting root filesystem in read-write mode:               [  OK  ]
    Mounting local filesystems:                                  [  OK  ]
    Enabling local filesystem quotas:                            [  OK  ]
    Enabling /etc/fstab swaps:                                   [  OK  ]
    
  2. View /var/log/dmesg containing Kernel ring buffer (or kernel messages). Display the in-memory copy of the kernel ring buffer:

    sudo dmesg | head

    Example:

    Initializing cgroup subsys cpuset
    Initializing cgroup subsys cpu
    Linux version 2.6.32-573.7.1.el6.x86_64  (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313  (Red Hat 4.4.7-16) (GCC) ) #1 SMP Tue Sep 22 22:00:00 UTC 2015
    Command line: ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS  LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/ lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
    KERNEL supported cpus:
    Intel GenuineIntel
    AMD AuthenticAMD
    Centaur CentaurHauls
    BIOS-provided physical RAM map:
     BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
     

Bootup

BIOS -> Bootloader -> Kernel -> System Initialization

BIOS

The BIOS (Basic input/output system) performs sanity checks, such as the power-on self test (POST).

The BIOS loads the bootloader from the master boot record (MBR) on the hard disk.

Bootloader

The standard Linux bootloader is the grand unified boot loader (GRUB or GRUB2). It is responsible for loading the kernel and associated kernel modules (or libraries) stored in a file referred to as the initramfs.

  1. To get the GRUB menu, hold down the power button for 5 seconds or repeatedly pressing the Shift key during bootup.

  2. Press c to enter the GRUB command-line environment.
  3. Press Esc to return to main menu.
  4. Press b to boot selected stanza.
e edit selected stanza or line
o open/create new line after current line
O Open/create before current line
d delete current line

Kernel

The kernel is loaded from the hard disk to perform critical boot tasks. It then passes control of the boot process to a system initialization responsible for starting system services:

  • SysVinit (the oldest),
  • Upstart, and
  • Systemd (currently the most widely used).

The kernel starts the init process by reading file /etc/inittab to determine which runlevel to boot the system defined by the “initdefault” line.

See https://www.kernel.org/doc/Documentation/kernel-parameters.txt

Runlevel Target Description
0 poweroff.target Hal t the system.
1 or single poweroff.target Hal t the system.
2 multi-user.target Multi-user mode, traditionally with no NFS sharing or GUI.
3 multi-user.target Multi-user, traditionally with no GUI.
4 Not defined Either undefined (traditional) or a copy of runlevel 3.
5 graphical.target Multiple-user mode, traditionally with a GUI.
6 reboot.target Reboots the system.

“Emergency” / emergency.target is not technically a runlevel, but a boot stage in which a very basic environment is loaded.

Commands:

  • init switches to the runlevel specified as an argument. Example: init 1.

  • telinit Same function and syntax as the init command. Example: telinit 1.

  • shutdown brings the system down.

  • reboot reboots the system.

  • systemctl changes the current target on a Systemd-based distribution.

SysVinit

To set the default runlevel or boot target for SysVinit-based distributions, modify the second field of the initdefault line of the /etc/inittab file:

id:5:initdefault:

Upstart

Folder /etc/init contains configuration files for services.

File /etc/init/rc-sysinit.conf defines the default boot-up runlevel.

To set the default runlevel or boot target for Upstart-based distributions, set the DEFAULT_RUNLEVEL value

env DEFAULT_RUNLEVEL=2

SystemD

Instead of runlevels, Systemd uses a target for each specific services that start:

  • system.target
  • basic.target
  • multi-user.target
  • graphical.target

/lib/systemd/system

To set the default runlevel or boot target for systemd-based distributions, set the symbolic link from default.target to the desired target in

ln -s /etc/systemd/system/default.target /lib/systemd/system/graphical.target

Shutdown

The shutdown command is designed either to bring the system to a halt state or to completely power off the system. It can also be used to reboot the system.

See https://learning.oreilly.com/library/view/comptia-linuxlpic-1-portable/9780134692357/ch03.xhtml

Shell sessions

Linux launches a root shell session with this line:

rw init=/bin/bash

Wall broadcast

  1. List

    ls -l /bin/wall

    -r-xr-sr-x. 1 root tty 15344 Jun 9 2014 /bin/wall

    By default, all users can execute the wall command because of the SGID permission placed on the executable file.

  2. To broadcast a file or message text to all users who are currently logged in:

    wall -n [options][file message]

    If you get “wall -n: not priviliged” su -

    Regular users cannot use the -n option, which is designed to remove the standard banner message:

    Broadcast message from me@localhost.localdomain (pts/1) (Thu Nov 24 13:13:31 2019):
    

Resources

https://learning.oreilly.com/library/view/comptia-linuxlpic-1-portable/9780134692357/ch02.xhtml

More on macOS

This is one of a series about macOS: