[Seek Help] 开机有些程序占用的时间太多了,可以优化一下吗?不想等太久
Tofloor
poster avatar
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-01-10 05:08
Author

V23开机有些程序占用的时间太多了,可以优化一下吗?不想等太久

感觉开机时间等太久了

用命令行查看了一下

systemd-analyze blame
30.549s plymouth-quit-wait.service
14.515s systemd-journal-flush.service
11.214s dev-sda5.device
10.774s udisks2.service
10.531s NetworkManager-wait-online.service
10.060s spark-update-notifier.service
 8.894s deepin-accounts1-daemon.service
 8.869s accounts-daemon.service
 8.349s lightdm.service
 8.281s nmbd.service
 7.008s deepin-login-sound.service
 6.934s polkit.service
 6.591s NetworkManager.service
 6.564s wpa_supplicant.service
 6.549s avahi-daemon.service
 6.547s bluetooth.service
 6.537s org.deepin.linglong.PackageManager.service
 6.535s org.deepin.linglong.SystemHelper.service
 5.770s e2scrub_reap.service
 5.582s smartmontools.service
 5.356s cups.service
 4.855s ModemManager.service
 2.881s networking.service
 2.814s zram-swap.service
 2.423s upower.service
 2.158s systemd-rfkill.service
 1.957s smbd.service
 1.769s deepin-authenticate.service
 1.394s lm-sensors.service
 1.208s systemd-backlight@backlight:intel_backlight.service
 1.164s systemd-udevd.service
 1.132s systemd-modules-load.service
 1.128s systemd-logind.service
 1.122s winbind.service
 1.027s laptop-mode.service
  796ms systemd-random-seed.service
  784ms systemd-fsck@dev-disk-by\x2duuid-54CC\x2d09D7.service
  775ms systemd-backlight@leds:platform::kbd_backlight.service
  761ms systemd-udev-trigger.service
  724ms apt-daily-upgrade.service
  723ms systemd-tmpfiles-setup-dev.service
  693ms boot-efi.mount
  684ms [email protected]
  446ms systemd-journald.service
  436ms plymouth-read-write.service
  385ms dde-filemanager-daemon.service
  374ms systemd-sysusers.service
  351ms systemd-tmpfiles-setup.service
  347ms lvm2-monitor.service
  339ms plymouth-start.service
  333ms systemd-remount-fs.service
  315ms fstrim.service
  275ms ifupdown-pre.service
  247ms systemd-sysctl.service
  208ms systemd-binfmt.service
  206ms packagekit.service
  142ms fprintd.service
   96ms systemd-timesyncd.service
   91ms ipwatchd.service
   83ms dde-dconfig-daemon.service
   68ms systemd-update-utmp.service
   58ms dev-hugepages.mount
   56ms dev-mqueue.mount
   54ms sys-kernel-debug.mount
   52ms sys-kernel-tracing.mount
   51ms rtkit-daemon.service
   50ms kmod-static-nodes.service
   47ms systemd-tmpfiles-clean.service
   45ms [email protected]
   45ms systemd-user-sessions.service
   45ms [email protected]
   45ms [email protected]
   38ms proc-sys-fs-binfmt_misc.mount
   25ms [email protected]
   23ms alsa-restore.service
   19ms systemd-update-utmp-runlevel.service
    5ms sys-fs-fuse-connections.mount
    4ms sys-kernel-config.mount
    3ms lmt-poll.service
    2ms modprobe@efi_pstore.service
    2ms modprobe@dm_mod.service
    2ms [email protected]
    1ms binfmt-support.service
   60us blk-availability.service

那些秒数太小的先不看,着重看看占用时间大的,

30.549s plymouth-quit-wait.service

一个开机关机动画真的没太大必要吧?仅仅只是为了观感而牺牲启动的时间的话,大可不必了。

10.060s spark-update-notifier.service

不知道为什么安装完之后会开机启动有这个服务,开机的时候没必要通知我更新软件吧。。。。到时候需要再打开星火看看也可以的。希望默认不要自启这个服务。

7.008s deepin-login-sound.service

这个登陆声音也要占用7秒。。。。占用这么多时间,这个登陆声音,听与不听真的不影响~

6.547s bluetooth.service

至于这个蓝牙。。。其实开机那会根本没人会去用蓝牙吧?出现登陆界面之后再开启也不是不行?蓝牙鼠标蓝牙耳机等设备也是在登陆界面才用得上,对吗?

这里加起来占用了大概53s,我总时间是1min13s。

kk111k-mi111111111111n.png


我们再来看一下14.515s systemd-journal-flush.service

systemd-journal-flush.service 是 Linux 系统中的一个服务,它的主要作用是将存储在 /run/log/journal 中的日志数据刷新(即写入)到 /var/log/journal。

打开看一下,占4.7GB
image.png

如果你的系统中已经有大量的日志文件,这个服务可能会导致系统启动速度变慢。这是因为在启动过程中,系统需要检查大量的旧日志文件,并将新的日志数据附加到这些文件中

sudo journalctl --disk-usage
Archived and active journals take up 3.3G in the file system.

归档和活动日志在文件系统中占用3.3G。

“虽然你可以禁用这个服务,但这并不推荐。因为如果禁用了这个服务,可能会导致不是所有的日志数据都能写入到磁盘中,这在调试启动故障时可能会造成困扰。此外,Journald 是 systemd linux 中的一项基本服务,许多其他服务都依赖于它。”

我尝试把他设置为只保留不超过1g,少于3天,文件数少于5个。

sudo journalctl --vacuum-size=1G --vacuum-time=3days --vacuum-files=5

