How to speed up really slow boot on Ubuntu 16.04?

110,196

Solution 1

You can try to find out what is taking the most time with systemd

systemd-analyze blame

Solution 2

Editing /etc/fstab's UUID of the swap space (to match the output of sudo blkid) worked like a charm!

Note: After that, if there are any swap entries in /etc/crypttab file, you should change its second parameter to match with your swap space, either by UUID or path (i.e. UUID=something or /path/to/swap).

On my SSD the bootup went from 2 mins down to less than 10 seconds.

The thing is, I just did a normal upgrade from 14.04 to 16.04, no messing around with partitions, when this problem started. Clearly there is some issues with the upgrade procedure.

Solution 3

I ran into similar problem of longer boot time after upgrade.

What was the problem? I had deleted my swap space, so my /etc/fstab file and new file system had conflicts. The Boot loader waited for almost 1m 30s to find it.

How I solved the problem Run sudo blkid

Open your /etc/fstab file and compare the uuid's match with partitions you have. If there is mismatch change that and reboot.

Solution 4

It's a workaround solution but this reduced my boot time significantly (from 1 min 24s to 16s).

sudo vim /etc/systemd/system.conf

Uncomment these two parameters and set the desired timeout:

DefaultTimeoutStartSec=10s
DefaultTimeoutStopSec=10s

Note: Please optimize these values to match your hardware needs ~ 5 - 60s.

As discussed here these parameters configure the default timeouts for starting and stopping of units, as well as the default time to sleep between automatic restarts of units, as configured per-unit in TimeoutStartSec=, TimeoutStopSec= and RestartSec= (for services, see systemd.service(5) for details on the per-unit settings).

For non-service units, DefaultTimeoutStartSec= sets the default TimeoutSec= value. DefaultTimeoutStartSec= and DefaultTimeoutStopSec= default to 90s. DefaultRestartSec= defaults to 100ms.


Edit - More in detail:

I analyzed the boot sequence with systemd-analyze plot > sequence.svg that showed services failing to start on my freshly upgraded OS. There were three - one was a misconfigured sendmail daemon then powerd.service & NetworkManager-wait-online.service. Since it's not a good idea to disable the NetworkManager service entirely I just let it timeout after 10 secs and applied this rule globally.

Solution 5

This could be related to filesystem issues. You may want to check this link to see if repairing your filesystem improves boot time: https://help.ubuntu.com/community/FilesystemTroubleshooting

Share:
110,196

Related videos on Youtube

Packwood
Author by

Packwood

Updated on September 18, 2022

Comments

  • Packwood
    Packwood over 1 year

    I am trying to understand what I need to do to speed up my boot with Ubuntu 16.04. I have run dmesg and saved the output here. It all seems to go wrong after about 10 secs in.

    • NickT
      NickT about 8 years
      If you look at your dmesg, you may well find an entry such as 'new mount options do not match the existing superblock'. If so Google for that string and it will lead you to a Linux bug which has never been fixed
    • Packwood
      Packwood about 8 years
      I don't think I am seeing that error or similar.
    • Ciro Santilli OurBigBook.com
      Ciro Santilli OurBigBook.com almost 6 years
      Why do you feel things become bad at 10 secs in? Which message do you think is specially worrying?
  • Packwood
    Packwood about 8 years
    Hmm. now seems to be [longer!] (pastebin.com/a5g4wHvA) Looks like it goes wrong after around 30 secs. "eth0: link is not ready" "nf_conntrack: automatic helper assignment is deprecated and it will be removed soon. Use the iptables CT target to attach helpers instead"
  • Byte Commander
    Byte Commander almost 8 years
    The dmesg output in the question shows that OP has a different problem.
  • Emmanuel
    Emmanuel over 7 years
    Thank that helped me a lot : for test purpose I had put a swap on a removable caddy, no boot problem when the disk wasn't there on 14.04, on 16.04 boot took 1 or 2 minutes more . It seems that kernel 3 was faster than kernel 4 when not founding the swap.
  • mohammed amine bourkadi
    mohammed amine bourkadi over 7 years
    Yes so what after? do i have to stop some services from running?
  • Mirek
    Mirek over 7 years
    No probs, enjoy!
  • Woeitg
    Woeitg over 7 years
    it doesn't work for me as after applying the changes my boot time went from 52 to 57 seconds.
  • PaladiN
    PaladiN almost 7 years
    Thanks. you saved my alot of time. I was also upgrading the system from 14.04 so this issue occurred.
  • Brandon Culley
    Brandon Culley almost 7 years
    Thanks, I had the same issue with incorrect swap UUID, once I changed it to match blkid it took a long startup time of about 60 seconds to just 5 seconds
  • Dmitry
    Dmitry over 6 years
    Look in askubuntu.com/questions/38533/… answer for more info on how to do it. It reduced my boot time from 100+ seconds to 15.
  • Vasil Valchev
    Vasil Valchev over 6 years
    yea, upgrade to 17.10 but my swap uuid match whit the result from "blkid"
  • Anwar
    Anwar over 6 years
    10s is too low. It can make boot into recovery mode. I'm using 30s
  • Lym Zoy
    Lym Zoy about 6 years
    Thanks, I've changed swap partition before, and there's still info about that. Commenting it out works!
  • Luke Moll
    Luke Moll about 6 years
    I could kiss you right now, I don't have a swap partition but there was a swap line in fstab. Down from 2 minutes to 14 seconds :D
  • Kevin P.
    Kevin P. about 6 years
    This worked for me. Pretty safe to check. I had changed my partition so this seemed like it affected me and the boot time went from 1min+ to 5 seconds :)
  • Pasupathi
    Pasupathi almost 6 years
    10s broke my booting in 18.04. Now repairing Ubuntu in recovery mode.
  • Agung Prasetyo
    Agung Prasetyo almost 4 years
    thanks @Gokul, you save my time, exactly the problem was different UUID between swap and /. I got the problem because installing new ubuntu without swap.
  • Imran Faruqi
    Imran Faruqi almost 3 years
    I think you forgot the tell that we need to be root user before editing /etc/fstab to see the root level file. This fixed for me too.. I restored the backup from clonezilla. I think I need to figure out if I could also backup the swap partition.