Systemd boot hooks result in long boot

Not sure if this is the correct category for this, but like many I try to slim down my boot process as much as possible. Recently after switching to the systemd mkinit hooks, I have slimmed a couple seconds off what it was before but Im seeing quite a bit that I don’t understand now that I have changed boot hooks. I have done reading on the boot process but I’m having trouble narrowing down what I can change to expedite the process.

The only thing I can see in the journal that is causing problems is an elusive xhci error that adds a second or two to boot, but my attempts to fix it have been very 50/50 in fixing it. Connected to the charger or dock, it is not an issue but on battery power xhci is very delayed. I have tried disabling ASPM for battery, blacklisting the modules needed for xhci from ASPM, etc. and the problem has still only been fixed when attached to a power source.

The following are relevant lines in my mkinitcpio conf, and the output of both systemd-analyze and systemd-analyze blame

MODULES=(amdgpu radeon vfat)
HOOKS=(systemd autodetect kms keyboard sd-vconsole modconf block sd-encrypt filesystems fsck)
BINARIES=()
COMPRESSION="cat"
Startup finished in 12.355s (firmware) + 536ms (loader) + 5.702s (kernel) + 5.666s (initrd) + 5.488s (userspace) = 29.748s 
graphical.target reached after 4.041s in userspace.
7.732s sys-devices-virtual-misc-rfkill.device
7.732s dev-rfkill.device
7.675s sys-devices-platform-thinkpad_acpi-leds-tpacpi::kbd_backlight.device
7.499s dev-ttyS1.device
7.499s sys-devices-platform-serial8250-tty-ttyS1.device
7.499s sys-devices-platform-serial8250-tty-ttyS0.device
7.499s dev-ttyS0.device
7.498s sys-devices-platform-serial8250-tty-ttyS13.device
7.498s dev-ttyS13.device
7.497s sys-devices-platform-serial8250-tty-ttyS11.device
7.497s dev-ttyS11.device
7.497s dev-ttyS12.device
7.497s sys-devices-platform-serial8250-tty-ttyS12.device
7.496s sys-devices-platform-serial8250-tty-ttyS10.device
7.496s dev-ttyS10.device
7.496s dev-ttyS15.device
7.496s sys-devices-platform-serial8250-tty-ttyS15.device
7.496s sys-devices-platform-serial8250-tty-ttyS16.device
7.496s dev-ttyS16.device
7.495s dev-ttyS17.device
7.495s sys-devices-platform-serial8250-tty-ttyS17.device
7.495s sys-devices-platform-serial8250-tty-ttyS19.device
7.495s dev-ttyS19.device
7.494s dev-ttyS18.device
7.494s sys-devices-platform-serial8250-tty-ttyS18.device
7.493s sys-devices-platform-serial8250-tty-ttyS20.device
7.493s dev-ttyS20.device
7.493s sys-devices-platform-serial8250-tty-ttyS2.device
7.493s dev-ttyS2.device
7.492s sys-devices-platform-serial8250-tty-ttyS21.device
7.492s dev-ttyS21.device
7.492s dev-ttyS22.device
7.492s sys-devices-platform-serial8250-tty-ttyS22.device
7.492s dev-ttyS14.device
7.492s sys-devices-platform-serial8250-tty-ttyS14.device
7.492s dev-ttyS23.device
7.492s sys-devices-platform-serial8250-tty-ttyS23.device
7.491s sys-devices-platform-serial8250-tty-ttyS24.device
7.491s dev-ttyS24.device
7.491s dev-ttyS25.device
7.491s sys-devices-platform-serial8250-tty-ttyS25.device
7.490s sys-devices-platform-serial8250-tty-ttyS26.device
7.490s dev-ttyS26.device
7.490s dev-ttyS27.device
7.490s sys-devices-platform-serial8250-tty-ttyS27.device
7.489s sys-devices-platform-serial8250-tty-ttyS28.device
7.489s dev-ttyS28.device
7.489s sys-devices-platform-serial8250-tty-ttyS29.device
7.489s dev-ttyS29.device
7.489s dev-ttyS3.device
7.489s sys-devices-platform-serial8250-tty-ttyS3.device
7.488s sys-devices-platform-serial8250-tty-ttyS30.device
7.488s dev-ttyS30.device
7.488s sys-devices-platform-serial8250-tty-ttyS31.device
7.488s dev-ttyS31.device
7.487s dev-ttyS4.device
7.487s sys-devices-platform-serial8250-tty-ttyS4.device
7.487s dev-ttyS5.device
7.487s sys-devices-platform-serial8250-tty-ttyS5.device
7.487s dev-ttyS6.device
7.487s sys-devices-platform-serial8250-tty-ttyS6.device
7.486s dev-ttyS7.device
7.486s sys-devices-platform-serial8250-tty-ttyS7.device
7.486s dev-ttyS8.device
7.486s sys-devices-platform-serial8250-tty-ttyS8.device
7.486s dev-disk-by\x2dpartuuid-ac96b890\x2d7f39\x2da544\x2dbc8d\x2d5720d2f2979f.device
7.486s dev-disk-by\x2did-nvme\x2deui.8ce38e1000793942\x2dpart6.device
7.486s dev-disk-by\x2did-nvme\x2dKBG5AZNV1T02_LA_KIOXIA_32HC71GSENA5\x2dpart6.device
7.486s sys-devices-pci0000:00-0000:00:02.1-0000:01:00.0-nvme-nvme0-nvme0n1-nvme0n1p6.device
7.486s dev-disk-by\x2dpath-pci\x2d0000:01:00.0\x2dnvme\x2d1\x2dpart6.device
7.486s dev-disk-by\x2duuid-052ea56f\x2dacdc\x2d4fd6\x2dab17\x2d733c1cebb7b2.device
7.486s dev-nvme0n1p6.device
7.486s dev-ttyS9.device
7.486s sys-devices-platform-serial8250-tty-ttyS9.device
7.485s sys-devices-pci0000:00-0000:00:02.1-0000:01:00.0-nvme-nvme0-nvme0n1.device
7.485s dev-nvme0n1.device
7.485s dev-disk-by\x2did-nvme\x2dKBG5AZNV1T02_LA_KIOXIA_32HC71GSENA5.device
7.485s dev-disk-by\x2dpath-pci\x2d0000:01:00.0\x2dnvme\x2d1.device
7.485s dev-disk-by\x2ddiskseq-1.device
7.485s dev-disk-by\x2did-nvme\x2deui.8ce38e1000793942.device
7.484s dev-disk-by\x2dpartuuid-241d0b6a\x2d8d54\x2d4713\x2db3be\x2d0d0f2d721a3e.device
7.484s dev-disk-by\x2did-nvme\x2dKBG5AZNV1T02_LA_KIOXIA_32HC71GSENA5\x2dpart2.device
7.484s sys-devices-pci0000:00-0000:00:02.1-0000:01:00.0-nvme-nvme0-nvme0n1-nvme0n1p2.device
7.484s dev-nvme0n1p2.device
7.484s dev-disk-by\x2dpath-pci\x2d0000:01:00.0\x2dnvme\x2d1\x2dpart2.device
7.484s dev-disk-by\x2did-nvme\x2deui.8ce38e1000793942\x2dpart2.device
7.484s dev-disk-by\x2dpartlabel-Microsoft\x5cx20reserved\x5cx20partition.device
7.479s dev-disk-by\x2dpartuuid-6103c696\x2dce76\x2d4582\x2dafe7\x2d92bedb9d904e.device
7.479s dev-nvme0n1p3.device
7.479s dev-disk-by\x2did-nvme\x2deui.8ce38e1000793942\x2dpart3.device
7.479s sys-devices-pci0000:00-0000:00:02.1-0000:01:00.0-nvme-nvme0-nvme0n1-nvme0n1p3.device
7.479s dev-disk-by\x2dpath-pci\x2d0000:01:00.0\x2dnvme\x2d1\x2dpart3.device
7.479s dev-disk-by\x2dlabel-Windows.device
7.479s dev-disk-by\x2dpartlabel-Basic\x5cx20data\x5cx20partition.device
7.479s dev-disk-by\x2did-nvme\x2dKBG5AZNV1T02_LA_KIOXIA_32HC71GSENA5\x2dpart3.device
7.479s dev-disk-by\x2duuid-BE20D7A720D764C5.device
7.476s dev-disk-by\x2dlabel-WinRE_DRV.device
7.476s dev-disk-by\x2dpartuuid-4863079b\x2da72a\x2d4399\x2d92bc\x2df86d51c69dc7.device
7.476s dev-nvme0n1p4.device
7.476s dev-disk-by\x2did-nvme\x2dKBG5AZNV1T02_LA_KIOXIA_32HC71GSENA5\x2dpart4.device
7.476s dev-disk-by\x2duuid-9EECD7D7ECD7A7B3.device
7.476s dev-disk-by\x2did-nvme\x2deui.8ce38e1000793942\x2dpart4.device
7.476s dev-disk-by\x2dpath-pci\x2d0000:01:00.0\x2dnvme\x2d1\x2dpart4.device
7.476s sys-devices-pci0000:00-0000:00:02.1-0000:01:00.0-nvme-nvme0-nvme0n1-nvme0n1p4.device
7.473s dev-disk-by\x2dlabel-SYSTEM.device
7.473s dev-disk-by\x2did-nvme\x2dKBG5AZNV1T02_LA_KIOXIA_32HC71GSENA5\x2dpart1.device
7.473s dev-nvme0n1p1.device
7.473s dev-disk-by\x2dpartlabel-EFI\x5cx20system\x5cx20partition.device
7.473s dev-disk-by\x2did-nvme\x2deui.8ce38e1000793942\x2dpart1.device
7.473s sys-devices-pci0000:00-0000:00:02.1-0000:01:00.0-nvme-nvme0-nvme0n1-nvme0n1p1.device
7.473s dev-disk-by\x2dpath-pci\x2d0000:01:00.0\x2dnvme\x2d1\x2dpart1.device
7.473s dev-disk-by\x2dpartuuid-f30214d0\x2d9da5\x2d4d75\x2da56a\x2d9204f2bee3c2.device
7.473s dev-disk-by\x2duuid-B2D5\x2d3B2D.device
7.471s sys-devices-pci0000:00-0000:00:02.1-0000:01:00.0-nvme-nvme0-nvme0n1-nvme0n1p5.device
7.471s dev-nvme0n1p5.device
7.471s dev-disk-by\x2did-nvme\x2dKBG5AZNV1T02_LA_KIOXIA_32HC71GSENA5\x2dpart5.device
7.471s dev-disk-by\x2dpartuuid-6a5ff27d\x2de39f\x2d5544\x2dbeaa\x2dfd500d6c609c.device
7.471s dev-disk-by\x2duuid-FC5A\x2d980E.device
7.471s dev-disk-by\x2did-nvme\x2deui.8ce38e1000793942\x2dpart5.device
7.471s dev-disk-by\x2dpath-pci\x2d0000:01:00.0\x2dnvme\x2d1\x2dpart5.device
7.368s sys-module-configfs.device
6.767s dev-disk-by\x2dpath-pci\x2d0000:04:00.0\x2dplatform\x2drtsx_pci_sdmmc.0\x2dpart2.device
6.767s dev-disk-by\x2duuid-B894\x2d536D.device
6.767s dev-disk-by\x2did-mmc\x2dSN256_0x6058c0cf\x2dpart2.device
6.767s dev-mmcblk0p2.device
6.767s dev-disk-by\x2dlabel-key.device
6.767s dev-disk-by\x2dpartuuid-e68e0e95\x2d02.device
6.767s sys-devices-pci0000:00-0000:00:02.4-0000:04:00.0-rtsx_pci_sdmmc.0-mmc_host-mmc0-mmc0:aaaa-block-mmcblk0-mmcblk0p2.device
6.760s dev-disk-by\x2dpartuuid-e68e0e95\x2d01.device
6.760s dev-disk-by\x2did-mmc\x2dSN256_0x6058c0cf\x2dpart1.device
6.760s dev-disk-by\x2dpath-pci\x2d0000:04:00.0\x2dplatform\x2drtsx_pci_sdmmc.0\x2dpart1.device
6.760s dev-disk-by\x2duuid-6663\x2d3063.device
6.760s sys-devices-pci0000:00-0000:00:02.4-0000:04:00.0-rtsx_pci_sdmmc.0-mmc_host-mmc0-mmc0:aaaa-block-mmcblk0-mmcblk0p1.device
6.760s dev-mmcblk0p1.device
6.566s sys-devices-pci0000:00-0000:00:02.4-0000:04:00.0-rtsx_pci_sdmmc.0-mmc_host-mmc0-mmc0:aaaa-block-mmcblk0.device
6.566s dev-disk-by\x2did-mmc\x2dSN256_0x6058c0cf.device
6.566s dev-mmcblk0.device
6.566s dev-disk-by\x2dpath-pci\x2d0000:04:00.0\x2dplatform\x2drtsx_pci_sdmmc.0.device
6.566s dev-disk-by\x2ddiskseq-2.device
5.982s sys-devices-pci0000:00-0000:00:08.1-0000:07:00.0-backlight-amdgpu_bl0.device
1.445s tlp.service
1.376s systemd-tmpfiles-setup.service
1.266s systemd-binfmt.service
1.188s ldconfig.service
1.178s proc-sys-fs-binfmt_misc.mount
 963ms initrd-switch-root.service
 596ms systemd-udev-trigger.service
 526ms systemd-remount-fs.service
 437ms systemd-modules-load.service
 411ms modprobe@fuse.service
 384ms systemd-sysusers.service
 322ms modprobe@drm.service
 306ms systemd-random-seed.service
 269ms systemd-fsck@dev-disk-by\x2duuid-FC5A\x2d980E.service
 232ms lvm2-monitor.service
 228ms user@1000.service
 206ms systemd-boot-system-token.service
 196ms systemd-journal-flush.service
 190ms systemd-fsck@dev-disk-by\x2duuid-B2D5\x2d3B2D.service
 182ms kmod-static-nodes.service
 148ms systemd-journal-catalog-update.service
 133ms mnt-mmc\x2dSN256_0x6058c0cf\x2dpart1.mount
 127ms systemd-backlight@leds:tpacpi::kbd_backlight.service
 124ms systemd-logind.service
 114ms upower.service
  99ms dev-hugepages.mount
  99ms dev-mqueue.mount
  98ms sys-kernel-debug.mount
  98ms sys-kernel-tracing.mount
  97ms systemd-tmpfiles-setup-dev.service
  93ms user-runtime-dir@1000.service
  91ms systemd-backlight@backlight:amdgpu_bl0.service
  90ms systemd-journald.service
  79ms systemd-tmpfiles-clean.service
  78ms systemd-update-done.service
  77ms systemd-user-sessions.service
  69ms swapfile.swap
  66ms systemd-timesyncd.service
  65ms systemd-sysctl.service
  65ms systemd-update-utmp.service
  47ms initrd-cleanup.service
  40ms systemd-udevd.service
  24ms bluetooth.service
  23ms NetworkManager.service
  21ms polkit.service
  21ms dbus.service
  13ms systemd-fsck-root.service
  12ms wpa_supplicant.service
   9ms initrd-parse-etc.service
   5ms sys-fs-fuse-connections.mount
   4ms rtkit-daemon.service
   4ms sys-kernel-config.mount
   3ms initrd-udevadm-cleanup-db.service
   3ms boot.mount
   2ms efi.mount
   2ms modprobe@configfs.service
   1ms tmp.mount

