Slow boot, long kernel load time, due to wrong resume device
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.
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
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.
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).So I went to edit /etc/fstab file by typing
sudo gedit /etc/fstab
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