Views:
2,020
Votes: 3
Tags:
boot
grub2
initramfs
bootchart
defrag
Link:
🔍 See Original Question on Ask Ubuntu ⧉ 🔗
URL:
https://askubuntu.com/q/864277
Title:
Is initrd.img (grub's "Loading initial ramdisk ...") slowing down my boot?
ID:
/2016/12/24/Is-initrd.img-_grub_s-_Loading-initial-ramdisk-/Is-initrd.img-_grub_s-_Loading-initial-ramdisk-...__-slowing-down-my-boot_
Created:
December 24, 2016
Edited: April 13, 2017
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: true
Copy to clipboard: false
I’m on an SSD where file fragmentation shouldn’t matter that much anyway but I noticed “loading initial ramdisk …” message in grub is taking longer that I think it should. It lasts about 7 seconds before Plymouth runs. Plymouth itself only takes about 3 seconds (it would be nice if it started sooner and lasted longer though). Then lightdm / greeter screen comes up over a 2 to 3 seconds.
So I did a little experimenting and ran filefrag -v /boot/init*
and noticed my kernel 4.4.0-53 seems overly fragmented:
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
I’m curious how a fragmented initrd.img
will impact booting performance. Is it worth defragging?
Of course I’m always open to suggestions for making initrd.img
smaller and faster as well.
Note: Besides the mSata SSD and full-size SSD my laptop has a full-size HDD that contains Ubuntu 14.04 so I’m interested in defragging initrd.img
in general, not just for SSD. The current boot session is from the mSata SSD though which is limited to SATA II speeds unlike the full-size drives which are on SATA III bus.
EDIT 1: - systemd
Boot Chart
As per comments below I’ve included the systemd-bootchart which is generated by modifying grub kernel parameters with:
GRUB_CMDLINE_LINUX_DEFAULT="splash vt.handoff=7 kaslr init=/lib/systemd/systemd-bootchart"
The boot chart is saved to: /run/log/bootchart-20161224-1801.svg
. I had to use gimp
to open and export it in .jpg
format at 75% quality to make it fit in Ask Ubuntu’s 2.1 MB limit. The exported file is shown below:
Notice the 9 second delay at the begining. The “normal” delay of 7 seconds for “Loading initial ramdisk …” message in grub is now about 10 seconds. The extra time likely attributable to systemd-bootchart overhead.
EDIT 2: RAM and cgroups
As per comments (requests) below RAM
and cgroups
from /var/log/syslog
are included in this edit.
Output from free -m
:
$ free -m
total used free shared buff/cache available
Mem: 7843 3167 820 1574 3854 2740
Swap: 7999 4 7995
Note that SWAP is only used for testing OOM Killer
and can be erased. Indeed technically it shouldn’t be on an SSD in the first place.
Output from 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
Note this log contains multiple boots.
Edit 3 - Speed improved.
After implementing the Q&A answer I wrote (How can I set up a password for the 'rm' command?) where a wrapper script password protects the rm
command, boot speed has doubled.
Here’s the new graph: