initrd.img(grub 的“正在加载初始 ramdisk...”)是否会减慢我的启动速度?

initrd.img(grub 的“正在加载初始 ramdisk...”)是否会减慢我的启动速度?

我使用的是 SSD,文件碎片本来就不是什么大问题,但我注意到 grub 中的“正在加载初始 ramdisk...”消息比我认为的要长。它持续了大约 7 秒钟,然后 Plymouth 才开始运行。Plymouth 本身只需要大约 3 秒钟(不过,如果它能更早启动并持续更长时间就好了)。然后 lightdm/greeter 屏幕会在 2 到 3 秒内出现。

因此我做了一些实验并运行filefrag -v /boot/init*后发现我的内核 4.4.0-53 似乎过于碎片化:

File size of /boot/initrd.img-4.4.0-53-generic is 49027703 (11970 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       3:    4351562..   4351565:      4:            
   1:        4..    4095:    2334720..   2338811:   4092:    4351566:
   2:     4096..    8191:    2330624..   2334719:   4096:    2338812:
   3:     8192..   10239:    2355200..   2357247:   2048:    2334720:
   4:    10240..   11969:    2408448..   2410177:   1730:    2357248: last,eof

我很好奇碎片化initrd.img会如何影响启动性能。碎片整理值得吗?

initrd.img当然,我也始终乐于接受有关使其变得更小、更快的建议。

笔记:除了 mSata SSD 和全尺寸 SSD,我的笔记本电脑还配备了一个全尺寸 HDD,其中包含 Ubuntu 14.04,因此我对碎片整理很感兴趣initrd.img,而不仅仅是 SSD。当前的启动会话来自 mSata SSD,但它的速度限制为 SATA II,而全尺寸驱动器的速度则位于 SATA III 总线上。

编辑 1:-systemd启动图表

根据以下评论,我添加了systemd-bootchart它是通过修改 grub 内核参数生成的:

GRUB_CMDLINE_LINUX_DEFAULT="splash vt.handoff=7 kaslr init=/lib/systemd/systemd-bootchart"

启动图表保存到:/run/log/bootchart-20161224-1801.svg。我不得不使用以 75% 质量gimp的格式打开并导出它,.jpg以使其符合 Ask Ubuntu 的 2.1 MB 限制。导出的文件如下所示:

systemd 启动图

注意开始时的 9 秒延迟。grub 中“正在加载初始 ramdisk ...”消息的“正常”延迟为 7 秒,现在约为 10 秒。额外的时间可能归因于systemd-bootchart高架。

编辑 2:RAM 和 cgroups

按照下面的评论(请求)RAMcgroups包含/var/log/syslog在此编辑中。

输出自free -m

$ free -m
              total        used        free      shared  buff/cache   available
Mem:           7843        3167         820        1574        3854        2740
Swap:          7999           4        7995

请注意,SWAP 仅用于测试OOM Killer,可以擦除。实际上,从技术上讲,它本来就不应该位于 SSD 上。

输出自grep cgroup < /var/log/syslog.1

$ grep cgroup < /var/log/syslog.1
Dec 24 15:22:50 dell kernel: [    0.000000] Initializing cgroup subsys cpuset
Dec 24 15:22:50 dell kernel: [    0.000000] Initializing cgroup subsys cpu
Dec 24 15:22:50 dell kernel: [    0.000000] Initializing cgroup subsys cpuacct
Dec 24 15:22:50 dell kernel: [    0.011642] Initializing cgroup subsys io
Dec 24 15:22:50 dell kernel: [    0.011645] Initializing cgroup subsys memory
Dec 24 15:22:50 dell kernel: [    0.011651] Initializing cgroup subsys devices
Dec 24 15:22:50 dell kernel: [    0.011653] Initializing cgroup subsys freezer
Dec 24 15:22:50 dell kernel: [    0.011655] Initializing cgroup subsys net_cls
Dec 24 15:22:50 dell kernel: [    0.011657] Initializing cgroup subsys perf_event
Dec 24 15:22:50 dell kernel: [    0.011659] Initializing cgroup subsys net_prio
Dec 24 15:22:50 dell kernel: [    0.011662] Initializing cgroup subsys hugetlb
Dec 24 15:22:50 dell kernel: [    0.011664] Initializing cgroup subsys pids
Dec 24 15:22:50 dell kernel: [    6.204710] cgroup: new mount options do not match the existing superblock, will be ignored
Dec 24 15:23:33 dell kernel: [    0.000000] Initializing cgroup subsys cpuset
Dec 24 15:23:33 dell kernel: [    0.000000] Initializing cgroup subsys cpu
Dec 24 15:23:33 dell kernel: [    0.000000] Initializing cgroup subsys cpuacct
Dec 24 15:23:33 dell kernel: [    0.010846] Initializing cgroup subsys io
Dec 24 15:23:33 dell kernel: [    0.010849] Initializing cgroup subsys memory
Dec 24 15:23:33 dell kernel: [    0.010855] Initializing cgroup subsys devices
Dec 24 15:23:33 dell kernel: [    0.010857] Initializing cgroup subsys freezer
Dec 24 15:23:33 dell kernel: [    0.010860] Initializing cgroup subsys net_cls
Dec 24 15:23:33 dell kernel: [    0.010861] Initializing cgroup subsys perf_event
Dec 24 15:23:33 dell kernel: [    0.010864] Initializing cgroup subsys net_prio
Dec 24 15:23:33 dell kernel: [    0.010867] Initializing cgroup subsys hugetlb
Dec 24 15:23:33 dell kernel: [    0.010868] Initializing cgroup subsys pids
Dec 24 15:23:33 dell kernel: [    7.338815] cgroup: new mount options do not match the existing superblock, will be ignored
Dec 24 15:45:25 dell kernel: [    0.000000] Initializing cgroup subsys cpuset
Dec 24 15:45:25 dell kernel: [    0.000000] Initializing cgroup subsys cpu
Dec 24 15:45:25 dell kernel: [    0.000000] Initializing cgroup subsys cpuacct
Dec 24 15:45:25 dell kernel: [    0.010844] Initializing cgroup subsys io
Dec 24 15:45:25 dell kernel: [    0.010847] Initializing cgroup subsys memory
Dec 24 15:45:25 dell kernel: [    0.010853] Initializing cgroup subsys devices
Dec 24 15:45:25 dell kernel: [    0.010855] Initializing cgroup subsys freezer
Dec 24 15:45:25 dell kernel: [    0.010857] Initializing cgroup subsys net_cls
Dec 24 15:45:25 dell kernel: [    0.010859] Initializing cgroup subsys perf_event
Dec 24 15:45:25 dell kernel: [    0.010861] Initializing cgroup subsys net_prio
Dec 24 15:45:25 dell kernel: [    0.010864] Initializing cgroup subsys hugetlb
Dec 24 15:45:25 dell kernel: [    0.010866] Initializing cgroup subsys pids
Dec 24 15:45:25 dell kernel: [    5.977461] cgroup: new mount options do not match the existing superblock, will be ignored
Dec 24 16:09:31 dell kernel: [    0.000000] Initializing cgroup subsys cpuset
Dec 24 16:09:31 dell kernel: [    0.000000] Initializing cgroup subsys cpu
Dec 24 16:09:31 dell kernel: [    0.000000] Initializing cgroup subsys cpuacct
Dec 24 16:09:31 dell kernel: [    0.010848] Initializing cgroup subsys io
Dec 24 16:09:31 dell kernel: [    0.010852] Initializing cgroup subsys memory
Dec 24 16:09:31 dell kernel: [    0.010858] Initializing cgroup subsys devices
Dec 24 16:09:31 dell kernel: [    0.010860] Initializing cgroup subsys freezer
Dec 24 16:09:31 dell kernel: [    0.010862] Initializing cgroup subsys net_cls
Dec 24 16:09:31 dell kernel: [    0.010864] Initializing cgroup subsys perf_event
Dec 24 16:09:31 dell kernel: [    0.010866] Initializing cgroup subsys net_prio
Dec 24 16:09:31 dell kernel: [    0.010870] Initializing cgroup subsys hugetlb
Dec 24 16:09:31 dell kernel: [    0.010871] Initializing cgroup subsys pids
Dec 24 16:09:31 dell kernel: [    6.663158] cgroup: new mount options do not match the existing superblock, will be ignored
Dec 24 18:00:44 dell kernel: [    0.000000] Initializing cgroup subsys cpuset
Dec 24 18:00:44 dell kernel: [    0.000000] Initializing cgroup subsys cpu
Dec 24 18:00:44 dell kernel: [    0.000000] Initializing cgroup subsys cpuacct
Dec 24 18:00:44 dell kernel: [    0.011644] Initializing cgroup subsys io
Dec 24 18:00:44 dell kernel: [    0.011647] Initializing cgroup subsys memory
Dec 24 18:00:44 dell kernel: [    0.011654] Initializing cgroup subsys devices
Dec 24 18:00:44 dell kernel: [    0.011656] Initializing cgroup subsys freezer
Dec 24 18:00:44 dell kernel: [    0.011658] Initializing cgroup subsys net_cls
Dec 24 18:00:44 dell kernel: [    0.011660] Initializing cgroup subsys perf_event
Dec 24 18:00:44 dell kernel: [    0.011662] Initializing cgroup subsys net_prio
Dec 24 18:00:44 dell kernel: [    0.011665] Initializing cgroup subsys hugetlb
Dec 24 18:00:44 dell kernel: [    0.011667] Initializing cgroup subsys pids
Dec 24 18:00:44 dell kernel: [    6.388658] cgroup: new mount options do not match the existing superblock, will be ignored
Dec 24 18:01:33 dell kernel: [    0.000000] Initializing cgroup subsys cpuset
Dec 24 18:01:33 dell kernel: [    0.000000] Initializing cgroup subsys cpu
Dec 24 18:01:33 dell kernel: [    0.000000] Initializing cgroup subsys cpuacct
Dec 24 18:01:33 dell kernel: [    0.010850] Initializing cgroup subsys io
Dec 24 18:01:33 dell kernel: [    0.010854] Initializing cgroup subsys memory
Dec 24 18:01:33 dell kernel: [    0.010860] Initializing cgroup subsys devices
Dec 24 18:01:33 dell kernel: [    0.010862] Initializing cgroup subsys freezer
Dec 24 18:01:33 dell kernel: [    0.010864] Initializing cgroup subsys net_cls
Dec 24 18:01:33 dell kernel: [    0.010866] Initializing cgroup subsys perf_event
Dec 24 18:01:33 dell kernel: [    0.010868] Initializing cgroup subsys net_prio
Dec 24 18:01:33 dell kernel: [    0.010871] Initializing cgroup subsys hugetlb
Dec 24 18:01:33 dell kernel: [    0.010873] Initializing cgroup subsys pids
Dec 24 18:01:34 dell kernel: [   12.036550] cgroup: new mount options do not match the existing superblock, will be ignored

请注意,该日志包含多次启动。

编辑 3-速度提高。

在实施问答答案之后,我写道(如何为‘rm’命令设置密码?) 其中包装脚本密码保护rm命令,启动速度提高了一倍。

这是新图表:

bootchart 12 月 30 日

答案1

我不认为碎片整理是你的问题,但你可以这样做......

terminal...

  • 输入man update-initramfs#来了解有关此命令的更多信息。

  • 然后输入sudo update-initramfs -c#从头创建一个新文件。

  • 然后输入reboot

相关内容