Score:0

Ubuntu 21.04 takes too long to boot (or why is man-db.service taking so long?)

ph flag

I'm using Windows 10 and Ubuntu side by side on my HP Pavillion laptop with :

Intel® Core™ i7-8750H CPU @ 2.20GHz × 12 NVIDIA Corporation GP107M [GeForce GTX 1050 Ti Mobile] / GeForce GTX 1050 Ti/PCIe/SSE2and 16 GB of Ram.

According to 'systemd-analyze' :

Startup finished in 4.110s (kernel) + 1min 8.206s (userspace) = 1min 12.316s graphical.target reached after 1min 7.940s in userspace

if i type in 'systemd-analyze blame' :

39.619s man-db.service
38.758s plymouth-quit-wait.service
26.468s snapd.service
18.378s logrotate.service
18.269s dev-sda4.device
17.726s networkd-dispatcher.service
12.867s NetworkManager-wait-online.service
11.566s udisks2.service
10.604s dev-loop21.device
10.500s dev-loop25.device
10.321s dev-loop22.device
10.190s dev-loop3.device
 9.950s dev-loop26.device
 9.862s dev-loop31.device
 9.718s dev-loop23.device
 9.217s dev-loop28.device
 9.184s dev-loop16.device
 ...

it gets worse day by day and with each update. Saw a few threads about this problem but they were ancient by OS standarts (Ubuntu 12 or 14).

What can i do to get it back to speed again?


Edit: Paladin wanted me to do two things and here are the results of those:

#1 the result of sudo systemctl status man-db.service is :

● man-db.service - Daily man-db regeneration Loaded: loaded (/lib/systemd/system/man-db.service; static) Active: inactive (dead) TriggeredBy: ● man-db.timer Docs: man:mandb(8)

#2 Also after sudo journalctl | grep -i error > error.txt i got a 93997 line text file. I am including the log of the last boot below.

