Ubuntu 16.04 升级后启动缓慢

Ubuntu 16.04 升级后启动缓慢

我已经升级到 Ubuntu 16.04,但启动速度很慢。我只粘贴了dmesg速度很慢的部分。

[    0.204212] PCI: CLS 64 bytes, default 64
[    0.204244] Trying to unpack rootfs image as initramfs...
[    0.580208] Freeing initrd memory: 34716K (ffff880033c22000 - ffff880035e09000)
[    0.580233] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)

[    0.708039] ata1: SATA max UDMA/133 abar m2048@0xf7216000 port 0xf7216100 irq 30
[    0.708040] ata2: DUMMY
[    0.708041] ata3: DUMMY
[    0.708042] ata4: DUMMY
[    0.708044] ata5: SATA max UDMA/133 abar m2048@0xf7216000 port 0xf7216300 irq 30
[    0.713054] r8169 0000:03:00.0 eth0: RTL8168g/8111g at 0xffffc9000073e000, f8:bc:12:6a:b1:27, XID 0c000800 IRQ 31
[    0.713057] r8169 0000:03:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]
[    0.916133] usb 1-1: new high-speed USB device number 2 using ehci-pci
[    0.932126] usb 3-1: new full-speed USB device number 2 using xhci_hcd
[    0.932135] usb 2-1: new high-speed USB device number 2 using ehci-pci
[    1.024132] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)

[    1.731849] usbcore: registered new interface driver usb-storage
[    1.732726] usbcore: registered new interface driver uas
[    1.745077] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[    2.527620] random: nonblocking pool is initialized
[    2.580169] clocksource: Switched to clocksource tsc

最后一部分

