有没有什么办法可以减少我的 Ubuntu 的启动时间?

有没有什么办法可以减少我的 Ubuntu 的启动时间?

我在一台 HP 笔记本电脑上使用 Ubuntu 18.04,该笔记本电脑双启动 Windows 10,Ubuntu 有 40 GB 的磁盘空间,SWAP 区域有 20 GB,因为我有 8 GB 的 RAM。我使用的是 HDD。在 40 GB 中,32.5 GB 仍然可用且免费。几周前我刚刚安装了操作系统。关机时间很短,大约 5 秒,但启动所需的时间长达 1 分钟。我已经编辑/etc/initramfs-tools/initramfs.conf和更改了MODULES=dep。这大大减少了 initramfs 所花费的时间。我不确定如何改进它并减少所花费的时间。

启动时间从systemd-analyze blame

 23.512s dev-sda6.device
 21.462s plymouth-quit-wait.service
 18.832s systemd-udevd.service
 18.395s apparmor.service
 17.486s systemd-tmpfiles-setup.service
  6.801s NetworkManager-wait-online.service
  6.732s plymouth-start.service
  5.873s plymouth-read-write.service
  4.169s udisks2.service
  3.890s networking.service
  3.889s accounts-daemon.service
  3.013s speech-dispatcher.service
  2.573s networkd-dispatcher.service
  2.527s NetworkManager.service
  2.453s avahi-daemon.service
  2.449s thermald.service
  2.446s alsa-restore.service
  2.446s systemd-logind.service
  2.443s pppd-dns.service
  2.438s gpu-manager.service
  2.434s rsyslog.service
  2.016s apport.service
  1.426s wpa_supplicant.service
  1.388s dns-clean.service
  1.276s grub-common.service
  1.269s keyboard-setup.service
  1.056s tlp.service
  1.007s systemd-random-seed.service
   987ms packagekit.service
   896ms fwupd.service
   878ms systemd-tmpfiles-setup-dev.service
   779ms systemd-remount-fs.service
   758ms dev-mqueue.mount
   714ms sys-kernel-debug.mount
   712ms dev-hugepages.mount
   694ms systemd-modules-load.service
   590ms polkit.service
   579ms iio-sensor-proxy.service
   574ms systemd-sysctl.service
   442ms colord.service
   434ms systemd-journal-flush.service
   379ms systemd-timesyncd.service
   332ms dev-disk-by\x2duuid-72e62aa6\x2deefa\x2d49e1\x2daba3\x2d858b0e7dfbd3.swap
   330ms upower.service
   321ms systemd-journald.service
   312ms systemd-backlight@backlight:intel_backlight.service
   230ms setvtrgb.service
   217ms ufw.service
   209ms [email protected]
   179ms systemd-resolved.service
   174ms bolt.service
   141ms gdm.service
   106ms kmod-static-nodes.service
    87ms console-setup.service
    73ms systemd-update-utmp.service
    56ms systemd-udev-trigger.service
    52ms kerneloops.service
    22ms systemd-user-sessions.service
    20ms sys-fs-fuse-connections.mount
    19ms rtkit-daemon.service
    19ms sys-kernel-config.mount
     8ms systemd-update-utmp-runlevel.service

free --human

              total        used        free      shared  buff/cache   available
Mem:           7.7G        1.2G        5.4G        148M        1.1G        6.3G
Swap:           19G          0B         19G

输出ls /etc/apparmor.d/

abstractions  force-complain  tunables         usr.bin.man                           usr.lib.libreoffice.program.soffice.bin  usr.sbin.cupsd     usr.sbin.tcpdump
cache         local           usr.bin.evince   usr.lib.libreoffice.program.oosplash  usr.lib.libreoffice.program.xpdfimport   usr.sbin.ippusbxd
disable       sbin.dhclient   usr.bin.firefox  usr.lib.libreoffice.program.senddoc   usr.sbin.cups-browsed                    usr.sbin.rsyslogd

笔记:

  • 为了缩短所需时间,systemd-journal-flush.service我将日志刷新服务使用的最大文件大小减少到 50M。
  • sda6 是我在硬盘上安装 Ubuntu 的分区
  • 我的机器不使用 Thunderbolt
  • 我不使用 SSD

编辑:添加基准测试结果

sudo hdparm -Tt /dev/sda

/dev/sda:
 Timing cached reads:   11730 MB in  2.00 seconds = 5876.89 MB/sec
 Timing buffered disk reads: 322 MB in  3.00 seconds = 107.22 MB/sec

sudo hdparm -v /dev/sda

/dev/sda:
 multcount     = 16 (on)
 IO_support    =  1 (32-bit)
 readonly      =  0 (off)
 readahead     = 256 (on)
 geometry      = 121601/255/63, sectors = 1953525168, start = 0

dd if=/dev/zero of=/tmp/output bs=8k count=10k; rm -f /tmp/output

10240+0 records in
10240+0 records out
83886080 bytes (84 MB, 80 MiB) copied, 0.0681511 s, 1.2 GB/s

此处显示图形结果

相关内容