Score:1

Lubuntu - Slow boot - Maybe swapfile or partition

us flag

I have noticed that my Lubuntu 20.04 boots slowly. So far, I have read some posts, and I can share you all this info I have collected:

# systemd-analyze blame
19.296s dev-sda5.device                                      
18.412s snapd.service                                        
17.480s networkd-dispatcher.service                          
16.627s accounts-daemon.service                              
15.142s udisks2.service                                      
12.115s dev-loop13.device                                    
11.692s NetworkManager-wait-online.service                   
11.054s dev-loop9.device                                     
11.010s bluetooth.service                                    
11.008s avahi-daemon.service                                 
10.916s dev-loop14.device                                    
10.872s dev-loop17.device                                    
10.831s dev-loop8.device                                     
10.798s dev-loop12.device                                    
10.755s dev-loop19.device                                    
10.734s NetworkManager.service                               
10.716s dundee.service                                       
10.665s dev-loop16.device                                    
10.638s dev-loop18.device                                    
10.604s dev-loop15.device                                    
10.604s dev-loop11.device                                    
 9.929s polkit.service                                       
 9.833s ofono.service                                                                                                                 
 9.176s switcheroo-control.service                                                                                                    
 9.158s thermald.service                                                                                                              
 9.155s systemd-logind.service                                                                                                        
 9.051s wpa_supplicant.service                                                                                                        
 8.573s dev-loop10.device                                                                                                             
 7.504s dev-loop6.device                                                                                                              
 7.450s dev-loop7.device                                                                                                              
 7.439s dev-loop2.device
...

Critical chain is:

# systemd-analyze critical-chain
graphical.target @50.502s
└─multi-user.target @50.502s
  └─kerneloops.service @50.294s +207ms
    └─network-online.target @50.270s
      └─NetworkManager-wait-online.service @38.577s +11.692s
        └─NetworkManager.service @27.837s +10.734s
          └─dbus.service @27.833s
            └─basic.target @27.480s
              └─sockets.target @27.478s
                └─snapd.socket @27.474s +3ms
                  └─sysinit.target @27.408s
                    └─snapd.apparmor.service @26.409s +998ms
                      └─apparmor.service @23.930s +2.464s
                        └─local-fs.target @23.929s
                          └─boot-efi.mount @23.880s +48ms
                            └─systemd-fsck@dev-disk-by\x2duuid-B86C\x2d1FC8.service @23.705s +155ms
                              └─dev-disk-by\x2duuid-B86C\x2d1FC8.device @23.704s

fstab:

    # sudo cat /etc/fstab
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sda5 during installation
    UUID=5376f975-326e-467b-b615-3c05494fc9c9 /               ext4    errors=remount-ro 0       1
    # /boot/efi was on /dev/sda1 during installation
    /swapfile                                 none            swap    sw              0       0
    UUID=B86C-1FC8 /boot/efi vfat umask=0077 0 1

And blkid shows:

sudo blkid
/dev/sda5: UUID="5376f975-326e-467b-b615-3c05494fc9c9" TYPE="ext4" PARTUUID="e2f7acbc-05"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/sda1: UUID="B86C-1FC8" TYPE="vfat" PARTUUID="e2f7acbc-01"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/loop15: TYPE="squashfs"
/dev/loop16: TYPE="squashfs"
/dev/loop17: TYPE="squashfs"
/dev/loop18: TYPE="squashfs"
/dev/loop19: TYPE="squashfs"

Also lsbkl outputs this:

#sudo lsbkl -f
# There is more info here, but I think it is not relevant at this point.
#...
sda                                                                       
├─sda1 vfat           B86C-1FC8                               511M     0% /boot/efi
├─sda2                                                                    
└─sda5 ext4           5376f975-326e-467b-b615-3c05494fc9c9  806,9G     7% /
sr0  

gnome-disks smart-data-1:

smart-data-1

gnome-disks smart-data-2:

