Ubuntu 16.04.3 "still" takes 1.5 minutes to boot after successful clone to SSD and with noatime and trim and AHCI boot?

Appreciate any help. Very slow boot on Ubuntu 16.04.3 with SSD still. when I run

    systemd-analyze blame

I get

    40.044s snapd.refresh.service
     29.529s apt-daily.service
      6.510s NetworkManager-wait-online.service
      2.469s apt-daily-upgrade.service
      1.814s snapd.service
      1.649s [email protected]
       936ms dev-sda2.device
       168ms ufw.service
       131ms ModemManager.service
       126ms lightdm.service
        86ms swapfile.swap
        83ms apport.service
        81ms systemd-fsck@dev-disk-by\x2duuid-BE45\x2d57DB.service
        78ms dev-loop0.device
        77ms speech-dispatcher.service
        71ms snap-core-2844.mount
        69ms alsa-restore.service
        69ms lm-sensors.service
        65ms pppd-dns.service
        64ms apparmor.service
        64ms rsyslog.service
        63ms accounts-daemon.service
        63ms systemd-user-sessions.service

when I run

    snap list

I get

    Name                        Version        Rev   Developer       Notes
    core                        16-2.27.6      2898  canonical       core
    keepassxc                   2.2.0          23    keepassxreboot  -
    ufw                         0.36pre-16.10  14    canonical       -
    ultimate-media-downloader2  1              1     keshavnrj       -

I am not familiar with snap or what to do. Can I disable or edit

     40.044s snapd.refresh.service
     29.529s apt-daily.service
      6.510s NetworkManager-wait-online.service

to make my boot faster? Appreciate any help beacuse my boot feels very slow. {But after the slow boot is completed the ssd does feel snappier inside Ubuntu,and I already am on AHCI boot mode in BIOS}. Please help. Appreciate any guidance.

Update 1:

Boot still takes over 1.5 minutes. I tried all this and still no change and boot very slow. I did

    sudo systemctl disable snapd.refresh.service
    sudo systemctl disable NetworkManager-wait-online.service
    

Run sudoedit /etc/rc.local and added this before line with exit 0 :

    rfkill block bluetooth

and I have tried this also

    sudo systemctl edit apt-daily.timer 

and pasted the following text into the editor window:

   # apt-daily timer configuration override
   [Timer]
   OnBootSec=15min
   OnUnitActiveSec=1d
   AccuracySec=1h
   RandomizedDelaySec=30min

But my boot is still very slow takes over 1.5 minutes. Now when I run systemd-analyze blame I get

     1.503s snapd.service
      1.246s [email protected]
       989ms virtualbox.service
       872ms dev-sda2.device
       674ms systemd-rfkill.service
       455ms dev-loop3.device
       149ms snap-core-2844.mount
       126ms lightdm.service
       119ms snap-core-2898.mount
       107ms accounts-daemon.service
       102ms apparmor.service
       100ms snap-core-2774.mount
        98ms ufw.service
        97ms ModemManager.service
        92ms snap-ufw-14.mount
        86ms systemd-fsck@dev-disk-by\x2duuid-BE45\x2d57DB.service
        86ms grub-common.service
        85ms swapfile.swap
        68ms plymouth-quit-wait.service
        59ms console-setup.service
        56ms preload.service
        54ms irqbalance.service
        52ms apport.service

But when I run systemd-analyze I get Startup finished in 5.179s (firmware) + 2.884s (loader) + 8.072s (kernel) + 3min 504ms (userspace) = 3min 16.641s

Boot is still very slow. Says my (userspace) takes 3mins? 3min 504ms (userspace) = 3min 16.641s Any advice please? (I am on SSD with noatime,trim and AHCI all already set).

Update 2:

When I run cat /var/log/syslog it goes crazy too fast I can't copy it but it is repeating same thing. So I run less /var/log/syslog I get

    Sep 25 07:30:04 jon kernel: [  473.457872] pcieport 0000:00:1c.2:   device [8086:a112] error status/mask=00000001/00002000
    Sep 25 07:30:04 jon kernel: [  473.457873] pcieport 0000:00:1c.2:    [ 0] Receiver Error         (First)
    Sep 25 07:30:04 jon kernel: [  473.457876] pcieport 0000:00:1c.2: AER: Corrected error received: id=00e2
    Sep 25 07:30:04 jon kernel: [  473.458511] pcieport 0000:00:1c.2: can't find device of ID00e2
    Sep 25 07:30:04 jon kernel: [  473.458574] pcieport 0000:00:1c.2: AER: Corrected error received: id=00e2
    Sep 25 07:30:04 jon kernel: [  473.458577] pcieport 0000:00:1c.2: PCIe Bus Error: severity=Corrected, type=Physical Layer, id=00e2(Receiver ID)
    Sep 25 07:30:04 jon kernel: [  473.458579] pcieport 0000:00:1c.2:   device [8086:a112] error status/mask=00000001/00002000Sep 25 07:30:04 jon kernel: [  473.458580] pcieport 0000:00:1c.2:    [ 0] Receiver Error         (First)
    Sep 25 07:30:04 jon kernel: [  473.460512] pcieport 0000:00:1c.2: AER: Corrected error received: id=00e2
    Sep 25 07:30:04 jon kernel: [  473.460515] pcieport 0000:00:1c.2: PCIe Bus Error: severity=Corrected, type=Physical Layer, id=00e2(Receiver ID)
    Sep 25 07:30:04 jon kernel: [  473.460518] pcieport 0000:00:1c.2:   device [8086:a112] error status/mask=00000001/00002000

