KaliLinux 2018.2: Slow boot problem when using LVM

If you install KaliLinux 2018.2 with LVM, slow boot problem happens. This article will describe a way to avoid this problem. If you install KaliLinux 2018.2 without LVM, this problem does not happen.

1 Slow boot problem when using LVM

systemd-analyze shows that kernel boot time takes a lot of time.

$ systemd-analyze
Startup finished in 34.539s (kernel) + 2.871s (userspace) = 37.410s
graphical.target reached after 1.305s in userspace

The wait-for-root in /usr/share/initramfs-tools/scripts/local times out after expiring 30 seconds.

[    2.056198] random: lvm: uninitialized urandom read (2 bytes read)
done.
Begin: Running /scripts/local-premount ... Begin: Waiting for
suspend/resume device ... Begin: Running /scripts/local-block
... done.
Begin: Running /scripts/local-block ... done.
[    4.948882] random: fast init done
Begin: Running /scripts/local-block ... done.
<snip>
Begin: Running /scripts/local-block ... done.
done.
Gave up waiting for suspend/resume device
done.
[   34.841249] cryptd: max_cpu_qlen set to 1000

2 Avoid slow boot problem when using LVM

Assign device file path of LVM swap partition to RESUME. This is the same with /etc/initramfs-tools/conf.d/resume in Debian 9.

$ RESUME=$(sudo lvscan -q | awk '{ print $2 }' | \
           sed -e "s/^'//g" -e "s/'$//g" | grep '/swap_1$')
$ sudo sed -e 's/^RESUME=/#RESUME=/g' \
       -i /etc/initramfs-tools/conf.d/resume
$ echo "RESUME=${RESUME}" | sudo tee -a /etc/initramfs-tools/conf.d/resume

Recreate initrd and reboot system.

$ sudo update-initramfs -u
$ sudo reboot

Kernel boot time is faster and you can use hibernation.

$ systemd-analyze
Startup finished in 2.398s (kernel) + 1.255s (userspace) = 3.654s
graphical.target reached after 1.240s in userspace