Ubuntu – 18.04.2 load initrd into ramdisk

bootinitramfs

I am trying to create a PXE boot kernel for CloneDeploy. I have a NIC that needs some drivers that do not work out of the box, but work fine on an Ubuntu install, so I thought's I'd simply PXE boot using the kernel and initrd that i boot my Ubuntu from (being not very Linux-savvy I can't think of a much better way to do things, attempts to build my own kernel have failed to yield a working NIC).

I am running an up-to-date 18.04.2 install. So I copied the files:
vmlinuz-4.18.0-20-generic and initrd.img-4.18.0-20-generic
to the right places of my PXE system, and try to boot from them.

This is the (ipxe) boot command line (with locations of images shortened to keep things legible):

kernel http://.../IpxeBoot?filename=vmlinuz-4.18.0-20-generic&type=kernel initrd=initrd.img-4.18.0-20-generic root=/dev/ram0 rw ramdisk_size=1560000  web=http://.../ USER_TOKEN= task=debug consoleblank=0 
imgfetch --name initrd.img-4.18.0-20-generic http://.../IpxeBoot?filename=initrd.img-4.18.0-20-generic&type=bootimage
boot

When booting, a bunch of relevant devices get initialized (including my NIC!) but then I run into the following error:

gave up waiting for root file system device
ALERT! /dev/ram0 does not exist. Dropping to a shell!

I have found this question, which suggests i need to do an extra step during boot somewhere to get the brd module to load and get the initrd to be turned into an actual usable ram disk. It was suggested to add "brd rd_size=16777216" to /etc/initramfs/modules, but when i unpack the initrd.img-4.18.0-20-generic file (using unmkinitramfs), there is no /etc/initramfs. (I also note i should probably use rd_nr=1 rd_size=1048576 to only have ram0 created instead of ram0 through ram15).

How do i get past the boot error. And if that involves loading brd, how do i do that for this kernel version?

Best Answer

Initial ramdisk (in your case it is initrd.img-4.18.0-20-generic) is generated by update-initramfs tool automatically during kernel installation into your system.

update-initramfs checks out your system and adds required modules into initrd to load it during boot.

There are two locations where you can put your scripts for initial ramdisk:

/usr/share/initramfs-tools

and

/etc/initramfs-tools 

In your case you must insert that line into /etc/initramfs-tools/modules and run

update-initramfs -u

for your current kernel.

Then check out the result:

mkdir myinitramfs

cd myinitramfs

zcat /boot/initrd.img-4.18.0-20-generic | cpio --extract

cat conf/modules

check if your module is in the list

Related Question