smart-data-2

free command:

~$ free -h
total        used        free      shared  buff/cache   available
Mem:          5,7Gi       853Mi       409Mi       119Mi       4,4Gi       4,4Gi
Swap:         2,0Gi       1,0Mi       2,0Gi

Do you know what may be happening? I'm guessing that sda1 partition or swapfile may be responsible for this. If it is so, how may a fix it? Thanks in advance!

heynnema avatar
ru flag
How slow is slow, in seconds? Edit your question and show me `free -h` and `swapon -s` and `sysctl vm.swappiness`. Start comments to me with @heynnema or I'll miss them.
Adrian - avatar
us flag
@heynnema Boots in 45 to 50 seconds. ~$ free -h total used free shared buff/cache available Mem: 5,7Gi 743Mi 2,0Gi 93Mi 3,0Gi 4,6Gi Swap: 2,0Gi 0B 2,0Gi ~$ swapon -s Filename Type Size Used Priority /swapfile file 2097148 0 -2 ~$ sysctl vm.swappiness vm.swappiness = 60
heynnema avatar
ru flag
Always add data as an edit to your question, not as comments please. Edit your question and show me screenshot(s) of the `Disks` application SMART Data window (scrollable and may take 2 screenshots). Do you have HDD or SSD?
Adrian - avatar
us flag
Edited my question and added 1 screenshot. I can't find SMART data window. Hope that attached screenshot helps! Thanks @heynnema.
heynnema avatar
ru flag
No, go to the 3-dot menu and select SMART Data & Tests. Also, is there a reason for your disk having a MBR partition table, instead of GPT/GUID? This is HDD, yes?
Adrian - avatar
us flag
Done (edited question with screenshots)! Yes it is HDD. Nop, there is no reason now. This machine came with Windows OS. Of course the first thing I did was to install Ubuntu :P But that was years ago. Did I made some mistakes with partitions? Thanks @heynnema!
heynnema avatar
ru flag
Thanks for the screenshots. You have read/write errors and excessive load/unload errors. How old is this drive? Do you hear any clicking noises from the drive? Is this an internal SATA drive, or something else?
Adrian - avatar
us flag
Thanks for your response @heynnema! Do you think this errors make Lubuntu boot slow? This computer (and it's drive) are from august 2014. Drive is internal. I don't know if it is SATA, but I suppose it is.
heynnema avatar
ru flag
Edit your question and show me `free -h`, and I may modify my answer slightly.
Adrian - avatar
us flag
I just edit it @heynnema adding output of free comand. I will check your answer now, and if you edit it I will check again later. Thanks for your help!
Adrian - avatar
us flag
@heynnema I put a comment in your answer. But I could not put your name with @ on that comment. That's why I'm writing this.
Adrian - avatar
us flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/126362/discussion-between-adrian-and-heynnema).
guiverc avatar
cn flag
I personally don't find LXQt the fastest desktop to get started (it is however one of the fastest once running) but your use of `gnome-disks` (a GTK3 program) on a Qt5 desktop implies you're not aware of the toolkits/libraries apps use, and are thus potentially slowing your system down through application choice (ie. causing multiple libs to be loaded into memory that do exactly the same thing, wasting resources (esp. ram) & slowing load time yourself). Those issues won't show in what you provided (except your photo). You may decide the slower boot is worth it; I too use some GTK3 apps.
Adrian - avatar
us flag
@guiverc based on data I provided on my question, I believe there should be a partition or a swapfile problem. Mix of different desktops and or apps may slow down as you said, but this doesn`t seem to be the case. If you have some hints that doesn`t contradict shared info, I will be pleased to read it. Thanks in advance.
Score:1
ru flag

Your HDD has read/write errors and excessive load/unload errors. The drive may just be old, and pre-failing.

HDD's are much slower than SSD's, and tend to boot much slower. Expect boot times of approximately 30-90 seconds.

CABLES

