Ubuntu: How to diagnose and fix a slow boot time

Updated: January 28, 2024 By: Guest Contributor Post a comment

Introduction

Nothing is as frustrating as a slow boot time when you want to get started with your work or tasks on Ubuntu. This guide aims to provide a step-by-step tutorial on how to diagnose and fix slow boot times on your Ubuntu machine.

Understanding Boot Process

Understanding the boot process is key before troubleshooting. When you power on your device, the BIOS/UEFI hands control to the bootloader, which then loads the Linux Kernel and initial RAM disk, leading to the launch of systemd, Ubuntu’s init system. Analyzing each step’s time consumption can usually indicate the bottleneck.

Basic Troubleshooting

We’ll start with the basic ways to diagnose a slow boot.

Use systemd-analyze

systemd-analyze time

Running the command above will give you a breakdown of your boot process. An example output could be:

Startup finished in 3.546s (kernel) + 2.244s (initrd) + 17.536s (userspace) = 23.327s

If ‘userspace’ is significantly high, that’s probably where the issues lie.

Diagnose with systemd-analyze blame

systemd-analyze blame

This command lists all services by the time they took to start. Look for any service that’s taking an unusually long time.

Intermediate Troubleshooting

Investigating further involves identifying and disabling non-critical services or optimizing those that are necessary.

Disabling Services

sudo systemctl disable .service

Replace with the name of the service you wish to disable. Be careful not to disable critical system services.

The blkid gives the UUIDs:

sudo blkid

You would then edit the fstab file:

sudo nano /etc/fstab

And replace the respective /dev/sdX parts with UUID=your-UUID-comes-here to make the boot process more reliable.

Advanced Troubleshooting

For some, the boot time issue may be kernel or driver related, complex to handle but still worth looking into.

Analyze Kernel Boot Parameters

cat /proc/cmdline

This displays current kernel boot parameters. Look for any unnecessary options or add new ones, like quiet to suppress unnecessary logs or profile to re-profile your system on boot that might be causing delays.

Edit the /etc/default/grub file to modifying these parameters:

sudo nano /etc/default/grub

Make sure to update-grub after changes:

sudo update-grub

Profiling with BootChart

BootChart is a tool for performance analysis and visualization of the Linux boot process. Installation instructions vary, and you might need to search for the most current way to install it on your version of Ubuntu. Once installed, BootChart will start tracking your next boot process.

Conclusion

A slow boot can be a nuance, but with systematic diagnosis and the above steps, most issues can be resolved. Remember to backup before you make changes and proceed only if you’re confident with potentially advanced system modifications.