Core dump overflow

Core dump in progress...

LFCS prep - Runlevels and bootloader configuration

| Comments

Today we’ll look at the following LFCS objectives:

  • Log into graphical and text mode consoles

  • Boot systems into different runlevels manually

  • Install, configure and troubleshoot the bootloader

systemd targets

First, let’s take a look at all the available targets:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
systemctl list-units --type=target --all
  UNIT                   LOAD      ACTIVE   SUB    DESCRIPTION
  basic.target           loaded    active   active Basic System
  cryptsetup.target      loaded    active   active Encrypted Volumes
  emergency.target       loaded    inactive dead   Emergency Mode
  final.target           loaded    inactive dead   Final Step
  getty.target           loaded    active   active Login Prompts
  graphical.target       loaded    active   active Graphical Interface
  local-fs-pre.target    loaded    active   active Local File Systems (Pre)
  local-fs.target        loaded    active   active Local File Systems
  multi-user.target      loaded    active   active Multi-User System
  network-online.target  loaded    active   active Network is Online
  network-pre.target     loaded    inactive dead   Network (Pre)
  network.target         loaded    active   active Network
  nfs-client.target      loaded    active   active NFS client services
  nss-lookup.target      loaded    inactive dead   Host and Network Name Lookups
  nss-user-lookup.target loaded    active   active User and Group Name Lookups
  paths.target           loaded    active   active Paths
  remote-fs-pre.target   loaded    active   active Remote File Systems (Pre)
  remote-fs.target       loaded    active   active Remote File Systems
  rescue.target          loaded    inactive dead   Rescue Mode
  rpcbind.target         loaded    inactive dead   RPC Port Mapper
  shutdown.target        loaded    inactive dead   Shutdown
  slices.target          loaded    active   active Slices
  sockets.target         loaded    active   active Sockets
  swap.target            loaded    active   active Swap
  sysinit.target         loaded    active   active System Initialization
‚óŹ syslog.target          not-found inactive dead   syslog.target
  time-sync.target       loaded    inactive dead   System Time Synchronized
  timers.target          loaded    active   active Timers
  umount.target          loaded    inactive dead   Unmount All Filesystems

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

29 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.

Out of these, we will only look at the most relevant ones:

  • emergency.target = emergency mode. All you have is systemd and a shell. This is what you use if, for instance, you experience disk failure

  • rescue.target = single user mode. It’s the equivalent of runlevel 1. In this mode, the early boot services are started and local mount points are mounted. No networking

  • multi-user.target = multi-user text mode with networking. Equivalent to runlevel 3

  • graphical.target = multi-user with GUI. Equivalent to runlevel 5

Let’s see what the default target is on my system:

1
2
systemctl get-default
graphical.target

You can set a new default target with systemctl set-default

It is possible to switch to a different target without rebooting, by using systemctl isolate . However, only targets with AllowIsolate=yes in their unit files can be isolated. Isolation will start or stop all necessary services for that particular target. You can use isolation to quickly switch between targets. You can achieve the same with the systemctl command:

1
2
systemctl rescue
systemctl emergency

Additionally, you can boot a desired target through the boot menu, by selecting e at the desired entry, and appending at the end of the kernel command line (the one starting with linux16) the entry systemd.unit=

bootloader troubleshooting

Here we’re only going to look at the grub2 bootloader. Its main configuration file is /boot/grub2/grub.cfg, but you’re not supposed to edit it directly, but use grub2-mkconfig to generate the configuration. So you first edit the GRUB parameters in /etc/default/grub, and then run grub2-mkconfig to create the cfg file. Let’s see the defaults I have:

1
2
3
4
5
6
7
8
cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

After editing those, you can run grub2-mkconfig > /boot/grub2/grub.cfg to create the new boot config file.

If you need to reinstall the bootloader, you can do so with grub2-install

Learn more

SysVinit to Systemd Cheatsheet

emergency mode vs rescue mode

1
2
3
4
5
6
7
8
9
 _________________________________________
/ You will always get the greatest        \
\ recognition for the job you least like. /
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Comments