keyboard-setup.service taking too long in startup (20+sec)

7,842

Solution 1

@hector-muñoz-h's answer works, but it is not the right way. You should not edit distro files.

This is the right way:

FIXSERVICE="keyboard-setup.service"
mkdir -p "/etc/systemd/system/${FIXSERVICE}.d"
echo -e "[Service]\nTimeoutStartSec=10" > "/etc/systemd/system/${FIXSERVICE}.d/reduce-timeout.conf"

You can also use systemctl edit keyboard-setup.service and paste in the editor:

[Service]
TimeoutStartSec=10

Then save & quit the editor.

Solution 2

Ok, I've managed to decrease dramatically the keyboard-setup.service from 20 secs to 2 secs. sudo gedit /lib/systemd/system/keyboard-setup.service,

and adding the line:

TimeoutStartSec=10sec

after the last line of [Service] bit. Turns out my problem was that this service was going to timeout and this had not been defined.

Share:
7,842

Related videos on Youtube

Hector Muñoz H
Author by

Hector Muñoz H

Updated on September 18, 2022

Comments

  • Hector Muñoz H
    Hector Muñoz H over 1 year

    so I'm trying to improve my startup time now 41.772s (using UBUNTU 17.04/GNOME 3)

    I have solved some problems but I can't seem to find a solution to improve keyboard-setup.service

    systemd-analyze blame:

    20.671s dev-sda6.device
         20.294s keyboard-setup.service
         16.885s systemd-tmpfiles-setup-dev.service
         15.296s systemd-sysctl.service
         10.730s networking.service
          9.848s ntp.service
          6.699s NetworkManager-wait-online.service
          5.546s click-system-hooks.service
          5.229s ModemManager.service
          4.989s accounts-daemon.service
          4.741s NetworkManager.service
          4.343s grub-common.service
          3.740s iio-sensor-proxy.service
          2.926s repowerd.service
          2.102s systemd-modules-load.service
          2.043s colord.service
          1.847s fwupd.service
          1.770s upower.service
          1.529s switcheroo-control.service
          1.372s [email protected]
          1.357s polkit.service
          1.322s irqbalance.service
          1.167s systemd-rfkill.service
    

    systemd-analyze critical-chain:

    graphical.target @36.002s
     └─multi-user.target @36.002s
      └─systemd-resolved.service @34.741s +363ms
        └─network.target @34.733s
          └─wpa_supplicant.service @30.369s +679ms
        └─basic.target @24.005s
          └─sockets.target @24.004s
            └─snapd.socket @23.986s +16ms
              └─sysinit.target @23.928s
                └─apparmor.service @23.387s +538ms
                  └─local-fs.target @23.384s
                    └─run-user-128.mount @35.104s
                      └─local-fs-pre.target @23.384s
                        └─keyboard-setup.service @3.089s +20.294s
                          └─systemd-journald.socket @3.049s
                            └─-.slice @2.602s
    

    Any help? Can I disable it and make the service start after boot? or should I install another keyboard driver? My computer is a hp pavillion dv6 Intel i7, 8GB RAM

    Thanks!

    • Hector Muñoz H
      Hector Muñoz H almost 7 years
      Ok, I've managed to decrease dramatically the keyboard-setup.service from 20 secs to 2 secs. gedit /lib/systemd/system/keyboard-setup.service, and adding TimeoutStartSec=10sec at the bottom of [Service]. I am still battling with systemd-tmpfiles-setup-dev.service
    • pbhj
      pbhj over 5 years
      I used @Jeroen Vermeulen - MageHost 's method below (sudo systemctl edit ...) and in fact did it for systemd-tmpfiles-setup-dev.service too. Now, it reduced the keyboard-setup by 6s to 16s (still very high) and reduced the tmpfiles-setup from ~20s down to >1s. On Kubuntu 18.04, I have a USB keyboard, and USB isn't enabled in my "BIOS" (I made a mistake, have to reset it to enable); both/either of those might be pertinent.