systemd

Time

Daemon:

systemd-timedatd

Status:

timedatectl

Reboot

To reboot, run the command

systemctl reboot

To reboot for UEFI (Bios), run:

systemctl reboot --firmware-setup

systemd-boot

yay systemd-boot-pacman-hook

systemd-networkd

Journald

Limit journal size in:

sudo nano /etc/systemd/journald.conf
SystemMaxUse=500M

Kexec

https://wiki.archlinux.org/index.php/Kexec

Analyze and Improve Boot time

Recommendations:

  • Use systemd-boot instead of grub if UEFI support is available (usually VM’s support no UEFI until you install it manually, so probably the best to keep grub there)
  • Use the kernel boot command: quiet

To analyze the boot time, use systemd-analyze.

$ systemd-analyze
 Startup finished in 5853ms (kernel) + 1252ms (userspace) = 7106ms

Tip: To see how much time was spent in the initramfs, append the systemd hook to your HOOKS array in /etc/mkinitcpio.conf:

# udev replaced by systemd (add sd-encrypt after systemd if using encryption)
HOOKS="base systemd autodetect modconf block keyboard keymap filesystems"

As root, rebuild your initramfs with:

$ mkinitcpio -p linux
$ systemd-analyze
 Startup finished in 1766ms (kernel) + 4113ms (initramfs) + 1224ms (userspace) = 7104ms

Services startup time:

systemd-analyze critical-chain

or to see all services:

$ systemd-analyze blame

Create boot time chart/picture:

systemd-analyze plot > plot.svg

Silent Boot

Flickerfree booting (https://wiki.archlinux.org/index.php/Silent_boot):

Add to your kernel boot parameters (e.g. in /boot/loader/entries/). With Linux 5.1 this is not required anymore for Intel machines.

quiet loglevel=3 rd.udev.log_priority=3 rd.systemd.show_status=auto vt.global_cursor_default=0

Interestingly I had to enable additionally upower to get on the AMD GPU system no text output:

systemctl enable upower
systemctl mask systemd-hwdb-update.service

Disable not required services

There may be some services, that could be disabled, if you do not need them. Example of 2 services that are not required on my systems.

systemctl disable ModemManager.service
systemctl mask ModemManager.service
systemctl disable lvm2-monitor.service
systemctl mask lvm2-monitor.service

Fallback to working kernel

On Arch Linux you could install besides the mainline kernel as well the lts kernel as a fallback, so if the mainline kernel fails to boot that then at least there is another stable kernel available. This could then be combined with the new systemd-boot-count feature to automatically fallback to a working kernel.

https://www.phoronix.com/scan.php?page=news_item&px=Systemd-Boot-Count

Systemd Rescue Mode

Recently I was hit by an issue with a wrong installed mesa driver after I played around with mesa-git. Basically I notebook booted fine, but as soon as it tried to load SDDM something crashed very bad.

I couldn’t change to another non-graphical terminal (TTY) nor could I login via SSH.

On my notebook I use systemd-boot as a boot loader. It is fast and I don’t have issue with encryption. But as I have never seen any OS selection window like in GRUB2, I thought I have an issue… but pressing during the bios screen ESC multiple times showed by a systemd-boot loader where I could select to start normal, fallback, EFI default loader or Reboot into firmware interface.

The fallback options sounded very sweet. But it crashed as well because it tried to basically load the graphical target with SDDM as well.

After a reset I was again in the systemd-boot loader. Pressing “e” key allowed me to edit the lines. First thing I don’t understand, why is the parameter “quiet” provided in the fallback line. I mean people use this if something goes wrong so they want to see some output and possible failure messages and where the process is stuck. So why would this be a default. And second there is no option to tell the system to boot to a non-graphical environment. Again very bad.

I know there is something like a search engine on the internet, but it is still annoying, I found in https://fedoraproject.org/wiki/Systemd the following options with systemd (should work in systemd-boot, GRUB2 or as well in other boot loaders):

  • systemd.unit=rescue.target is a special target unit for setting up the base system and a rescue shell (similar to run level 1)
  • systemd.unit=emergency.target is very similar to passing init=/bin/sh but with the option to boot the full system from there
  • systemd.unit=multi-user.target for setting up a non-graphical multi-user system
  • systemd.unit=graphical.target for setting up a graphical login screen.

So I removed from the parameter “quiet” and added “systemd.unit=multi-user.target.

A little annoying is here, that the keyboard is not changed to your local. Findind special characters like = or – can take time for beginners.

And by pressing enter I could boot into a non-graphical environment. Great, but not as easy as I would wish. I hope I never have to tell this somebody by phone. Maybe I should open a bug report, but I fear they will ignore it.

D-Bus Broker

Dbus-broker can be installed on Arch Linux and it replaces the normal dbus. Users should not notice any big difference when using this new dbus-broker as it keeps backward compatibility.

Plymouth – Graphical Boot

The only case where a graphical boot is useful is if you use disk encryption. Typing it the password in the terminal is not nice.

yay plymouth

Add to mkinitcpio.conf the required hooks like (read the Arch Wiki for more details https://wiki.archlinux.org/index.php/Plymouth), example:

sudo nano /etc/mkinitcpio.conf
# replaced encrypt with plymouth-encrypt, if you have encryption
HOOKS="base udev plymouth plymouth-encrypt autodetect modconf block keyboard keymap filesystems"

Recommended for systemd:

# add sd-encrypt if you have encryption
HOOKS="base systemd sd-plymouth sd-encrypt autodetect modconf block keyboard keymap filesystems"

You should enable early KMS by adding to Modules as well the GPU module like, example (i915 for intel, amdgpu, nouveau, …):

MODULES="i915..."

Then deactivate the login manager and use the plymouth one instead.

sudo systemctl disable sddm.service

sudo systemctl enable sddm-plymouth.service

Add splash to kernel parameters and enable silent boot (https://wiki.archlinux.org/index.php/Silent_boot), e.g. in:

sudo nano /etc/loader/entries/archlinux.conf

quiet splash loglevel=3 vt.global_cursor_default=0

And if you use systemd hook add:

rd.udev.log-priority=3 rd.systemd.show_status=auto

For Intel add additionally (not required anymore Linux >= 5.1 and Intel Skylake and newer hardware):

i915.fastboot=1

List themes:

plymouth-set-default-theme -l

Enable theme (example solar)

sudo plymouth-set-default-theme -R <theme>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.