[    7.064802] systemd[1]: Started Apply Kernel Variables.
[    7.120884] systemd[1]: Started Set console keymap.
[    7.182860] systemd[1]: Started Journal Service.
[    9.806764] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
[    9.993932] systemd-journald[855]: Received request to flush runtime journal from PID 1
[   10.764016] shpchp: Standard Hot Plug PCI Controller Driver version: 0.4
[   11.581881] dcdbas dcdbas: Dell Systems Management Base Driver (version 5.6.0-3.2)
[   11.687512] AVX2 version of gcm_enc/dec engaged.
[   11.687514] AES CTR mode by8 optimization enabled
[   11.693854] [drm] Initialized drm 1.1.0 20060810
[   12.128087] snd_hda_intel 0000:01:00.1: Disabling MSI
[   12.128091] snd_hda_intel 0000:01:00.1: Handle vga_switcheroo audio client
[   12.219941] snd_hda_codec_realtek hdaudioC0D2: autoconfig for ALC662 rev3: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:line
[   12.219944] snd_hda_codec_realtek hdaudioC0D2:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   12.219946] snd_hda_codec_realtek hdaudioC0D2:    hp_outs=1 (0x1b/0x0/0x0/0x0/0x0)
[   12.219946] snd_hda_codec_realtek hdaudioC0D2:    mono: mono_out=0x0
[   12.219947] snd_hda_codec_realtek hdaudioC0D2:    inputs:
[   12.219949] snd_hda_codec_realtek hdaudioC0D2:      Rear Mic=0x19
[   12.219950] snd_hda_codec_realtek hdaudioC0D2:      Front Mic=0x18
[   12.219951] snd_hda_codec_realtek hdaudioC0D2:      Line=0x1a
[   12.229089] input: HDA Intel PCH Rear Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input8
[   12.229127] input: HDA Intel PCH Front Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
[   12.229160] input: HDA Intel PCH Line as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
[   12.229191] input: HDA Intel PCH Line Out as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
[   12.229223] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input12
[   12.515231] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input13
[   12.515268] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input14
[   14.368589] nvidia: module license 'NVIDIA' taints kernel.
[   14.368592] Disabling lock debugging due to kernel taint
[   14.371983] nvidia: module verification failed: signature and/or required key missing - tainting kernel
[   14.375548] vgaarb: device changed decodes: PCI:0000:01:00.0,olddecodes=io+mem,decodes=none:owns=io+mem
[   14.375613] nvidia-nvlink: Nvlink Core is being initialized, major device number 246
[   14.375710] [drm] Initialized nvidia-drm 0.0.0 20150116 for 0000:01:00.0 on minor 0
[   14.375713] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  361.42  Tue Mar 22 18:10:58 PDT 2016
[   14.770921] Adding 4142076k swap on /dev/sda5.  Priority:-1 extents:1 across:4142076k FS
[   14.920390] intel_rapl: Found RAPL domain package
[   14.920392] intel_rapl: Found RAPL domain core
[   14.920394] intel_rapl: Found RAPL domain dram
[   14.920396] intel_rapl: RAPL package 0 domain package locked by BIOS
[   14.920398] intel_rapl: RAPL package 0 domain dram locked by BIOS
[   15.039367] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  361.42  Tue Mar 22 17:29:54 PDT 2016
[   15.226610] nvidia-uvm: Loaded the UVM driver in lite mode, major device number 245
[   17.247667] audit: type=1400 audit(1470190982.111:2): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/bin/ubuntu-core-launcher" pid=2402 comm="apparmor_parser"
[   17.260652] audit: type=1400 audit(1470190982.119:3): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/sbin/dhclient" pid=2399 comm="apparmor_parser"
[   17.260656] audit: type=1400 audit(1470190982.119:4): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=2399 comm="apparmor_parser"
[   17.260659] audit: type=1400 audit(1470190982.119:5): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-helper" pid=2399 comm="apparmor_parser"
[   17.260662] audit: type=1400 audit(1470190982.119:6): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/connman/scripts/dhclient-script" pid=2399 comm="apparmor_parser"
[   17.370137] audit: type=1400 audit(1470190982.227:7): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/telepathy/mission-control-5" pid=2404 comm="apparmor_parser"
[   17.370142] audit: type=1400 audit(1470190982.227:8): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/telepathy/telepathy-*" pid=2404 comm="apparmor_parser"
[   17.370145] audit: type=1400 audit(1470190982.227:9): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/telepathy/telepathy-*//pxgsettings" pid=2404 comm="apparmor_parser"
[   17.370148] audit: type=1400 audit(1470190982.227:10): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/telepathy/telepathy-*//sanitized_helper" pid=2404 comm="apparmor_parser"
[   17.370151] audit: type=1400 audit(1470190982.227:11): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/telepathy/telepathy-ofono" pid=2404 comm="apparmor_parser"
[   21.790450] cgroup: new mount options do not match the existing superblock, will be ignored
[   26.110295] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   26.276323] r8169 0000:03:00.0 eth0: link down
[   26.276342] r8169 0000:03:00.0 eth0: link down
[   26.276385] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   28.613629] r8169 0000:03:00.0 eth0: link up
[   28.613636] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   37.466205] vboxdrv: Found 4 processor cores
[   37.484930] vboxdrv: TSC mode is Invariant, tentative frequency 3192606045 Hz
[   37.484941] vboxdrv: Successfully loaded version 5.0.24_Ubuntu (interface 0x00240000)
[   37.487363] VBoxNetFlt: Successfully started.
[   37.489455] VBoxNetAdp: Successfully started.
[   37.491734] VBoxPciLinuxInit
[   37.493687] vboxpci: IOMMU not found (not registered)
[   40.412102] nvidia-modeset: Allocated GPU:0 (GPU-7c788e0d-eac6-268b-9ef9-38957d72fb15) @ PCI:0000:01:00.0

这是systemd-analyze blame

