Score:1

Using a compressed initrd when pxe booting

us flag

I'm using netboot/pxeboot with grub.

menuentry "Install Ubuntu 20.04" {
  set gfxpayload=keep
  echo 'Loading vmlinuz ...'
  linux  /tftp/vmlinuz ip=dhcp netboot=nfs nfsroot=10.0.0.20:/data/netboot/nfs/ubuntu2004/ boot=casper toram noquiet splash=off console=tty0 console=ttyS1,57600n8 ---
  echo 'Loading initrd, this takes a long time ...'
  initrd /tftp/initrd
}

It works fine, however, the loading of initrd over tftp is taking a long time (30+ minutes). I would like to compress (gz/bz2) this file to save on some file transfer time.

I had seen some examples out there referring to a initrd.gz (One example: https://unix.stackexchange.com/questions/217002/which-iso-file-vmlinuz-and-initrd-gz-to-use-for-installing-centos-from-multiboo) but when I tried to just compress the file with gzip and use it, I get an error such as:

[   12.543547] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[   12.558487] Please append a correct "root=" boot option; here are the available partitions:
[   12.575161] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Is there a way to compress this file so it can transfer a smaller file size, and have it uncompress before it tries to mount the root fs?

Alternatively, is there a way to transfer it over a different protocol (HTTP/FTP/SFTP/SCP/etc) ?

in flag
You could use xz or any other compression, even if grub does not decompress the file, the kernel can do the decompression as long as it has those options enabled. I always recommend http, not sure if grub has gotten such support, my goto solution is iPXE. (as you already seem to be using, I would avoid NFS)
Score:1
us flag

@Pat's answer is accepted and more detailed, however here are the direct answers to the original questions:

Is there a way to compress this file so it can transfer a smaller file size, and have it uncompress before it tries to mount the root fs?

No, it's already compressed. The accepted answer gives an example of this.

Alternatively, is there a way to transfer it over a different protocol (HTTP/FTP/SFTP/SCP/etc) ?

Not with regular PXE. Use another network boot system, like iPXE, which allows http/nfs

Score:1
za flag
Pat

An initrd is a compressed CPIO structure created from a file tree structure with a command like:

find . | cpio -o -c -R root:root | gzip -9 > /boot/new.img

The ubuntu-20.04-desktop-amd64 initrd is already compressed and weights about 87MB. TFTP transfer of that file should be around 36 seconds.

[04/05 08:17:46.445] TFTP Inf: <\NWA_PXE\ubuntu-20.04-desktop-amd64\casper\initrd>: sent blks=63901 blkSz=1408, Total 89971296 bytes in 36s, err recovery=0 

If your TFTP transfer takes half an hour you have a different problem in your network-TFTP setup. A Wireshark traffic capture can help you to pin point your issue.

Rino Bino avatar
us flag
I ended up just using iPXE with nfs protocol enabled. NFS transferred it in seconds. Unfortunately there is no tuning params for TFTP other than block size (which was already tuned) and it runs over udp which doesn't play nice in my setup over a vpn. I'll accept this as the answer but I'll put another answer down which answers the questions directly.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.