how to speed up initrd at boot

I’m trying to diagnose my boot time, and discovered that the largest share is taken by initrd.

This is the output of systemd-analyze

Startup finished in 4.356s (kernel) + 1min 32.790s (initrd) + 40.040s (userspace) = 2min 17.186s

Are these values normal or could be improved? If possible, I’d like to speed up the whole process.

Try systemd-analyze blame to see which processes ar taking the time

Hi
Not normal at all… should only be 2-3 seconds, I see around 5 seconds on the raspberry pi3.

A slow or failing disk maybe?

freeze down my back I hope not…

this is the SMART report

smartctl 6.5 2016-05-07 r4318 [x86_64-linux-4.9.10-1-default] (SUSE RPM)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       1
  3 Spin_Up_Time            0x0027   180   176   021    Pre-fail  Always       -       1966
  4 Start_Stop_Count        0x0032   098   098   000    Old_age   Always       -       2696
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   100   253   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   079   079   000    Old_age   Always       -       15914
 10 Spin_Retry_Count        0x0032   100   100   051    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   098   098   000    Old_age   Always       -       2671
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       249
193 Load_Cycle_Count        0x0032   160   160   000    Old_age   Always       -       122929
194 Temperature_Celsius     0x0022   099   088   000    Old_age   Always       -       48
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   200   200   051    Old_age   Offline      -       0



For comparison, I see:

Startup finished in 55us (firmware) + 23us (loader) + 1.224s (kernel) + 15.834s (initrd) + 18.487s (userspace) = 35.547s

That’s already slow. But most of my “initrd” time will be how long it takes me to type in the encryption key (using an encrypted LVM).

without output from “systemd-analyze blame” there can be no diagnosis

without output from “systemd-analyze blame” there can be no diagnosis

My problem is with initrd, AFAIK systemd and its processes and services are loaded after initrd has finished; afaik “systemd-analyze blame” can’t help with initrd.

Anyway, here is the output:

         15.883s nmb.service
         10.337s apparmor.service
          9.186s dev-sda5.device
          8.771s systemd-udev-settle.service
          8.007s systemd-journal-flush.service
          7.280s libvirtd.service
          6.769s SuSEfirewall2.service
          6.389s SuSEfirewall2_init.service
          4.831s ntpd.service
          4.683s ModemManager.service
          4.126s postfix.service
          3.747s display-manager.service
          2.940s cups.service
          2.884s systemd-udevd.service
          2.400s systemd-fsck@dev-disk-by\x2duuid-490f1cc3\x2d4911\x2d45a8\x2da7f0\x2da5f4f707554a.service
          2.331s smb.service
          2.182s lvm2-activation-net.service
          2.141s rc-local.service
          2.141s nscd.service
          1.798s rpcbind.service
          1.699s systemd-vconsole-setup.service
          1.487s NetworkManager.service
          1.265s polkit.service
           966ms plymouth-read-write.service
           810ms upower.service
           778ms wpa_supplicant.service
           713ms tmp.mount
           711ms systemd-tmpfiles-setup-dev.service
           685ms systemd-remount-fs.service
           670ms sys-kernel-debug.mount
           620ms boot-grub2-i386\x2dpc.mount
           571ms var-lib-mysql.mount
           528ms dev-mqueue.mount
           525ms dev-hugepages.mount
           513ms udisks2.service
           509ms avahi-daemon.service
           508ms var-lib-machines.mount
           459ms opt.mount
           405ms var-log.mount
           378ms var-lib-libvirt-images.mount
           356ms boot-grub2-x86_64\x2defi.mount
           344ms dev-disk-by\x2duuid-bab51854\x2dd247\x2d4166\x2d90cc\x2d2b9041e5c199.swap
           337ms var-lib-mariadb.mount
           336ms var-lib-pgsql.mount
           332ms systemd-udev-root-symlink.service
           332ms var-lib-mailman.mount
           332ms var-lib-mailman.mount
           327ms lvm2-activation-early.service
           305ms var-lib-named.mount
           303ms systemd-random-seed.service
           299ms var-tmp.mount
           296ms systemd-udev-trigger.service
           292ms var-cache.mount
           282ms dracut-shutdown.service
           280ms auditd.service
           276ms srv.mount
           275ms systemd-logind.service
           270ms home.mount
           268ms systemd-backlight@backlight:acpi_video0.service
           266ms systemd-sysctl.service
           199ms mcelog.service
           195ms usr-local.mount
           193ms systemd-tmpfiles-setup.service
           192ms user@1000.service
           180ms systemd-user-sessions.service
           162ms var-spool.mount
           154ms var-opt.mount
           150ms systemd-journald.service
           140ms rtkit-daemon.service
           132ms systemd-rfkill.service
           132ms \x2esnapshots.mount
           124ms systemd-modules-load.service
           121ms var-crash.mount
           109ms systemd-fsck-root.service
            74ms systemd-tmpfiles-clean.service
            57ms plymouth-start.service
            19ms lvm2-activation.service
            16ms systemd-update-utmp.service
             8ms kmod-static-nodes.service
             8ms sys-fs-fuse-connections.mount
             7ms alsa-restore.service
             6ms systemd-update-utmp-runlevel.service
             3ms var-run.mount