Re-seat the data and power cables on the rear of the HDD, and the motherboard.

PARTITION TABLE

Your disk should probably be in GPT format... although with a 2014 computer that may be BIOS, not UEFI... that may not be possible.

SWAP

A 2G /swapfile is a little smallish, and we'll increase it to 4G...

Note: Incorrect use of the rm and dd commands can cause data loss. Suggest copy/paste.

In the terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 6G RAM and 4G swap

Edit /etc/fstab, using sudo -H gedit /etc/fstab or sudo pico /etc/fstab.

Confirm this /swapfile line in /etc/fstab... and confirm no other “swap” lines... use SPACES in this line... confirm NO TABS...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation

BAD BLOCKS

Let's check your disk for any bad blocks...

Note: do NOT abort a bad block scan!

Note: do NOT bad block a SSD

Note: backup your important files FIRST!

Note: this will take many hours

Note: you may have a pending HDD failure

Boot to a Ubuntu Live DVD/USB in “Try Ubuntu” mode.

In terminal...

sudo fdisk -l # identify all "Linux Filesystem" partitions

sudo e2fsck -fcky /dev/sdXX # read-only test

or

sudo e2fsck -fccky /dev/sda5 # non-destructive read/write test (recommended)

The -k is important, because it saves the previous bad block table, and adds any new bad blocks to that table. Without -k, you loose all of the prior bad block information.

The -fccky parameter...

   -f    Force checking even if the file system seems clean.

   -c    This option causes e2fsck to use badblocks(8) program to do
         a read-only scan of the device in order to find any bad blocks.
         If any bad blocks are found, they are added to the bad block
         inode to prevent them from being allocated to a file or direc‐
         tory.  If this option is specified twice, then the bad block scan
         will be done using a non-destructive read-write test.

   -k    When combined with the -c option, any existing bad blocks in the
         bad blocks list are preserved, and any new bad blocks found by
         running badblocks(8) will be added to the existing bad blocks
         list.

   -y    Assume an answer of `yes' to all questions; allows e2fsck to be
         used non-interactively. This option may not be specified at the
         same time as the -n or -p options.
Adrian - avatar
us flag
I'm sorry, but I have a question about this: "Confirm this /swapfile line in /etc/fstab... and confirm no other “swap” lines... use SPACES in this line... confirm NO TABS...". I already have a /swapfile there. Should I make any edit on existing line after resizing it to 6GB?
heynnema avatar
ru flag
@Adrian- You can skip that part. It was mostly intended for users that didn't already have a /swapfile. And `free -h` should show a 4G /swapfile (not 6G).
Adrian - avatar
us flag
no noticeable changes after resizing to a 4G /swapfile. I still think that this happens for some reason about /boot/efi mount (sda1 partition).
heynnema avatar
ru flag
@Adrian- Have you checked cables, and run the bad block procedure yet?
Adrian - avatar
us flag
Can`t check cables right now. I`m running bad blocks procedure. It will last at least 10 hours. So far, nearly 4 hours, zero bad blocks.
heynnema avatar
ru flag
@Adrian- Status please...
Adrian - avatar
us flag
no changes after disk check. But, I disabled NetworkManager-wait-online.service, and now time is about 47 seconds to boot.
heynnema avatar
ru flag
@Adrian- That's not too bad. Do you connect via wireless or ethernet?
Adrian - avatar
us flag
I connect via Wireless. Maybe the other thing I can do is something with snapd service. I know I should not disable it, but somehow try to get it ran faster. Thank you for your help! I will mark your answer as the one that resolved my issue.
heynnema avatar
ru flag
@Adrian- From `sudo blkid` we can see that you have 20 snap apps installed. You can `snap remove` ones that you don't need, but don't delete snaps that were put there by Ubuntu. Note that with a 2014 computer with a HDD, you won't really be able to speed up boots much.
Adrian - avatar
us flag
I will. Thank you for your help!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.