64

For some time, my boot process is taking too long (almost 1 min.).

systemd-analyze time 

shows that kernel is taking 35.765s

Looking at dmesg, it seems that the problem is with mounting file systems:

...
[    2.186084]  sdb: sdb1 sdb9
[    2.186919] sd 2:0:0:0: [sdb] supports TCG Opal
[    2.186922] sd 2:0:0:0: [sdb] Attached SCSI disk
[    2.499795] ata5: SATA link down (SStatus 0 SControl 300)
[    2.844320] clocksource: Switched to clocksource tsc
[   35.670493] EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)
[   35.782128] ip_tables: (C) 2000-2006 Netfilter Core Team
[   35.803610] systemd[1]: systemd 237 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
...

My /etc/fstab looks like this:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=3996-2381  /boot/efi       vfat    umask=0077      0       1
#/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0

How can I troubleshoot this ?

EDIT: looking closely at the boot messages (after removing the quiet option in grub), I spotted this suspicious line:

gave up waiting for suspend/resume device

I think my swap is encrypted, and I also think the UUID in /etc/initramfs/conf.d/resume does not correspond to any device.

Should I disable resume/suspend? and how to do that?

2
  • 7
    The problem is actually at ``` Begin: Running /scripts/local-premount ``` It is displayed during the boot (if you disable quiet). Due to some reason this premount script is taking a 30 seconds or so.
    – Sudhanshu
    Mar 11, 2018 at 11:27
  • 2
    This question/answer is valuable because it helps solve a bug in Lubuntu Bionic, so please help reopen it :-)
    – sudodus
    Apr 20, 2018 at 14:37

5 Answers 5

95

Ok, I found the solution, thanks to Sudhanshu's comment.

The problem was due to my swap being encrypted. So the local-premount script in initramfs was waiting for a swap device that was not available, until it timed out. The relevant message was gave up waiting for suspend/resume device.

To disable this (as resuming from swap is not possible with an encrypted swap, and I don't use hibernation anyway), I modified this file: /etc/initramfs-tools/conf.d/resume.

In this file, a line with

RESUME=none

(instead of the UUID that was here) will disable waiting for a resume device.

Run

sudo update-initramfs -u

to apply the changes.

System now boots normally.

6
  • 2
    I think you are affected by Bug #1763611, Lubuntu bionic boots slower than the other Ubuntu flavours with some SSDs. And you have shown how to squash the bug :-)
    – sudodus
    Apr 20, 2018 at 13:24
  • 5
    Brilliant! Thanks for the fix. It had me pulling my hair out!
    – user636763
    May 24, 2018 at 23:58
  • 1
    Had the problem since a long time caused by zram (no swap partition). I just fixed it, thanks ! May 8, 2019 at 20:30
  • 1
    Thanks it worked!
    – Malakai
    May 18, 2020 at 19:54
  • Weird thing, commenting the line out wasn't fixing it. I wonder how you found out what you had to put there. Thanx, damn thing was driving me nuts :-D
    – DimiDak
    May 12, 2021 at 22:22
7

I also saw this in Linux Mint (based on Ubuntu), and spent some time working out what was going wrong.

This happens if your system is installed on LVM and is using an LVM volume as the swap disk.

There is a long-standing, recurring bug where the resume file incorrectly has a UUID (which is invalid for LVM) instead of the device path that it should have. See https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/1768230

You can fix it by editing the /etc/initramfs-tools/conf.d/resume file and replacing the UUID with the device path of the swap drive. The following command snippet will do this for you, using the first swap drive found and reported by blkid:

sudo bash -c 'mv /etc/initramfs-tools/conf.d/resume /tmp/resume.bak; echo RESUME=$(blkid | \grep -i swap | head -n 1 | cut -d : -f 1) > /etc/initramfs-tools/conf.d/resume'

The fixed resume file should look something like this: RESUME=/dev/mapper/mint--vg-swap_1

4
  • 1
    This script won't work for everyone (like me). Please include what the actual resume file contents will look like afterwards. Feb 20, 2020 at 1:12
  • 2
    The resume file should look something like this: RESUME=/dev/mapper/mint--vg-swap_1 Feb 22, 2020 at 14:41
  • Thank you, +1 👍 Feb 22, 2020 at 22:41
  • I think there is a typo: grep -iinstead of grep -I the correct line likely to be: sudo bash -c 'mv /etc/initramfs-tools/conf.d/resume /tmp/resume.bak; echo RESUME=$(blkid | \grep -i swap | head -n 1 | cut -d : -f 1) > /etc/initramfs-tools/conf.d/resume'
    – kFly
    Jul 19, 2020 at 11:07
3

None of those solutions above or elsewhere worked out for me but I have found a solution which reduces my boot time to 40 seconds from 2 minutes and 10 seconds.

I used to create and remove swap partitions and somehow these logs stayed in etc/fstab file. So my system was trying to mount those previously created swap partitions which no longer exists. So please let me explain what I did step by step.

  1. I ran this command sudo blkid | grep swap to find out my swap partitions. There was two but one does not actually exist (it does not refer to any of my partitions).

  2. So I went to edit /etc/fstab file by typing sudo gedit /etc/fstab

  3. Then I realized there are so many swap files which I had deleted but somehow resumed existing in this file. So I referred to step 1 and deleted partitions which no longer exist.

Please see two before & after /etc/fstab file screenshots. After this cleanout everything's working as normal.

This is unedited /etc/fstab file unedited /etc/fstab

and here after wiping out non-existing swap partitions clean /etc/fstab

2
  • This worked for me. Thanks. Sep 22, 2019 at 9:47
  • This worked for me, all I had to do open fstab to see the line that referred to a swap file on a partition that had been deleted and whose reference I'd also deleted in grub. I'd recommend doing that first - check fstab and look for references to swap file you know don't exist.
    – VanAlbert
    Oct 4, 2020 at 18:36
3

I got this problem after installing 2 different linux distros. Somehow, on one distro, the swap partition got another UUID assigned to it then expected. My solution was to: First, run sudo blkid to get the right UUID for the swap partition. Copy the UUID of the swap. Paste it in /etc/initramfs-tools/conf.d/resume so you get RESUME=_the_correct_UUID_. Now run sudo update-initramfs -u to apply this change.

Next, check /etc/fstab, and change the UUID of the swap partition there also if necessary. (I had to)

1
  • This helped me. Thanks. Sep 22, 2019 at 10:04
0

In my case, adding configuration files in /etc/initramfs-tools/conf.d/ (with RESUME=none etc.) as said in the other answers didn't work for me. Ubuntu continues to report at boot time:

gave up waiting for suspend/resume device

The solution that worked for me is to change grub configuration at /etc/default/grub and change the line from something like the following:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=7f6bbc71-07d2-46db-946c-03e47368706c"

to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash noresume"

then run:

sudo update-grub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .