Optimizing Boot Time - Analyzing systemd-analyze blame Results

Hey Guys,

I am trying to improve / optimize my boot time and needed some help analyzing the systemd-analyze blame results. Just for some background, I have a 2016 Dell XPS 13 (9350) with an i5 Skylake Processor and 8GB of ram. The output is below:

Startup finished in 14.208s (firmware) + 4.747s (loader) + 1.115s (kernel) + 1min 40.103s (userspace) = 2min 174ms 
graphical.target reached after 1min 39.842s in userspace

systemd-analyze Blame Results:

1min 30.110s nmb.service                                                                              
     42.977s fstrim.service                                                                           
     35.475s updatedb.service                                                                         
      5.335s NetworkManager-wait-online.service                                                       
      1.629s systemd-timesyncd.service                                                                
      1.479s lvm2-monitor.service                                                                     
      1.331s dev-nvme0n1p5.device                                                                     
      1.165s apparmor.service                                                                         
      1.083s systemd-backlight@backlight:intel_backlight.service                                      
      1.041s systemd-random-seed.service                                                              
       834ms systemd-logind.service                                                                   
       661ms systemd-udevd.service                                                                    
       639ms ufw.service                                                                              
       610ms systemd-journald.service                                                                 
       520ms snapd.service                                                                            
       415ms upower.service                                                                           
       402ms systemd-fsck@dev-disk-by\x2duuid-26de23b6\x2daf2b\x2d4302\x2dac31\x2df6eb9caea968.service
       381ms boot-efi.mount                                                                           
       366ms pamac-cleancache.service                                                                 
       258ms tlp.service                                                                              
       233ms systemd-rfkill.service                                                                   
       178ms polkit.service                                                                           
       174ms systemd-journal-flush.service                                                            
       154ms systemd-udev-trigger.service                                                             
       144ms user@1000.service                                                                        
       142ms org.cups.cupsd.service                                                                   
       106ms smb.service                                                                              
       100ms NetworkManager.service                                                                   
       100ms udisks2.service                                                                          
        99ms avahi-daemon.service                                                                     
        90ms modprobe@drm.service                                                                     
        72ms systemd-tmpfiles-setup.service                                                           
        68ms ModemManager.service                                                                     
        52ms systemd-fsck@dev-disk-by\x2duuid-38B4\x2dDDC3.service                                    
        50ms systemd-modules-load.service                                                             
        50ms systemd-tmpfiles-setup-dev.service                                                       
        40ms wpa_supplicant.service                                                                   
        34ms systemd-tmpfiles-clean.service                                                           
        30ms sys-kernel-config.mount                                                                  
        29ms snapd.apparmor.service                                                                   
        29ms systemd-sysctl.service

I’m not sure where to start, as I am a Linux newbie. Any help or assistance anyone could provide would be greatly appreciated.

Thank you!

nmb.service certainly seems to be the major culprit in slowing down the boot process. I don’t know whether you need that or not, but it’s for connecting your machine to a Windows network.

If you don’t need that, then you can disable and/or mask it, and then I would also advise disabling NetworkManager-wait-online.service, which is also known to slow down the boot process, and in this case, possibly related to nmb.service.

The other two below that are tasks that are periodically run ─ respectively, trimming the unused blocks of your SSD and updating the database of files on your system ─ but that could not be run when they were scheduled because the system was shut down, and so they are then run upon the next boot instead.

fsrim.service is normally run once a week, by fstrim.timer, and updatedb.service is normally run every 24 hours, by updatedb.timer. Both usually run at midnight.

2 Likes

Thanks for the awesome reply @Aragorn! I did a reboot and ran it again just to see if the updatedb.* services would disappear. The output is below:

[aahmad@aahmad-pc ~]$ systemd-analyze
Startup finished in 7.999s (firmware) + 4.743s (loader) + 1.031s (kernel) + 20.037s (userspace) = 33.812s 
graphical.target reached after 19.779s in userspace
[aahmad@aahmad-pc ~]$ systemd-analyze blame 
10.118s nmb.service                                                                              
 5.554s NetworkManager-wait-online.service                                                       
 1.502s lvm2-monitor.service                                                                     
 1.430s dev-nvme0n1p5.device                                                                     
 1.368s systemd-timesyncd.service                                                                
 1.282s apparmor.service                                                                         
  940ms systemd-random-seed.service                                                              
  775ms systemd-logind.service                                                                   
  717ms systemd-udevd.service                                                                    
  658ms systemd-journald.service                                                                 
  453ms boot-efi.mount                                                                           
  421ms snapd.service                                                                            
  408ms upower.service                                                                           
  391ms systemd-hostnamed.service                                                                
  350ms ufw.service                                                                              
  256ms tlp.service                                                                              
  201ms polkit.service                                                                           
