Automate an additional entry in grub.cfg

OK, so I've successfully transitioned to Arch, because...reasons, and want to keep my Manjaro install for a while. Arch GRUB has control now; this has to do with booting Manjaro, so I'm asking here, instead of the Arch forums. And no, I'm NOT going to use grub-customizer...so please don't even bother to recommend it.

Anyway...

The Arch os-prober successfully detects and adds entries for Manjaro in grub.cfg. Here's what's written:

menuentry 'Manjaro Linux (18.0.4) (on /dev/nvme0n1p3)' --class manjarolinux --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-0f2b8c18-6181-4a8a-a2f4-4509dca06afc' {
	insmod part_gpt
	insmod ext2
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  de418e92-03de-4d58-aa0d-1ea30a36658c
	else
	  search --no-floppy --fs-uuid --set=root de418e92-03de-4d58-aa0d-1ea30a36658c
	fi
	linux /vmlinuz-5.2-x86_64 root=UUID=0f2b8c18-6181-4a8a-a2f4-4509dca06afc rw quiet net.ifnames=0 nowatchdog acpi_enforce_resources=lax sysrq_always_enabled=1 scsi_mod.use_blk_mq=1 audit=0
	initrd /intel-ucode.img 
}

Along with the associated 'Advanced Options' entries.

In order to boot Manjaro, the 'initrd' line needs to be this:

initrd /intel-ucode.img /initramfs-5.2-x86_64.img

Is there any way to automate adding the /initramfs-{kernel_version}.img during grub.cfg generation, without touching the fallback /initramfs-{kernel_version}-fallback.img entries, or am I just plain stuck manually editing grub.cfg?

Thanks...

I thought the latest grub version would be capable of using two initrd.
Apart from this question:

  • Use a custom entry for Manjaro at /boot/grub/custom.cfg with "configfile" aiming Manjaro grub.cfg (look for gohlip's tutorial)
    Or
  • Create a bash script to run after update-grub, to check and edit grub.cfg

(Without modification), only Manjaro's grub can boot manjaro OS.
Our grub is wonderful.

You thought wrong. To do the 2 initrd files, there has to be some extra lines at /etc/default/grub.
And even so, that won't make other OS's entry with 2 initrd .

I hadn't done my homework. Can you share yours?
How does it work?

PS:

Ha! That was a secret message calling you:wink:

The line is GRUB_EARLY_INITRD_LINUX_STOCK. From the wiki...

GRUB_EARLY_INITRD_LINUX_STOCK

List of space-separated early initrd images to be loaded from ‘/boot’. This is for loading things like CPU microcode, firmware, ACPI tables, crypto keys, and so on. These early images will be loaded in the order declared, and all will be loaded before the actual functional initrd image.

‘GRUB_EARLY_INITRD_LINUX_STOCK’ is for your distribution to declare images that are provided by the distribution. It should not be modified without understanding the consequences. They will be loaded first.

GRUB_EARLY_INITRD_LINUX_CUSTOM’ is for your custom created images.

The default stock images are as follows, though they may be overridden by your distribution:

intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode.cpio

But grub is not os-prober. And it says nothing about setting other OS's with 2 initrd files.
Our (modified) manjaro os-prober checks for other OS's with intel-ucode and amd-ucode and puts them into the grub.cfg. Has been like this before 2.04 (since intel-ucode).

See, our grub is wonderful.
You can download upstream grub 2.04, install it. But you will need to play with /etc/default/grub.

3 Likes

Arch upgraded to 2.04 a couple of days ago...

:slight_smile:

We'll see; might make an interesting project.

Thanks, guys.

1 Like

/boot/grub/custom.cfg

You could just put the working entry there? Of course, you would need to add another entry when adding kernels, but still easier than editing grub.cfg?

This is what Arch is adding to detect their initramfs files. On Manjaro we have that. However, grub is not the problem here. It is os-prober instead. Arch is missing at least this patch.

4 Likes

On the 4th post of this topic, there are several ways the entries can be put into custom.cfg. @AgentS has pointed out the configfile entry and that would be a very good entry for the OP's intention. It does not need to be revised with any kernel addition, change or deletion as it just use that OS grub.cfg (which change with kernel). I use multiboot to test OS's grub; and my own grub that I normally use to boot all OS's use the direct boot (direct to kernel) method. Chainload is messy and unreliable.

Hope this explains.

3 Likes

Forum kindly sponsored by Bytemark