1

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) ?

Rino Bino
  • 511
  • 5
  • 21
  • 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) – NiKiZe Apr 12 '22 at 14:32

2 Answers2

1

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.

Pat
  • 3,519
  • 2
  • 17
  • 17
  • 1
    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. – Rino Bino Apr 05 '22 at 15:41
1

@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

Rino Bino
  • 511
  • 5
  • 21