Page MenuHomeFreeBSD

nanobsd: Fix NANO_MD_BACKING_SWAP md issues
Needs ReviewPublic

Authored by jlduran on Sun, May 17, 7:47 AM.

Details

Summary

There were a series of issues preventing the use of a swap-backed memory
disk in NanoBSD.

First, to create a memory disk using "-t swap", the size must align to a
valid geometry, otherwise the operation fails with:

mdconfig: ioctl(/dev/mdctl): Numerical argument out of domain

The value used for the size did not include the MBR sectors needed for a
valid CHS geometry. Fix this by adding them when creating the md
device.

When adding the freebsd-ufs partition inside the code slice, explicitly
set the size to the CODE_SIZE minus the 16 sectors that bsdlabel(8) (now
gpart(8)) used as an offset, which are reserved for metadata.

Finally, when issuing the final dd operation that writes the contents of
the rounded-up swap-backed memory device to the image file, trim the
size to CODE_SIZE in order for it to fit the full image accordingly.

Test Plan

Angshuman, please test this stack of patches. You should now be able to use a swap-backed memory device to build amd64 images.
Remember to set:

NANO_MD_BACKING=swap
NANO_IMAGE_MBRONLY=

in your configuration file.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 73156
Build 70039: arc lint + arc unit