6

I'm reading up on Wake on Lan on Debian wiki and there is a part that says:

If your kernel uses an initramfs image (eg. Debian stock kernels), also run update-initramfs -u (or update-initramfs -u -k all if necessary) to rebuild kernel initial ramdisk(s).

How do I determine if my kernel uses initramfs?

I installed LMDE v2, 64-bit, Mate.

linstar
  • 753
  • 5
    Your computer boots. – mikeserv Jun 22 '15 at 02:50
  • 1
    "Your computer boots" - true for most mainstream distros, but not universally true. I had a gentoo box with no initrd/initramfs for a decade and it worked flawlessly. Of course this limits the choices around filesystem, encryption, lvm etc. But it is still seen in the wild. – AtomHeartFather Feb 15 '22 at 13:29

3 Answers3

4

While terse, mikeserv is essentially correct - Linux has used initramfs for a long time, since the 2.6 days. If you use GRUB (which, assuming you have a default LMDE installation, you do), then checkout /boot/grub/grub.cfg:

$ grep initr /boot/grub/grub.cfg 
    initrd  /boot/initrd.img-3.13.0-53-generic
    initrd  /boot/initrd.img-3.13.0-53-generic
    initrd  /boot/initrd.img-3.13.0-52-generic
    initrd  /boot/initrd.img-3.13.0-52-generic
    initrd  /boot/initrd.img-3.13.0-24-generic
    initrd  /boot/initrd.img-3.13.0-24-generic

Even though the name is initrd, it is an initramfs archive, which you can test by virtue of initramfs being a CPIO archive:

$ file - < /boot/initrd.img-3.13.0-24-generic
/dev/stdin: gzip compressed data, from Unix, last modified: Tue Sep 30 20:07:43 2014
$ gunzip < /boot/initrd.img-3.13.0-24-generic | file -
/dev/stdin: ASCII cpio archive (SVR4 with no CRC)

(The name for the initramfs image is distro-dependent. Arch Linux, for example, simply calls it initramfs-linux.img.)

muru
  • 72,889
  • 2
    It's not just typical - initramfs is a filesystem. The image which accompanies most kernels is unpacked into that fs at boot. If there is no external image file, then it is because the required image has been compiled into the kernel itself. In both cases the kernel mounts its first root as an initramfs at boot. This has been the case since the 2.6 kernel series - it is a requirement for every linux kernel since. – mikeserv Jun 22 '15 at 04:15
  • @mikeserv Odd. Everything I've read (https://wiki.ubuntu.com/Initramfs, https://wiki.debian.org/initramfs/More, https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt) seems to indicate that the primary quality of initramfs is that it is not a filesystem image, unlike initrd. Probably just a technical difference. – muru Jun 22 '15 at 04:17
  • 2
    Well. Yes and no - it's not an image of a filesystem, because initramfs is one whereas the initrd is a filesystem image laid down on a ram disk - a block dev. But initramfs is basically tmpfs - it's fs cache incarnate - so there's no underlying block layer at all, and the initramfs image (or archive may be more correct to say) can just be a simple cpio stream archive. But my point was that external archive/image file or no - initramfs is not optional. – mikeserv Jun 22 '15 at 04:22
  • @mikeserv Done. But in case the initramfs is compiled into the kernel, how do we detect it? – muru Jun 22 '15 at 04:34
  • 1
    Detect it? I guess you wouldn't - unless you stuck a debugger in there and did like init=bin/gdb on the kernel commandline. It's there though - it's the kernel's first root every time. See this for the whole story. – mikeserv Jun 22 '15 at 04:36
  • @mikeserv this seems to search the decompressed kernel for some kinda signature to extract the cpio archive. – jiggunjer Jan 24 '17 at 06:55
  • that's too much x86 centric. doesn't work on mips, arm, even x86 qemu, and every system that doesn't use grub. – Eric Sep 11 '19 at 08:35
1

Almost all Linux desktop uses initramfs at least with default configuration including LMDE v2 and initramfs feature is kernel inbuilt.

Some OS like Slitaz and many embedded system OS like OpenWRT do not use initramfs image, they skips the initramfs image during boot, by a kernel boot argument noinitrd. you can check it at your bootloader(GRUB) menu or after booting, run

cat /proc/cmdline if you see a noinitrd word then it do not use initramfs image. There is a near 100% chance you will not see noinitrd word.

Arnab
  • 1,581
0

If an initramfs (or initrd for that matter) has been used during boot, the logs should have a bunch of initrd related entries.

Examples from my Arch Linux box:

$ sudo dmesg -T | grep "initrd"
[Tue Feb 15 12:58:58 2022] Freeing initrd memory: 31360K

or, using journalctl

$ journalctl -b --no-hostname | grep "initrd"                                                                                                                                                                                                                                                                                                                          
Feb 15 12:58:22 kernel: Freeing initrd memory: 31360K
Feb 15 12:58:29 systemd[1]: initrd-parse-etc.service: Deactivated successfully.
Feb 15 12:58:29 systemd[1]: initrd-cleanup.service: Deactivated successfully.
Feb 15 12:58:29 systemd[1]: initrd-udevadm-cleanup-db.service: Deactivated successfully.
Feb 15 12:58:30 systemd[1]: initrd-switch-root.service: Deactivated successfully.
Feb 15 13:00:00 systemd[1]: Startup finished in 16.502s (firmware) + 5.955s (loader) + 751ms (kernel) + 7.451s (initrd) + 1min 30.238s (userspace) = 2min 900ms.