my apologies - you are correct i should read more carefully, i saw the conversation moving to disk issues before getting data. this would be better handled by the more experienced, but would journal not have info from initrd stage (with directives for logging level)?

Okay, try this:

ls -lh /boot/vmlinuz-* /boot/initrd-*

then

rpm -qf /lib/mkinitrd/scripts/setup-* | sort -u

Hi
The other one is;


lsinitrd

ls -lh /boot/vmlinuz-* /boot/initrd-*

-rw------- 1 root root  11M 23 feb 11.17 /boot/initrd-4.9.10-1-default
-rw------- 1 root root  11M 18 feb 11.22 /boot/initrd-4.9.9-1-default
-rw-r--r-- 1 root root 6,8M 18 feb 07.47 /boot/vmlinuz-4.9.10-1-default
-rw-r--r-- 1 root root 6,8M 15 feb 17.15 /boot/vmlinuz-4.9.9-1-default

rpm -qf /lib/mkinitrd/scripts/setup-* | sort -u

error: file /lib/mkinitrd/scripts/setup-*: No such file or directory

sudo lsinitrd

Too long to post it here, see it on pastebin

Hi
There is a new snapshot and kernel up to 4.9.11, so do a;


zypper dup --no-allow-vendor-change

See how that goes and compare the initrd sizes…

I have;


 ls -lh /boot/vmlinuz-* /boot/initrd-*

-rw------- 1 root root 7.5M Feb 24 16:39 /boot/initrd-4.9.10-1-default
-rw------- 1 root root 7.5M Feb 24 16:40 /boot/initrd-4.9.11-1-default
-rw------- 1 root root 8.6M Feb 17 18:24 /boot/initrd-4.9.8-1-default
-rw-r--r-- 1 root root 6.8M Feb 18 00:47 /boot/vmlinuz-4.9.10-1-default
-rw-r--r-- 1 root root 6.8M Feb 21 13:21 /boot/vmlinuz-4.9.11-1-default

I have upgraded to the new kernel, but there aren’t any noticeable changes:

Startup finished in 4.394s (kernel) + 1min 32.800s (initrd) + 43.938s (userspace) = 2min 21.134s

However, mi initrd sizes are different than yours

ls -lh /boot/vmlinuz-* /boot/initrd-*
-rw------- 1 root root  11M 25 feb 14.26 /boot/initrd-4.9.10-1-default
-rw------- 1 root root  11M 25 feb 14.27 /boot/initrd-4.9.11-1-default
-rw-r--r-- 1 root root 6,8M 18 feb 07.47 /boot/vmlinuz-4.9.10-1-default
-rw-r--r-- 1 root root 6,8M 21 feb 20.21 /boot/vmlinuz-4.9.11-1-default

Hi
I’m guessing your system is adding more hardware/kernel drivers into initrd…

If you run the command;


mkinitrd
ls -lh /boot/vmlinuz-* /boot/initrd-*
mkinitrd -A
ls -lh /boot/vmlinuz-* /boot/initrd-*

Any differences?

Maybe some device that is slow to respond. Got anything odd attached??

im curious -you have 1min 32.800s, systemd default time-out for non-responsive process is 90s.
are you saying there are no journal messages? and if not is there no way to get them (using directives)?

@malcolmlewis

Running “mkinitrd” without arguments doesn’t give me anything different from the previous scenario (If I’m not wrong, this is run every time a new kernel is installed).

After issuing “mkinitrd -A” the initrd size is noticeably increased,

ls -lh /boot/vmlinuz-* /boot/initrd-*
-rw------- 1 root root  47M 27 feb 10.13 /boot/initrd-4.9.10-1-default
-rw------- 1 root root  47M 27 feb 10.13 /boot/initrd-4.9.11-1-default
-rw-r--r-- 1 root root 6,8M 18 feb 07.47 /boot/vmlinuz-4.9.10-1-default
-rw-r--r-- 1 root root 6,8M 21 feb 20.21 /boot/vmlinuz-4.9.11-1-default

but the loading time is really improved now:

Startup finished in 8.597s (kernel) + 6.795s (initrd) + 37.128s (userspace) = 52.522s

@gogalthorp

No, I don’t have anything fancy attached; I’m using a laptop and the only additional device is a plain wireless mouse receiver; just to be sure I’ve tried to detach it before the boot, but it was not our guilty.

@ndc33

If you need more information I can provide anything that is required, just ask.

Hi
So if you run mkinitrd by itself again, back to slow startup?

Yes, exactly as before.

On Mon 27 Feb 2017 12:56:01 PM CST, sekhemty wrote:

Yes, exactly as before.

Hi
So the A option adds it all… A missing module, so no special grub
options…?

No journal messages about hardware? is all your hardware working?


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE Leap 42.1|GNOME 3.16.2|4.1.36-44-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!