Startup finished in 5.546s (firmware) + 4.351s (loader) + 7.353s (kernel) + 57.093s (userspace) = 1min 14.345s  graphical.target reached after 57.053s in userspace.

其实用户空间占用的是大头,我再看看用户空间这里的大头(+号后面是所花时间,@是第n秒时)

sudo systemd-analyze critical-chain
graphical.target @57.053s
└─multi-user.target @57.053s
  └─smbd.service @54.927s +2.125s
    └─winbind.service @53.539s +1.361s
      └─nmbd.service @46.919s +6.599s
        └─network-online.target @46.900s
          └─NetworkManager-wait-online.service @33.726s +13.173s
            └─NetworkManager.service @27.072s +6.623s
              └─dbus.service @27.069s
                └─basic.target @26.728s
                  └─sockets.target @26.728s
                    └─dbus.socket @26.728s
                      └─sysinit.target @26.574s
                        └─systemd-update-utmp.service @26.432s +142ms
                          └─systemd-tmpfiles-setup.service @25.663s +735ms
                            └─systemd-journal-flush.service @3.687s +21.931s
                              └─systemd-remount-fs.service @3.381s +256ms
                                └─systemd-journald.socket @3.306s
                                  └─system.slice @3.251s
                                    └─-.slice @3.251s

可以看出主要还是这俩:

systemd-journal-flush.service @3.687s +21.931s

NetworkManager-wait-online.service @33.726s +13.173s

尝试禁掉 NetworkManager-wait-online.service试试先。

sudo systemctl disable NetworkManager-wait-online.service
Removed "/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service".

systemd-analyze time
Startup finished in 6.649s (firmware) + 6.078s (loader) + 6.842s (kernel) + 42.904s (userspace) = 1min 2.474s 
graphical.target reached after 42.853s in userspace.
systemd-analyze blame
13.184s udisks2.service
12.496s nmbd.service
11.144s accounts-daemon.service
10.454s dev-sda5.device
10.428s lightdm.service
8.795s polkit.service
8.577s avahi-daemon.service
7.823s bluetooth.service
7.764s wpa_supplicant.service
7.746s NetworkManager.service
7.697s org.deepin.linglong.PackageManager.service
7.695s org.deepin.linglong.SystemHelper.service
7.558s systemd-tmpfiles-setup.service
7.486s deepin-accounts1-daemon.service
7.372s e2scrub_reap.service
6.749s ModemManager.service
6.606s smartmontools.service
6.541s upower.service
6.314s cups.service
4.500s networking.service
4.443s winbind.service
3.737s zram-swap.service
2.992s binfmt-support.service
2.205s deepin-authenticate.service
2.045s smbd.service
1.594s laptop-mode.service
1.429s systemd-logind.service
1.039s lm-sensors.service
885ms plymouth-read-write.service
823ms systemd-modules-load.service
778ms [email protected]
674ms systemd-udev-trigger.service
624ms packagekit.service
617ms dde-dconfig-daemon.service
590ms systemd-udevd.service
556ms systemd-random-seed.service
551ms systemd-backlight@backlight:intel_backlight.service
549ms systemd-journald.service
479ms systemd-tmpfiles-setup-dev.service
470ms plymouth-start.service
375ms systemd-backlight@leds:platform::kbd_backlight.service
359ms systemd-update-utmp.service
358ms lvm2-monitor.service
345ms systemd-timesyncd.service
325ms systemd-fsck@dev-disk-by\x2duuid-54CC\x2d09D7.service
313ms dde-filemanager-daemon.service
301ms systemd-rfkill.service
274ms systemd-sysusers.service
241ms systemd-remount-fs.service
182ms systemd-binfmt.service
171ms systemd-sysctl.service
149ms fprintd.service
133ms dev-hugepages.mount
131ms dev-mqueue.mount
129ms sys-kernel-debug.mount
127ms sys-kernel-tracing.mount
124ms kmod-static-nodes.service
120ms [email protected]
116ms [email protected]
115ms [email protected]
107ms ipwatchd.service
93ms rtkit-daemon.service
76ms boot-efi.mount
67ms ifupdown-pre.service
34ms proc-sys-fs-binfmt_misc.mount
27ms [email protected]
23ms systemd-user-sessions.service
19ms systemd-update-utmp-runlevel.service
7ms alsa-restore.service
3ms lmt-poll.service
2ms sys-fs-fuse-connections.mount
2ms modprobe@efi_pstore.service
2ms [email protected]
2ms modprobe@dm_mod.service
1ms sys-kernel-config.mount
58us blk-availability.service

顺带systemd-analyze 中文手册

Reply Favorite View the author
All Replies
2 / 2
To page
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-01-11 10:25
#21
昨夜的星辰

我已经禁了,并没有什么问题,服务器可能不行,桌面端又没有必须在开机前连网搞定的事情

辛辛苦苦禁掉了几个大头之后只少了10s。。。。。。

Reply View the author
昨夜的星辰
deepin
2024-01-11 12:35
#22
把一切操作变成GUI

辛辛苦苦禁掉了几个大头之后只少了10s。。。。。。

你这的问题很明显是硬件跟不上,机械硬盘?如果是机械硬盘开机开个一两分钟也正常

还有就是机械硬盘往往伴随着处理器的性能也不太高,综合起来开机更慢了

Reply View the author
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-01-11 20:49
#23
昨夜的星辰

你这的问题很明显是硬件跟不上,机械硬盘?如果是机械硬盘开机开个一两分钟也正常

还有就是机械硬盘往往伴随着处理器的性能也不太高,综合起来开机更慢了

win10开机也不至于这么慢吧。。。。

我不要求有win10这么快,但是也不能超1分钟吧。。。

Reply View the author
2 / 2
To page