10.118s nmb.service                                                                              
 5.554s NetworkManager-wait-online.service                                                       
 1.502s lvm2-monitor.service                                                                     
 1.430s dev-nvme0n1p5.device                                                                     
 1.368s systemd-timesyncd.service                                                                
 1.282s apparmor.service                                                                         
  940ms systemd-random-seed.service                                                              
  775ms systemd-logind.service                                                                   
  717ms systemd-udevd.service                                                                    
  658ms systemd-journald.service                                                                 
  453ms boot-efi.mount                                                                           
  421ms snapd.service                                                                            
  408ms upower.service                                                                           
  391ms systemd-hostnamed.service                                                                
  350ms ufw.service                                                                              
  256ms tlp.service                                                                              
  201ms polkit.service                                                                           
  180ms org.cups.cupsd.service                                                                   
  177ms systemd-journal-flush.service                                                            
  153ms avahi-daemon.service                                                                     
  152ms NetworkManager.service                                                                   
  142ms systemd-udev-trigger.service                                                             
  138ms bluetooth.service                                                                        
  123ms user@1000.service                                                                        
  102ms smb.service                                                                              
   86ms systemd-fsck@dev-disk-by\x2duuid-26de23b6\x2daf2b\x2d4302\x2dac31\x2df6eb9caea968.service
   79ms udisks2.service                                                                          
   65ms modprobe@drm.service                                                                     
   62ms ModemManager.service                                                                     
   56ms systemd-fsck@dev-disk-by\x2duuid-38B4\x2dDDC3.service                                    
   39ms linux-module-cleanup.service                                                             
   38ms systemd-backlight@backlight:intel_backlight.service                                      
   37ms systemd-update-utmp.service                                                              
   36ms systemd-backlight@leds:dell::kbd_backlight.service                                       
   36ms systemd-sysctl.service                                                                   
   31ms systemd-tmpfiles-setup-dev.service                                                       
   29ms systemd-modules-load.service                                                             
   28ms snapd.apparmor.service                                                                   
   27ms systemd-tmpfiles-setup.service                                                           
   27ms dev-disk-by\x2duuid-fc440987\x2d1c94\x2d45a3\x2d9c45\x2dfcc91942087e.swap                
   26ms colord.service                                                                           
   20ms home.mount                                                                               
   19ms systemd-remount-fs.service                                                               
   18ms wpa_supplicant.service                                                                   
   18ms dev-hugepages.mount                                                                      
   17ms systemd-rfkill.service                                                                   
   17ms dev-mqueue.mount                                                                         
   16ms sys-kernel-debug.mount                                                                   
   15ms sys-kernel-tracing.mount                                                                 
   14ms NetworkManager-dispatcher.service                                                        
   13ms systemd-user-sessions.service                                                            
   12ms kmod-static-nodes.service                                                                
   10ms rtkit-daemon.service                                                                     
   10ms user-runtime-dir@1000.service                                                            
    6ms tmp.mount                                                                                
    4ms snapd.socket                                                                             
    4ms sys-kernel-config.mount                                                                  
    3ms sys-fs-fuse-connections.mount                                                            

In addition, if you have any details (or can point me to any documentation) on how to disable the nmb.service, I can go ahead and take care of that one. I do NOT need to connect to a Windows network at all under my Manjaro installation.

Thanks again for your time and help, it is SUPER appreciated!

Well, it is curious as to why you had that enabled on your system in the first place. Maybe you installed a package that needed it? :thinking:

Anyway, disabling it is as easy as… :arrow_down:

sudo systemctl disable --now nmb.service && sudo systemctl mask nmb.service

Note that this can always be undone again later, if so required. :wink:

It looks like it didn’t like the mask command:

[aahmad@aahmad-pc ~]$ sudo systemctl disable --now nmb.service && sudo mask nmb.service
[sudo] password for aahmad: 
Removed /etc/systemd/system/multi-user.target.wants/nmb.service.
sudo: mask: command not found

Is disabling the nmb.service only enough? Or is there another issue that is being called out here?

TIA.

1 Like

It was a typographical error on my part ─ sorry, I’m fighting Covid-19 again at the moment ─ and I’ve corrected it in my previous post.

