[x86/64] Request official release of the initramfs-kernel

Today I was looking for the OpenWrt x64 initramfs-kernel for my need. Surprisingly it's not on the official release page. And I found out that it cannot be made using the Image Builder either. So I have to pull all the code, turn on the TARGET_ROOTFS_INITRAMFS knob, and compile it for myself.

So may I ask the dev folks to add the x86/64 initramfs-kernel in the build process so it appears on the official release page? And also on the online builder page?

Why do I want this?

Because it would be cool to have a Linux live system that runs entirely from a single kernel file (or plus an initrd), yet has the ability to add package from a reasonably rich software repo. It's a handy toolbox to do maintenance work. For instance I use it in a cloud VM to fetch and kexec another kernel.

Regular Linux live distros rely on a squashfs file as a backing store. Even Alpine Linux needs a "modloop" file sitting somewhere. So you have to prepare a disk and install them. With the imagined initramfs-kernel release, people can simply grab the file from the website, feed it to a bootloader, and voila!

How to change?

After some digging, I come up with this patch.

diff --git a/target/linux/x86/Makefile b/target/linux/x86/Makefile
index 5368a779e5..f105ae8dbd 100644
--- a/target/linux/x86/Makefile
+++ b/target/linux/x86/Makefile
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=i386
 BOARD:=x86
 BOARDNAME:=x86
-FEATURES:=squashfs ext4 vdi vmdk vhdx pcmcia targz fpu boot-part rootfs-part
+FEATURES:=squashfs ext4 vdi vmdk vhdx pcmcia targz fpu boot-part rootfs-part ramdisk
 SUBTARGETS:=generic legacy geode 64

 KERNEL_PATCHVER:=5.15

With the patch, the initramfs-kernel file appears in bin/targets/x86/64. But it does not appear when I build again using the resulting imagebuilder.

I am also not sure whether it would appear on the official release page and https://firmware-selector.openwrt.org with that single line patch.

Any suggestions? Many thanks!

good dea, but doesn't booting vanilla openwrt from an USB flash drive give you the same thing, plus save the packages you install, while it's running ?

It's not the same. One doesn't always have a USB drive at hand. In some situations it's impossible to plug a new drive to a machine, such as a VM in the cloud.

The point is that with the initramfs-kernel you don't have to install. You just boot the single file loaded from anywhere - local hard drive, USB drive, or even a web server.

The default image will boot just fine in a VM, without needing a usb drive.

You can also bootp or tftp boot it easily.

I’m not seeing what the use case would be for an initramfs image on x86 or x64. Sure it would be immutable, but what does that give you?

1 Like

The default image will boot just fine in a VM, without needing a usb drive.

Again, you have to install (i.e. dd of=/dev/sda) it first (Edit: which is sometimes not doable or not desirable).

You can also bootp or tftp boot it easily.

I don't understand how. The official x86/64 releases do not provide an initramfs-kernel or an initrd. Could you kindly explain how to do it?

One usage example:

Let me give one scenario where the proposed initramfs-kernel is useful.

You have a cloud VM with Debian installed. One day you decide to shrink the ext4 rootfs partition, which cannot be done online. The cloud provider does not support any boot device other than the only virtual hard disk. And you want to keep this Debian and no reinstall.
Here's what you can do with the proposed initramfs-kernel:

  • In the running Debian, download the initramfs-kernel to /boot/efi. Note that download link does not exist yet.
  • Connect to the VNC or serial console, wait for the grub menu to appear and press C key.
  • In the grub shell, type in linux (hd0, gpt1)/openwrt-23.05.3-x86-64-generic-initramfs-kernel.bin; boot.
  • Later in the OpenWrt console, execute opkg update && opkg install resize2fs sgdisk.
  • Do the shrink.
  • Reboot to Debian.

Did you try it? Virtualbox or qemu will happily accept the ext4 image.
It’s literally an installed openwrt image - that’s why you can dd it to a drive and boot from it.

Virtualbox or qemu will happily accept the ext4 image.

That does work when you are able to hand the image to the VM manager.

But many cloud providers do not allow you to add or change the underlying virtual disk file. You either dd inside the VM or reinitiate with a new stock OS image (selected from a list provided by the cloud provider - Debian/Ubuntu/Arch/.etc).

When you work with a physical machine and do not have a spare USB drive at hand, it's the same story.

Then you have the same issue with an initramfs image.
I’m not seeing what you are going to accomplish

See the example I just gave above.

Have you tried submiting a github MR with this patch?

I have not.

As I said, that patch appears to not work when using imagebuilder. So I thought to ask here for help.

I just found out that imagebuilder and firmware-selector.openwrt.org simply do not support building/customizing initramfs-kernel for all targets in general, not just x86.

Several additional files (particularly build_dir\target-x86_64_musl\linux-x86_64\bzImage-initramfs) do appear in the imagebuilder tarball after applying the one line patch though.

So I guess i'm going to submit that patch to github, as a first step. Persuing for customizing initramfs-kernel with imagebuilder and firmware-selector.openwrt.org is a separate issue.

1 Like