Is there anything here that I can change or edit to shorten boot? I am already using an uncompressed initramfs and have kms enabled. The most irritating/troubling part is the rfkill services as I have systemd-rfkill maksed as per tlp configuration. So if tlp is taking care of the rfkill stuff, how can I disable the other .device entries at the top?

This device is also using LUKS which I realize will bottleneck my boot time significantly. I am unsure if minimizing the mkinit as described here will help much as removing autodetect seems mostly just to reduce time spent creating an image at update. I’m also not quite sure what hooks I need with systemd instead of base.

Any advice is appreciated greatly. I’m not fully an idiot on this topic as I’ve gotten my desktop to a 4s boot (on old and cheap hardware) and using minimal modules but it always helps to get another perspective. Im using sytemd-boot as well. Any other info I forgot can be posted if requested. Thanks!

I’m also quite curious if I should even be uncompressing my kernel. My main initramfs is only 79Mb but I have seen some amount of discussion over if compressed faster due to being loaded to ram faster than uncompressed because of size, but it seems like there’s a trade-off in that it is either longer to load to ram, or longer to read from ram when picking between these two choices.

You know what you’re doing. :grinning:

I am curious why you need to enable so many tty(s)?

archwiki has an article on this topic. See here

There’s a thread on this forum on the boot time as well, see here.

Thx for sharing @chroot . Bookmarked for future readings.

So far I have checked all boxes I’ve seen mentioned by the arch wiki but can’t help but feel I’m missing something. I’m not sure what the deal is with all the extra ttys, I only need like three or four max so if theres a way I can keep some of those from starting pls point me in that direction lol. I’ve only seen a little about it on other forums and they seemed to be left pretty inconclusive. I will also post in the other thread too though thanks @chroot !

If you want speed you really should be looking at compiling your own kernel with everything you need built into it and ditching initranfs altogether.

Is that possible with an encrypted system? @knob

Oh! Don’t know the answer to that . . .