PDA

View Full Version : How to speed up boot time



Sandrew
1st April 2018, 12:09 PM
Hi Gals/Guys,

I have recently installed fedora and I really like the system. But I experience a couple of annoying things I would like some help to improve. One of them is the slow boot time. It feels like it takes ages. After researching this a bit, it seems firewalld and systemd-udev-settle are the bottle-necks but I am unsure what to do to fix them. Can some knowledgeable please help ? I have attached the results of systemd-analyze to have some metrics around the problem. I have an encrypted HDD, and I understand that the time I take to type the password is included in the results, but I am really concerned by the time between me hitting enter after supplying the LVM password and the login screen.


[sandrew@neela ~]$ uname -a
Linux neela 4.15.6-300.fc27.x86_64 #1 SMP Mon Feb 26 18:43:03 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[sandrew@neela ~]$ cat /etc/fedora-release
Fedora release 27 (Twenty Seven)



[sandrew@neela ~]$ systemd-analyze blame
2min 29.233s dnf-makecache.service
40.885s plymouth-quit-wait.service
24.769s NetworkManager-wait-online.service
21.850s dracut-initqueue.service
21.367s systemd-cryptsetup@luks\x2dc4a5b02d\x2d586e\x2d45f2\x2da8f 0\x2d4794d4410c74.service
14.859s cups.service
14.702s firewalld.service
9.388s lvm2-monitor.service
8.882s udisks2.service
8.726s libvirtd.service
8.296s systemd-udev-settle.service
7.894s sssd.service
7.707s dev-mapper-fedora\x2droot.device
6.372s systemd-journal-flush.service
4.706s initrd-switch-root.service
3.374s abrtd.service
3.360s polkit.service
3.359s ModemManager.service
3.292s user@42.service
2.945s systemd-fsck-root.service
2.886s switcheroo-control.service
2.879s gssproxy.service
2.848s systemd-udevd.service
2.527s rtkit-daemon.service
2.518s avahi-daemon.service
2.513s bluetooth.service
2.286s NetworkManager.service
1.998s colord.service
1.532s gdm.service
1.511s systemd-tmpfiles-setup-dev.service
1.415s fwupd.service
1.369s lvm2-pvscan@253:0.service
1.156s packagekit.service
1.031s accounts-daemon.service
864ms livesys.service
851ms chronyd.service
777ms wpa_supplicant.service
751ms fedora-readonly.service
676ms systemd-vconsole-setup.service
609ms systemd-rfkill.service
573ms systemd-fsck@dev-disk-by\x2duuid-e8dfde5d\x2df705\x2d4272\x2d9288\x2d724bb2204849.s ervice
552ms auditd.service
440ms boot.mount
411ms dmraid-activation.service
401ms systemd-udev-trigger.service
397ms systemd-logind.service
382ms systemd-fsck@dev-mapper-fedora\x2dhome.service
320ms systemd-backlight@leds:asus::kbd_backlight.service
298ms systemd-journald.service
295ms dev-hugepages.mount
294ms systemd-remount-fs.service
290ms dev-mqueue.mount
288ms sys-kernel-debug.mount
281ms fedora-import-state.service
259ms systemd-backlight@backlight:acpi_video0.service
248ms upower.service
240ms systemd-backlight@backlight:intel_backlight.service
236ms boot-efi.mount
232ms systemd-tmpfiles-setup.service
226ms kmod-static-nodes.service
210ms nfs-config.service
200ms systemd-fsck@dev-disk-by\x2duuid-08BC\x2dA789.service
194ms dracut-shutdown.service
189ms systemd-user-sessions.service
186ms dev-mapper-fedora\x2dswap.swap
164ms home.mount
149ms plymouth-read-write.service
141ms systemd-random-seed.service
130ms dracut-pre-pivot.service
126ms systemd-sysctl.service
110ms dracut-cmdline.service
105ms initrd-parse-etc.service
87ms systemd-tmpfiles-clean.service
87ms plymouth-switch-root.service
86ms rpc-statd-notify.service
76ms user@1000.service
61ms var-lib-nfs-rpc_pipefs.mount
45ms systemd-update-utmp.service
39ms sysroot.mount
23ms initrd-cleanup.service
19ms dracut-pre-udev.service
16ms plymouth-start.service
14ms geoclue.service
13ms initrd-udevadm-cleanup-db.service
10ms livesys-late.service
8ms tmp.mount
6ms systemd-update-utmp-runlevel.service
6ms sys-fs-fuse-connections.mount
1ms sys-kernel-config.mount


