Ubuntu Desktop 17.04 64-bit with encrypted home, slow boot

I reinstalled Ubuntu 17.04 Desktop 64-bit UEFI on my Laptop on a harddisk.

Laptop: Intel Core i5-5200U, Intel HD Graphics 5500, 16 GB Ram.

Booting takes ~120 seconds (from pressing the powerswitch to loginscreen, with Ubuntu 16.04.2 on a ssd it takes less than 20 seconds).

syslog

$ systemd-analyze blame
          5.187s dev-sdb2.device
          4.268s ModemManager.service
          3.138s accounts-daemon.service
          2.852s fwupd.service
          2.688s grub-common.service
          2.421s irqbalance.service
          2.367s apport.service
          2.360s gpu-manager.service
          2.269s NetworkManager.service
          1.641s thermald.service
          1.632s polkit.service
          1.567s rsyslog.service
          1.336s keyboard-setup.service
          1.241s lightdm.service
          1.240s plymouth-quit-wait.service
          1.231s speech-dispatcher.service
          1.172s udisks2.service
          1.159s apparmor.service
          1.019s alsa-restore.service
           976ms repowerd.service
           957ms upower.service
           900ms bluetooth.service
           821ms systemd-resolved.service
           792ms dev-hugepages.mount
           792ms dev-mqueue.mount
           789ms avahi-daemon.service
           755ms sys-kernel-debug.mount
           689ms [email protected]
           663ms systemd-modules-load.service
           638ms rtkit-daemon.service
           599ms systemd-backlight@backlight:intel_backlight.service
           540ms systemd-rfkill.service
           511ms systemd-udevd.service
           505ms systemd-fsck@dev-disk-by\x2duuid-F685\x2d7079.service
           456ms systemd-machine-id-commit.service
           455ms openvpn.service
           444ms systemd-timesyncd.service
           386ms systemd-user-sessions.service
           326ms systemd-journald.service
           321ms kmod-static-nodes.service
           273ms systemd-logind.service
           243ms colord.service
           239ms systemd-udev-trigger.service
           227ms wpa_supplicant.service
           199ms networking.service
           192ms console-setup.service
           191ms systemd-tmpfiles-setup-dev.service
           188ms pppd-dns.service
           184ms systemd-hostnamed.service
           171ms [email protected]
           170ms systemd-localed.service
           165ms setvtrgb.service
           162ms systemd-tmpfiles-setup.service
           131ms dns-clean.service
           101ms systemd-journal-flush.service
            92ms resolvconf.service
            91ms sys-fs-fuse-connections.mount
            82ms systemd-sysctl.service
            79ms systemd-remount-fs.service
            70ms systemd-random-seed.service
            51ms ufw.service
            44ms systemd-update-utmp.service
            42ms boot-efi.mount
            37ms snapd.socket
            14ms plymouth-start.service
            11ms plymouth-read-write.service
             6ms snapd.autoimport.service
             4ms ureadahead-stop.service
             4ms dev-mapper-cryptswap1.swap
             3ms systemd-update-utmp-runlevel.service
             1ms swapfile.swap

systemd-analyze plot

Any ideas?


Got it, it's a Ubiquity problem with encrypted home option: system hangs because of ecryptfs-setup-swap not working with swapfiles !

I set up Ubuntu with encrypted Home like i always do, with the fix as described in the link boot went from ~200 seconds down to ~30 seconds, this is on a hdd.


Edit: the problem is when installing Ubuntu with encrypted home, 17.04 creates a swapfile instead of a swap partition like previous versions, then the installer writes a faulty config file.

Quote, from the Original Bug Report:

In particular, ecryptfs-setup-swap puts in /etc/crypttab a line like this:

cryptswap1 UID=XXXXXXXX /dev/urandom
swap,offset=1024,cipher=aes-xts-plain64

(like there were a swap partition with UID=XXXXXXXX) while with a swapfile it should put the following line:

cryptswap1 /swapfile /dev/urandom
swap,offset=1024,cipher=aes-xts-plain64

If you manually change that line and reboot, you get rid of the problem - before rebooting, check also that your /etc/fstab file ends with:

#/swapfile none swap sw 0 0
/dev/mapper/cryptswap1 none swap sw 0 0

Because of this error Ubuntu spends a long time waiting for the swap.

fixed systemd-analyze blame

fixed systemd-analyze plot


Installing with LVM enabled also prevents this issue, (for Ubuntu MATE anyway) as it creates a swap partition.