tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Support for disk images when loading ramdisks



		Hi tech-kern@,

For the purposes of smolBSD (https://smolbsd.org <https://smolbsd.org/>) and as presented
together with iMil@ (Cc’d here) during FOSDEM 2026
(https://fosdem.org/2026/schedule/event/BGPF3M-smolbsd/), I have written
a first patch supporting disk images when loading ramdisks: the code
looks for the presence of a GPT header in the second block (offset 512),
looks for the first partition marked with the "bootme" attribute, and
then uses this partition as the actual ramdisk filesystem.

It only adds this capacity when booting amd64 platforms in generic PVH
mode so far. However, it seems to me that this could also be useful in
at least two aspects:
- Saving disk space in NetBSD releases,
- Providing users with ready to use disk images.

I believe that distributing bootable disk images instead of filesystem
images is easier to handle for users, e.g., when flashing USB drives or
setting up virtualised environments. It would also be less confusing to
provide a single works-everywhere file for e.g., rescue operations,
usable as a virtual disk image or directly as a ramdisk. The memory cost
is just a few kilobytes of unused, unreclaimed memory. (The EFI/GPT
headers)

Your feedback is welcome about this capability; with a sufficient
consensus I could look into extending this patch for more situations and
platforms.

Also note that the generic PVH specification allows for parameters to be
assigned for each and every module provided at boot time; this could
allow different selection mechanisms for the partition to boot. (e.g.,
NAME=…)

Anyhow, you can find this work in the khorben/ramdisk-gpt branch of our
NetBSDfr/NetBSD-src GitHub fork, at:
https://github.com/NetBSDfr/NetBSD-src/tree/khorben/ramdisk-gpt


The corresponding diff is attached here as well.

Attachment: 0001-x86_machdep.c-support-ramdisk-filesystems-on-GPT.patch
Description: Binary data


Cheers & HTH,
-- 
khorben

Attachment: signature.asc
Description: Message signed with OpenPGP



Home | Main Index | Thread Index | Old Index