18.266s mysql.service
         13.201s NetworkManager-wait-online.service
          9.566s lightdm.service
          8.373s dev-sda1.device
          8.025s apparmor.service
          7.085s grub-common.service
          6.356s ModemManager.service
          6.241s gpu-manager.service
          5.251s snapd.refresh.service
          3.854s accounts-daemon.service
          3.752s networking.service
          3.674s thermald.service
          3.525s apache2.service
          3.305s console-setup.service
          3.261s systemd-tmpfiles-setup.service
          3.243s speech-dispatcher.service
          3.234s console-kit-log-system-start.service
          3.227s rsyslog.service
          2.998s NetworkManager.service
          1.931s systemd-udevd.service
          1.842s colord.service
          1.450s plymouth-start.service
          1.437s polkitd.service
          1.403s systemd-tmpfiles-setup-dev.service
          1.349s systemd-journald.service
          1.295s keyboard-setup.service

答案1

我的启动时间要长得多,但如果你真的想加快速度并且不关心启动画面,你可以禁用启动画面以加快速度。

您可以通过编辑来执行此操作/etc/default/grub。您可以通过运行以下命令进行必要的更改:

sudo sed -i 's/splash/profile/g;s/quiet//g' /etc/default/grub
sudo update-grub

这将替换内核标志quiet splashprofile跳过启动画面。

要恢复此更改,请运行以下命令:

sudo sed -i 's/profile/quiet splash/g' /etc/default/grub
sudo update-grub

此外,如果您不使用某些未使用的服务,则可以将其禁用。例如,除非您使用拨号或调制解调器,否则您可以禁用 ModemManager:

sudo systemctl disable ModemManager

此外,根据您的需要,您可能不需要 apache2 在启动时启动。

运行以下命令将在启动时禁用 apache2 的启动:

sudo systemctl disable apache2

您可以在启动后使用以下命令启动 apache2:

sudo systemctl start apache2

每当需要 apache2 时。

最后,运行以下命令来编辑NetworkManager-wait-online.service的超时值:

sudo nano /lib/systemd/system/NetworkManager-wait-online.service

改成timeout=30timeout=1

CTRL+o然后按ENTER保存文件。按CTRL+x退出 nano。

如果这会中断任何服务,请增加该值。如果没有,请享受更快的启动时间。

答案2

如果你不插以太网电缆,你的机器启动速度会更快吗?如果是这样,那么 r8169 驱动程序存在缺陷,应该用 Synaptic 安装的 r8168-dkms 替换。

另外,您是从 SSD 启动的吗?有时启动速度太快……快得超过了网络准备就绪的速度……因此您必须调整启动速度。

回报。

答案3

幸运的是,我刚刚在桌面上解决了同样的问题,所以我很高兴分享解决方案。具体来说,我正在回答为什么日志中这两行之间有 4.5 秒的延迟:

[ 2.580169] clocksource: Switched to clocksource tsc [ 7.064802] systemd[1]: Started Apply Kernel Variables.

在我将 rootfs 从 Samsung 840 EVO 256GB SSD 切换到 Samsung 850 EVO 500GB SSD 后,也发生了同样的事情。起初,我以为更新、更大的三星 SSD 速度更慢,但仅仅一秒钟的思考就让我意识到这完全是胡说八道。因此,我想起了我同时还做了什么,即:我从系统中移除了另外两个硬盘(以使系统保持安静并仅使用 SSD)。现在,其中一个硬盘有一个交换分区,虽然我不使用交换(我在这个桌面上有足够的 RAM),但这个文件中有一个指向它的 UUID 指针:

/etc/initramfs-tools/conf.d/resume

因此,磁盘已消失,但在启动时,您的 initramfs 映像中仍使用指向其分区之一的 UUID 指针!啊哈,原来这 4.5 秒就是用来干这个的!为了证实这个猜测,我刚刚从上述文件中删除了 UUID 行resume,并运行了以下命令:

$ sudo update-initramfs -u

然后重新启动系统,瞧瞧,启动时间减少到 2.1 秒(使用三星 840 EVO 时为 2.3 秒,修复之前增加到近 7 秒)。

相关内容