Ubuntu 启动时间

Ubuntu 启动时间

我的电脑运行着 Ubuntu,启动需要很长时间。

systemd-analyze critical-chain以下是和的输出systemd-analyze blame

$ systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

graphical.target @1min 48.620s
└─multi-user.target @1min 48.620s
  └─snapd.seeded.service @1min 31.009s +589ms
    └─snapd.service @1min 2.833s +28.172s
      └─basic.target @1min 1.943s
        └─sockets.target @1min 1.943s
          └─snapd.socket @1min 1.883s +59ms
            └─sysinit.target @1min 1.857s
              └─snapd.apparmor.service @52.628s +879ms
                └─apparmor.service @13.266s +39.359s
                  └─local-fs.target @13.167s
                    └─run-user-1000-doc.mount @1min 44.431s
                      └─run-user-1000.mount @1min 25.766s
                        └─local-fs-pre.target @8.072s
                          └─systemd-tmpfiles-setup-dev.service @7.695s +375ms
                            └─systemd-sysusers.service @6.889s +805ms
                              └─systemd-remount-fs.service @6.412s +282ms
                                └─systemd-journald.socket @6.288s
                                  └─system.slice @6.225s
                                    └─-.slice @6.225s
$ systemd-analyze blame
         51.958s dev-sda1.device
         39.426s dev-loop37.device
         39.398s dev-loop31.device
         39.359s apparmor.service
         39.320s dev-loop32.device
         39.176s dev-loop40.device
         38.205s dev-loop30.device
         38.139s dev-loop35.device
         38.127s dev-loop8.device
         37.854s dev-loop21.device
         37.673s dev-loop36.device
         37.661s dev-loop13.device
         37.315s dev-loop27.device
         37.280s dev-loop29.device
         36.984s dev-loop9.device
         36.664s dev-loop17.device
         36.301s dev-loop15.device
         36.279s dev-loop28.device
         35.967s dev-loop34.device
         35.500s dev-loop3.device
         34.508s dev-loop38.device
         34.502s dev-loop42.device
         34.486s dev-loop43.device
lines 1-23

答案1

查看到达“graphical.target”需要多长时间,请执行此操作,即使它是在 Ubuntu 18.04 时编写的。它有效,甚至在 Ubuntu 20.04 中也是如此(有两种方法;使用其中一种或两种):

方法一

输入(在终端中):

$ sudo sed -e 's/^RESUME=/#RESUME=/g' \
     -i /etc/initramfs-tools/conf.d/resume

完成后,输入:

$ echo "RESUME=/dev/mapper/ubuntu--YOUR FLAVOR OF UBUNTU (eg. mate)--vg-swap_1" | \
  sudo tee -a /etc/initramfs-tools/conf.d/resume

重新创建 initrd 并重启系统。

$ sudo update-initramfs -u

完成后,输入:

$ sudo reboot

内核启动时间应该更快。输入以下命令进行验证:

$ systemd-analyze

此后您还可以使用休眠模式。

方法二

导航到 /etc/initramfs-tools/conf.d/

右键点击“resume”,选择“以管理员身份编辑”。修改以下行:

RESUME=UUID=无论您的号码是多少(例如 - RESUME=UUID=67b3fe6f-1ec4-413f-8c5a-1136bc7f3270)

到:

简历=无

现在打开终端并输入:

$ sudo update-initramfs -u

完成后,输入:

$ sudo reboot

启动时间应该更快。

取自:这里这里

相关内容