FS#66804 - [linux] pmem support for webboot

Attached to Project: Arch Linux
Opened by Daniel Maslowski (cyrevolt) - Wednesday, 27 May 2020, 22:32 GMT
Last edited by Andreas Radke (AndyRTR) - Wednesday, 27 January 2021, 15:49 GMT
Task Type Feature Request
Category Kernel
Status Closed
Assigned To Tobias Powalowski (tpowa)
Jan Alexander Steffens (heftig)
Levente Polyak (anthraxx)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

With LinuxBoot and u-root, there is a new, more auditable approach to bootloaders in firmware. One of these is webboot, which allows for booting live ISO images, given that the kernel to boot is configured with pmem support. It can be used for recovery, installation, or a stateless system, just like a live USB stick.

The webboot bootloader works roughly as follows:

- connect to a network, download an ISO image
- copy the ISO to RAM, loopback mount it
- kexec the ISO's kernel, append `memmap=$SIZE!$SIZE root=/dev/pmem0`

For the config for Arch, see https://github.com/u-root/webboot/blob/master/webboot/webboot.go#L94

As a PoC, we have successfully taken TinyCore, rebuilt the kernel with pmem support, remastered the ISO, and could just boot into it. We could also fetch the live ISO images of various distros and boot into them; however, we needed to use a different kernel, because none of the distro kernels so far supports pmem by default. Research notes are here: https://github.com/u-root/webboot/blob/master/distros.md#distributions-of-linux-based-systems

To add pmem support, only a little change is necessary:
```
CONFIG_X86_PMEM_LEGACY_DEVICE=y
CONFIG_X86_PMEM_LEGACY=y
CONFIG_BLK_DEV_PMEM=y
CONFIG_ARCH_HAS_PMEM_API=y
```
Note that these cannot be modules, because the modules wouldn't be available before the ISO.

See also: https://github.com/u-root/webboot/#solutions
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Wednesday, 27 January 2021, 15:49 GMT
Reason for closing:  Implemented
Additional comments about closing:  29-1. NVDIMM modules are included in the initramfs by the block hook.
Comment by Jan Alexander Steffens (heftig) - Wednesday, 27 May 2020, 23:40 GMT
This sounds like it should be solved by putting the modules into the ISO's initramfs.
Comment by Daniel Maslowski (cyrevolt) - Wednesday, 27 May 2020, 23:45 GMT
Yea right, that's the option I forgot to list, sorry for that. Thank you! :)
Comment by Daniel Maslowski (cyrevolt) - Saturday, 30 May 2020, 04:54 GMT
The corresponding modules are `nd_btt`, `nd_e820` and `nd_pmem`, found in `/lib/modules/$KERNEL/kernel/drivers/nvdimm/`.

I've remastered an ISO by just adding the three files via `mkinitcpio.conf`, based on https://git.archlinux.org/archiso.git/tree/configs/releng/mkinitcpio.conf.

Here is a recording of the PoC in action: https://mastodon.social/@CyReVolt/104255555469684347
Comment by Daniel Maslowski (cyrevolt) - Saturday, 30 May 2020, 12:54 GMT
I've submitted a corresponding patch to add the modules: https://github.com/archlinux/mkinitcpio/pull/30

That allowed me to successfully remaster a SystemRescueCd ISO and boot it.

Just adding the hook to https://gitlab.archlinux.org/archlinux/archiso/-/blob/master/configs/releng/mkinitcpio.conf at the end suffices.

Demo: https://mastodon.social/@CyReVolt/104257269439262783

Loading...