(Additional information: Before I realized my logs (with thousands of pcie Bus error logs) were taking over 100Gb (!) space of my 250Gb SSD. Now I used logrotate and limited logs to 100M and set logrotate to run daily and my disk usage has gone from 180Gb to 80Gb.)

I know the pcie Bus error is a know bug. So is that what is delaying my boot? Appreciate advice.

Update 3

When I run lspci I get

    00:00.0 Host bridge: Intel Corporation Device 5910 (rev 05)
    00:01.0 PCI bridge: Intel Corporation Sky Lake PCIe Controller (x16) (rev 05)
    00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04)
   00:04.0 Signal processing controller: Intel Corporation Skylake Processor Thermal Subsystem (rev 05)
   00:14.0 USB controller: Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller (rev 31)
   00:14.2 Signal processing controller: Intel Corporation Sunrise Point-H Thermal subsystem (rev 31)
   00:15.0 Signal processing controller: Intel Corporation Sunrise Point-H LPSS I2C Controller #0 (rev 31)
  00:15.1 Signal processing controller: Intel Corporation Sunrise Point-H LPSS I2C Controller #1 (rev 31)
  00:16.0 Communication controller: Intel Corporation Sunrise Point-H CSME HECI #1 (rev 31)
  00:17.0 SATA controller: Intel Corporation Sunrise Point-H SATA Controller [AHCI mode] (rev 31)
  00:1c.0 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #1 (rev f1)
  00:1c.2 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #3 (rev f1)
  00:1c.3 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #4 (rev f1)
  00:1f.0 ISA bridge: Intel Corporation Sunrise Point-H LPC Controller (rev 31)
  00:1f.2 Memory controller: Intel Corporation Sunrise Point-H PMC (rev 31)
  00:1f.3 Audio device: Intel Corporation Device a171 (rev 31)
  00:1f.4 SMBus: Intel Corporation Sunrise Point-H SMBus (rev 31)
  01:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 950M] (rev a2)
  03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8723BE PCIe Wireless Network Adapter
  04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5287 (rev 01)
  04:00.1 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 12)

Update 4

I happened to try the workaround from AER: Corrected error received PCIe Bus Error

"Current workaround is to add pci=noaer to your kernel command line:

  1. edit /etc/default/grub and and add pci=noaer to the line starting with GRUB_CMDLINE_LINUX_DEFAULT. It will look like this: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=noaer"
  2. run sudo update-grub
  3. reboot"

That worked in stopping the syslog from being flooded and spammed with the pcieport 0000:00:1c.2: AER: Corrected error received: id=00e2 messages.

Thats great. I don't see those error messages on boot anymore either.

But my boot start-up time is still 90 seconds.

When I now run systemd-analyze I get

Startup finished in 6.232s (firmware) + 3.306s (loader) + 8.247s (kernel) + 3min 551ms (userspace) = 3min 18.337s still.

I am on Asus laptop model X550V i7-7700HQ Skylake cpu (with Geforce GTX Nividia 950M on Samsung 850 Evo 250Gb SSD) on Kernel 4.13.3-041303-generic. I had the same problem on 4.10.0-35 kernel so thats why I switched to 4.13 kernel to see if there was any improvement, but it is same issue still slow boot.

Do I still need to add pci=nomsi to Grub also as suggested in comments below, if I don't have the pcie buss error messages anymore?

Will that help my still slow boot time?

`


Solution 1:

I went through a similar (although not as drastic) experience.

From the terminal you need to use:

sudo systemctl disable snapd.refresh.service
sudo systemctl disable NetworkManager-wait-online.service

If you aren't using snapd disabling it isn't a problem. As per my own experience disabling NetworkManager-wait-online-service during boot isn't a problem.

As far as apt-daily.service goes it's a known bug. It wasn't designed to be run during boot but fifteen minutes into your session. There are a couple of different answers to that problem but as I've never encountered it cannot say which is better. (I would go with the one with the most upvotes though).

Although SSD boot took my time from 45 seconds to 11 seconds, I'm sorry you bought one thinking it would solve this particular problem. You'll still enjoy it though because applications will load in a few seconds instead of 15 seconds.

Solution 2:

[SOLVED]

After trying all of the above and thus fixing the PCIe Bus Error and AER Corrected error recieved messages that were flooding my syslog , and after using`

sudo systemctl disable snapd.refresh.service
sudo systemctl disable NetworkManager-wait-online.service

as suggested above to remove more boot time, my boot was still 80 or so seconds.

Then I noticed when I ran less /var/log/syslog this error also in my syslog

    systemd[1]: Dependency failed for Cryptography Setup for cryptswap1.
    systemd[1]: Dependency failed for dev-mapper-cryptswap1.device.

Seems my boot was also looking for cryptswap which I replaced with a swapfile a while ago. I missed that error thanks to the PCIe Bus Error and AER error messages that were flooding my syslog and that was taking up almost 100Gb of my disk space (!)

The final solution here on removing cryptswap and How to disable Crytswap following this explanation.

Seems I had already commented out the cryptswap1 line in fstab which was not in use, but had not yet commented out the line in /etc/crypttab .so I did as follows;

    sudo cryptsetup remove /dev/mapper/cryptswap1
    sudo vim /etc/crypttab
    *comment out the `cryptswap1 UUID= .... ` line*

now my boot is 10-15 seconds! Appreciate all the help.