1

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?

Kulfy
  • 17,416
  • 26
  • 64
  • 103

1 Answers1

0

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

kenn
  • 5,074
  • 12
  • 55
  • 94
  • thanks! I had to use `unmkinitramfs` and there is no conf/modules in the output, but found `/main/conf/modules` which contains the line. Boot however fails with the same error. some possibly relevant output [here](https://imgur.com/g5sOa2n) and [here](https://imgur.com/a/jA19FId). /dev/ram0 now exists, but still get the same `ALERT! /dev/ram0 does not exist. Dropping to a shell!` The exact line i added to `/etc/initramfs-tools/modules` is `brd rd_nr=1 rd_size=1048576 max_part=1` – Diederick C. Niehorster May 27 '19 at 10:59
  • You need to make filesystem on it and mount it https://askubuntu.com/questions/909740/how-to-load-a-ramdisk-now You can create a script and add it to `/usr/share/initramfs-tools/scripts/local-bottom/` or one of the proper one in that directory to create filesystem and mount it. Actually I don't have enough time to deal with it. – kenn May 27 '19 at 11:39
  • By the way, I didn't understand why you assigned `root=/dev/ram0` ? `root` parameter is for filesytem that OS resided in. – kenn May 27 '19 at 13:23
  • Thanks! I added a mount script to initramfs-tools/scripts/init-premount as i guess the drive needs to be created before its tried to be mounted. I do not see the output of this script as /var/log isn't available, but when i run it manually from shell, it errors on mkfs not being available. I am trying to boot to RAM, as its a PXE boot that is used as an imaging environment. I understood that initrd contents should become the /dev/ram0 contents by default, but guess thats not the case for this Ubuntu distro :p. I'm confused, perhaps trying the wrong thing completely for my problem. – Diederick C. Niehorster May 27 '19 at 14:37
  • the kernel arguments are as default by CloneDeploy and working for a standard(?) kernel as comes with CloneDeploy, i just swapped out the kernel and initrd images in the command – Diederick C. Niehorster May 27 '19 at 14:43
  • It's possible to move an entire filesystem into ram, load and run it, there is an example of it here https://github.com/arcmags/ramroot. It's also possible for ubuntu. But you confused things. As for `mkfs` command, you can check the dependencies of it and add it to `initrd` via another script. Check out this example hook `cat /usr/share/initramfs-tools/hooks/kmod` – kenn May 27 '19 at 15:21
  • I took a look at `CloneDeploy` boot line arguments, I think they use special `kernel` and `initrd` – kenn May 27 '19 at 15:42
  • Thanks for the further comments, given the trouble getting the ubuntu kernel to boot like this, i gave trying to get the NIC's firmware image into the initrd another try. Didn't work, turned out i needed to embed it in the kernel directly. All is working now, so i won't explore this route anymore. thanks again! – Diederick C. Niehorster Jun 01 '19 at 20:58