[sandrew@neela ~]$ systemd-analyze critical-chain
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.

graphical.target @1min 16.935s
└─multi-user.target @1min 16.935s
└─libvirtd.service @35.732s +8.726s
└─remote-fs.target @35.713s
└─remote-fs-pre.target @35.713s
└─iscsi-shutdown.service @35.712s
└─network.target @35.652s
└─wpa_supplicant.service @37.663s +777ms
└─dbus.service @15.799s
└─basic.target @15.779s
└─sockets.target @15.779s
└─virtlogd.socket @15.779s
└─sysinit.target @15.725s
└─systemd-update-utmp.service @15.679s +45ms
└─auditd.service @15.124s +552ms
└─systemd-tmpfiles-setup.service @14.888s +232ms
└─fedora-import-state.service @14.605s +281ms
└─local-fs.target @14.604s
└─run-user-42.mount @51.622s
└─local-fs-pre.target @13.097s
└─lvm2-monitor.service @3.708s +9.388s
└─lvm2-lvmetad.service @12.654s
└─lvm2-lvmetad.socket @3.636s
└─-.mount
└─system.slice
└─-.slice

Results of systemd-analyze plot
29515

Thanks

Dutchy
1st April 2018, 07:41 PM
You need to buy an SSD.

donatom
1st April 2018, 08:24 PM
I have Fedora 27 on a laptop and found that I had a lvmd service even though I have regular (non-lvm) partitions. If you don't use LVM partitioning, you could eliminate the wasted start-up time with "sudo systemctl mask lvm2-monitor.service" (apparently systemctl disable does not get rid of the lvm2-monitor.service). I don't know if you really need the virtualization service at boot. You might want to think about disabling libvirtd.service and starting it only when you need it which could reduce your start-up time.

Sandrew
1st April 2018, 09:25 PM
I have Fedora 27 on a laptop and found that I had a lvmd service even though I have regular (non-lvm) partitions. If you don't use LVM partitioning, you could eliminate the wasted start-up time with "sudo systemctl mask lvm2-monitor.service" (apparently systemctl disable does not get rid of the lvm2-monitor.service). I don't know if you really need the virtualization service at boot. You might want to think about disabling libvirtd.service and starting it only when you need it which could reduce your start-up time.

Unfortunately, I am using LVM and the virtualization service. But are not the slowest as far as I can see.

Sandrew
1st April 2018, 09:28 PM
You need to buy an SSD.

Thanks, but I doubt this is the issue.

antikythera
1st April 2018, 09:45 PM
1. /etc/default/grub

If you don't use IPv6 you can disable the IPv6 stack which will help a bit. add ipv6.disable=1 as an entry to GRUB_CMDLINE_LINUX_DEFAULT

also add rd.udev.log-priority=3 which supresses information messages like the systemd version but leaves warnings and encountered errors visible

2. journal vacuum

cut down the cruft stored by journal and it will speed up the scheduled journal log flush and rotation a bit


sudo journalctl --vacuum-size=50M --vacuum-time=30days

3. BTRFS

If you use BTRFS file system, occasionally it needs attention too:


sudo btrfs scrub start -BdqrRf /dev/sda3
sudo btrfs balance /

look at the btrfs man pages for descriptions of what they do before using them but they should help maintain the stability and speed of the file system if run once in a while. also, if you have a mechanical drive add autodefrag to the options of btrfs volumes in fstab. never add autodefrag when using an SSD though.

nsnbm
2nd April 2018, 12:42 AM
According to the 'system-analyze blame' output, the boot time is retarded by far mostly here: "2min 29.233s dnf-makecache.service"
You could turn off the makecache service and timer and see the improvement on next boot. You could do this with:


systemctl dnf-makecache.service dnf-makecache.timer off

and see what happens. You can always turn them back on. If the makecache.timer is off, when you run dnf to upgrade or install, it will then update the cache and that will take a few minutes. That's how it works for me.