Haz 28 20:44:11 Ubuntu2104 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.PCI0.PEG0.PEGP._ON], AE_ALREADY_EXISTS (20201113/dswload2-326)
Haz 28 20:44:11 Ubuntu2104 kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20201113/psobject-220)
Haz 28 20:44:11 Ubuntu2104 kernel: ACPI BIOS Error (bug): Failure creating named object [\_SB.PCI0.PEG0.PEGP._OFF], AE_ALREADY_EXISTS (20201113/dswload2-326)
Haz 28 20:44:11 Ubuntu2104 kernel: ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20201113/psobject-220)
Haz 28 20:44:11 Ubuntu2104 kernel: ACPI Error: Aborting method \_SB.PCI0.SPI1.FPNT._CRS due to previous error (AE_AML_INVALID_RESOURCE_TYPE) (20201113/psparse-529)
Haz 28 20:44:11 Ubuntu2104 kernel: ACPI Error: Method execution failed \_SB.PCI0.SPI1.FPNT._CRS due to previous error (AE_AML_INVALID_RESOURCE_TYPE) (20201113/uteval-68)
Haz 28 20:44:11 Ubuntu2104 kernel: ACPI Error: Aborting method \_SB.PCI0.SPI2.FPNT._CRS due to previous error (AE_AML_INVALID_RESOURCE_TYPE) (20201113/psparse-529)
Haz 28 20:44:11 Ubuntu2104 kernel: ACPI Error: Method execution failed \_SB.PCI0.SPI2.FPNT._CRS due to previous error (AE_AML_INVALID_RESOURCE_TYPE) (20201113/uteval-68)
Haz 28 20:44:11 Ubuntu2104 kernel: pcieport 0000:00:1b.0: DPC: error containment capabilities: Int Msg #0, RPExt+ PoisonedTLP+ SwTrigger+ RP PIO Log 4, DL_ActiveErr+
Haz 28 20:44:11 Ubuntu2104 kernel: pcieport 0000:00:1b.3: DPC: error containment capabilities: Int Msg #0, RPExt+ PoisonedTLP+ SwTrigger+ RP PIO Log 4, DL_ActiveErr+
Haz 28 20:44:11 Ubuntu2104 kernel: pcieport 0000:00:1d.0: DPC: error containment capabilities: Int Msg #0, RPExt+ PoisonedTLP+ SwTrigger+ RP PIO Log 4, DL_ActiveErr+
Haz 28 20:44:11 Ubuntu2104 kernel: pcieport 0000:00:1d.4: DPC: error containment capabilities: Int Msg #0, RPExt+ PoisonedTLP+ SwTrigger+ RP PIO Log 4, DL_ActiveErr+
Haz 28 20:44:11 Ubuntu2104 kernel: RAS: Correctable Errors collector initialized.
Haz 28 20:44:11 Ubuntu2104 kernel: EXT4-fs (sda4): re-mounted. Opts: errors=remount-ro. Quota mode: none.
Haz 28 20:44:31 Ubuntu2104 systemd[1]: Started Process error reports when automatic reporting is enabled (file watch).
Haz 28 20:44:33 Ubuntu2104 grub-editenv[1162]: /usr/bin/grub-editenv: error: invalid environment block.
Haz 28 20:44:43 Ubuntu2104 NetworkManager[1097]: <warn>  [1624902283.1928] Error: failed to open /run/network/ifstate
Haz 28 20:44:47 Ubuntu2104 systemd-xdg-autostart-generator[1381]: Not generating service for XDG autostart app-org.gnome.DejaDup.Monitor-autostart.service, error parsing Exec= line: No such file or directory
Haz 28 20:44:54 Ubuntu2104 /usr/libexec/gdm-x-session[1413]:         (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
Haz 28 20:45:09 Ubuntu2104 goa-daemon[1523]: /org/gnome/OnlineAccounts/Accounts/account_1622216939_0: Setting AttentionNeeded to TRUE because EnsureCredentials() failed with: No credentials found in the keyring (goa-error-quark, 4)
Haz 28 20:45:08 Ubuntu2104 gnome-keyring-daemon[1406]: couldn't create system prompt: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.keyring.SystemPrompter exited with status 1
Haz 28 20:45:09 Ubuntu2104 goa-daemon[1523]: /org/gnome/OnlineAccounts/Accounts/account_1622208713_0: Setting AttentionNeeded to TRUE because EnsureCredentials() failed with: No credentials found in the keyring (goa-error-quark, 4)
Haz 28 20:45:09 Ubuntu2104 gnome-keyring-daemon[1406]: couldn't create system prompt: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.keyring.SystemPrompter exited with status 1
Haz 28 20:45:09 Ubuntu2104 goa-daemon[1523]: /org/gnome/OnlineAccounts/Accounts/account_1622208966_1: Setting AttentionNeeded to TRUE because EnsureCredentials() failed with: No credentials found in the keyring (goa-error-quark, 4)
Haz 28 20:45:09 Ubuntu2104 gnome-keyring-daemon[1406]: couldn't create system prompt: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.keyring.SystemPrompter exited with status 1
Haz 28 20:45:54 Ubuntu2104 gnome-session[1746]: gnome-session-binary[1746]: GnomeDesktop-WARNING: Could not create transient scope for PID 1905: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 1905 does not exist.
Haz 28 20:45:53 Ubuntu2104 gnome-session-binary[1746]: GnomeDesktop-WARNING: Could not create transient scope for PID 1905: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 1905 does not exist.
Haz 28 20:45:53 Ubuntu2104 gnome-shell[1766]: Error looking up permission: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for geolocation
Haz 28 20:46:00 Ubuntu2104 gnome-shell[1766]: JS ERROR: TypeError: method Gio.File.delete_async: At least 3 arguments required, but only 2 passed
Haz 28 20:46:29 Ubuntu2104 chrome[2340]: Theme parsing error: gtk.css:1555:23: 'font-feature-settings' is not a valid property name
Haz 28 20:46:29 Ubuntu2104 chrome[2340]: Theme parsing error: gtk.css:3593:25: 'font-feature-settings' is not a valid property name
Haz 28 20:46:29 Ubuntu2104 chrome[2340]: Theme parsing error: gtk.css:4055:23: 'font-feature-settings' is not a valid property name
Haz 28 20:46:38 Ubuntu2104 chrome[3289]: Theme parsing error: gtk.css:1555:23: 'font-feature-settings' is not a valid property name
Haz 28 20:46:38 Ubuntu2104 chrome[3289]: Theme parsing error: gtk.css:3593:25: 'font-feature-settings' is not a valid property name
Haz 28 20:46:38 Ubuntu2104 chrome[3289]: Theme parsing error: gtk.css:4055:23: 'font-feature-settings' is not a valid property name
Haz 28 20:46:38 Ubuntu2104 chromium_chromium.desktop[2340]: [2340:3229:0628/204638.941762:ERROR:rankings.cc(781)] Inconsistent LRU.
Haz 28 20:46:38 Ubuntu2104 chromium_chromium.desktop[2340]: [2340:3229:0628/204638.941791:ERROR:backend_impl.cc(1044)] Critical error found -8

Day 2: I removed every snap from the system. Also purged the snap-store and snapd. created the "nosnap" file so that it may not be installed again.(I could just go with linux mint) the boot time is now 1 min and 2 seconds. Which is not perfect but i am running the OS from a mechanical disk.

The top time takers on boot are

32.070s plymouth-quit-wait.service
15.017s systemd-journal-flush.service
13.740s networkd-dispatcher.service
13.304s NetworkManager-wait-online.service
10.085s accounts-daemon.service
 8.072s udisks2.service
 7.821s dev-sda4.device
 7.050s smartmontools.service
 6.787s NetworkManager.service
 6.106s grub-initrd-fallback.service
 5.930s polkit.service
 5.258s avahi-daemon.service
 5.256s bluetooth.service
 5.243s iio-sensor-proxy.service
 4.565s power-profiles-daemon.service
 4.361s ModemManager.service
 4.324s switcheroo-control.service
 4.320s thermald.service
 4.318s systemd-logind.service
 4.086s wpa_supplicant.service
 3.948s cups.service

My systemd-journal seems to be 1016,2M (checked with journalctl --disk-usage) I did a journalctl --verify Invalid entries. After that i did a sudo journalctl --vacuum-size=1G --vacuum-time=5d --vacuum-files=5 and the journal size is reduced to 224M

after a reboot i see that i can boot in 50.189s.

Startup finished in 3.967s (kernel) + 46.221s (userspace) = 50.189s 
graphical.target reached after 46.086s in userspace

Now the top time-spenders on boot are:

28.253s plymouth-quit-wait.service
13.209s NetworkManager-wait-online.service
12.748s networkd-dispatcher.service
10.563s udisks2.service
 9.754s accounts-daemon.service
 8.904s polkit.service
 7.690s avahi-daemon.service
 7.688s bluetooth.service
 7.655s NetworkManager.service
paladin avatar
kr flag
Please do a `sudo systemctl status man-db.service` in console and post the result. You may also do a `sudo journalctl | grep -i error` and show its results too.
Karter avatar
ph flag
I have inserted the results to the original question.
HuHa avatar
es flag
Maybe check with the _smartmontools_ if your disk is developing problems. ~40 seconds is way too long for rebuilding the man-db on a modern machine. Try running it manually: `sudo time mandb` and check how long it takes. It returns almost instantly (0.18 sec elapsed) on my machine (with / on an SSD).
paladin avatar
kr flag
What I first did not have noticed is the time snapd needs. In my opinion snapd is a total trash program. Snapd is some kind of sandbox container, which enables the user to run programs which were intended to run on different system settings. In short it's a program which 'enables' some compatibility layer. Unfortunately it tends that programmers become lazy and depend to much on this nonsens. snapd is probably mounting all this loop devices too. If you ask me, get rid of it. Make sure to remove all snaps with snapd, before you remove snapd with apt. _"Creating a VM just to run calc."_ lol
paladin avatar
kr flag
Snapd is good for older machines, where for example an old OS runs and you don't get the latest firefox/chromium for your OS. With snapd you may use a containered version of chromium/firefox, to have at least a safe browser. So the best way to use snapd is to use it to an absolut minimum, use it only where it's totally necessary. Unnfortunatly some stupid programmers think snapd is the way how to do, because it enables them to ignore updating their software. (Making the software outdated and a danger to security. It also needs a lot of system ressources to run.)
Karter avatar
ph flag
i just did a 'sudo time mandb' as HuHa suggested. It took about 2.57 seconds. after a restart and another 'systemd-analyze' : Startup finished in 4.042s (kernel) + 1min 4.111s (userspace) = 1min 8.154s graphical.target reached after 1min 4.009s in userspace. now the top (10sec+) services are : '31.385s plymouth-quit-wait.service 23.168s snapd.service 18.831s dev-sda4.device 14.976s networkd-dispatcher.service 14.179s NetworkManager-wait-online.service 11.104s udisks2.service 10.924s accounts-daemon.service' excluding dev-loopxx.devices .
Karter avatar
ph flag
I'll do as paladin said and remove the snaps and try again.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.