You’ve already disabled it now, so now all you still need to do is mask it, like so… :arrow_down:

sudo systemctl mask nmb.service

You could eventually do the same with NetworkManager-wait-online.service. I have that masked on my system here as well, but this is a desktop, connecting to the internet via a UTP cable. If you need wireless networking, then maybe you need to keep that one active. :thinking:

Thanks for the update @Aragorn! I went ahead and disabled the NetworkManager-wait-online.service as well. I do have a laptop, so I guess if there are issues, I’ll go back and enable the service if needed.

After disabling both nmb.service and NetworkManager-wait-online.service and doing a fresh reboot, this is the current output:

[aahmad@aahmad-pc ~]$ systemd-analyze
Startup finished in 8.089s (firmware) + 1.862s (loader) + 1.031s (kernel) + 4.978s (userspace) = 15.962s 
graphical.target reached after 4.706s in userspace
[aahmad@aahmad-pc ~]$ systemd-analyze blame 
1.416s lvm2-monitor.service                                                                     
1.405s systemd-timesyncd.service                                                                
1.362s systemd-rfkill.service                                                                   
1.278s dev-nvme0n1p5.device                                                                     
1.043s systemd-random-seed.service                                                              
 966ms systemd-backlight@backlight:intel_backlight.service                                      
 830ms systemd-logind.service                                                                   
 752ms systemd-journald.service                                                                 
 738ms apparmor.service                                                                         
 728ms systemd-udevd.service                                                                    
 525ms snapd.service                                                                            
 381ms upower.service                                                                           
 368ms systemd-fsck@dev-disk-by\x2duuid-26de23b6\x2daf2b\x2d4302\x2dac31\x2df6eb9caea968.service
 362ms org.cups.cupsd.service                                                                   
 351ms systemd-fsck@dev-disk-by\x2duuid-38B4\x2dDDC3.service                                    
 351ms ufw.service                                                                              
 278ms smb.service                                                                              
 267ms tlp.service                                                                              
 266ms boot-efi.mount                                                                           
 247ms systemd-udev-trigger.service                                                             
 213ms polkit.service                                                                           
 190ms systemd-journal-flush.service                                                            
 127ms user@1000.service                                                                        
 112ms avahi-daemon.service                                                                     
 112ms ModemManager.service                                                                     
 108ms NetworkManager.service                                                                   
  76ms udisks2.service                                                                          
  63ms modprobe@drm.service                                                                     
  61ms colord.service                                                                           
  35ms systemd-backlight@leds:dell::kbd_backlight.service                                       
  35ms bluetooth.service                                                                        
  32ms systemd-modules-load.service                                                             
  31ms systemd-sysctl.service                                                                   
  29ms systemd-tmpfiles-setup-dev.service                                                       
  28ms dev-disk-by\x2duuid-fc440987\x2d1c94\x2d45a3\x2d9c45\x2dfcc91942087e.swap                
  27ms systemd-tmpfiles-setup.service                                                           
  25ms systemd-update-utmp.service                                                              
  24ms snapd.apparmor.service                                                                   
  21ms systemd-user-sessions.service                                                            
  18ms dev-hugepages.mount                                                                      
  17ms dev-mqueue.mount                                                                         
  17ms linux-module-cleanup.service                                                             
  16ms sys-kernel-debug.mount                                                                   
  15ms systemd-remount-fs.service                                                               
  15ms sys-kernel-tracing.mount                                                                 
  15ms home.mount                                                                               
  14ms wpa_supplicant.service                                                                   
  13ms kmod-static-nodes.service                                                                
  11ms user-runtime-dir@1000.service                                                            
   9ms rtkit-daemon.service                                                                     
   9ms sys-kernel-config.mount                                                                  
   9ms tmp.mount                                                                                
   6ms sys-fs-fuse-connections.mount                                                            
 869us snapd.socket         

Does this look okay? Anything else that I can disable?

Thanks again for your help so far, I hope you are feeling better with the COVID-19 that you are fighting!

2 Likes

Those are very good results. I think you should leave it at that. :slight_smile:

You’re welcome. :wink:

At the moment, I’m feeling pretty bad. It’s a horrible disease. But hey, it’s not like anyone asked me whether I wanted to get infected. I got infected because other people than me are not following the rules of social distance, hygiene and staying at home when they don’t have to go out. :frowning:

So I have no choice. I’ll just have to get through it again. “Again”, because I already had it once before, in April this year. :frowning:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.