You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.5 KiB

---
2 months ago
title: "Systemd: slow reboot and shutdown fixed"
aliases: /posts/2022-06-27-systemd-slow-reboot-and-shutdown-fixed
summary: >
I'm not so into systemd systems and ever avoided systemd whenever possible,
but nowadays systems without systemd are very rare. So I'm learning my lessons
slowly and with some memory protection (e.g. this article). Sorry, this
article is not very well formatted...
date: 2022-06-26T22:41:49+02:00
2 months ago
lastmod: 2024-09-28T23:48:06+0000
categories: [computerstuff]
2 months ago
tags: [linux, systemd, manjaro]
---
I noticed long delays (more than 2 minutes) on reboots and poweroffs recently
on my Manjaro laptop.
## Fix the slow shutdown/reboot
View the last boot session log in reverse order
2 months ago
```console
$ journalctl -rb -1
2 months ago
```
and inspect that for abnormalities. Also look at your console when rebooting or
shutting down the system, as that may also present some good starting points.
**To make things short, here's my solution that I currently work with:**
I edited `/etc/systemd/system.conf` and changed the following values:
2 months ago
```ini
# file: "/etc/systemd/system.conf"
[Manager]
[...]
RebootWatchdogSec=1min
ShutdownWatchdogSec=1min
[...]
DefaultTimeoutStopSec=5s
[...]
2 months ago
```
## Have a quick look at the boot time
2 months ago
```console
$ systemd-analyze
2 months ago
```
and if you are more interested into which module slows down your boot, list them
with:
2 months ago
```console
$ systemd-analyze blame
2 months ago
```
Just out of curiosity I also used:
2 months ago
```console
$ sudo systemctl disable NetworkManager-wait-online.service
2 months ago
```
→ revert that with:
2 months ago
```console
$ sudo systemctl enable NetworkManager-wait-online.service
2 months ago
```
## Sources
The sources of my research and a more detailed explanation can be found
with those links:
- <https://itsfoss.com/check-boot-time-linux/>
- <https://itsfoss.com/long-shutdown-linux/>
## Update and Results on my Fedora box
Since I made the switch to Fedora 36 I had to re-do those steps.
With default values I got this result for `systemd-analyze`
2 months ago
```console
$ systemd-analyze
Startup finished in 7.754s (firmware) + 5.988s (loader) + 1.140s (kernel) + 13.027s (initrd) + 1min 21.493s (userspace) = 1min 49.403s
graphical.target reached after 1min 21.462s in userspace
2 months ago
```
Without userspace: <span style="border-bottom: 3px double;">27.9090s</span>
And with the changes above I get this
2 months ago
```console
$ systemd-analyze
Startup finished in 10.151s (firmware) + 2.368s (loader) + 1.128s (kernel) + 10.509s (initrd) + 8.480s (userspace) = 32.639s
graphical.target reached after 8.450s in userspace
2 months ago
```
Without userspace: <span style="border-bottom: 3px double;">24.1560s</span>