Page MenuHomeFreeBSD

nanobsd: Add a NO_ROOT build option
ClosedPublic

Authored by jlduran on Feb 1 2025, 4:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 19, 10:08 PM
Unknown Object (File)
Sat, Jan 17, 8:50 PM
Unknown Object (File)
Mon, Dec 22, 11:15 PM
Unknown Object (File)
Nov 30 2025, 11:19 AM
Unknown Object (File)
Nov 28 2025, 6:32 PM
Unknown Object (File)
Nov 25 2025, 7:53 PM
Unknown Object (File)
Nov 10 2025, 9:04 AM
Unknown Object (File)
Oct 29 2025, 4:00 AM
Subscribers
None

Details

Summary

Add a -U option to build NanoBSD images without root privileges. It
relies on makefs/mkimg and metalog (mtree) files, similar to what
release engineering uses to build images.

Keep the current way to build NanoBSD images untouched. Once this
method gets battle tested, it may be used to build images as root as
well.

TODO:

  • Unify a tgt_echo function that does echo and writes to the metalog?
  • Gather suggestions regarding metalog handling. Specifically debate makefs -F vs. makefs <metalog last argument>
Test Plan
  1. The default, two (almost) identical code slices:

    $ sh nanobsd.sh -U
  1. Two code slices, with the second code slice zeroed (better compression):

    $ mkdir -p ~/nanobsd/test $ echo "NANO_INIT_IMG2=0" > ~/nanobsd/test/config.nano $ sh nanobsd.sh -U -c ~/nanobsd/test/config.nano
  1. A single code slice (no ping-pong):

    $ mkdir -p ~/nanobsd/test $ echo "NANO_IMAGES=1" > ~/nanobsd/test/config.nano $ sh nanobsd.sh -U -c ~/nanobsd/test/config.nano
  1. An image with a custom media size:

    $ mkdir -p ~/nanobsd/test $ echo "NANO_MEDIASIZE=16000000" > ~/nanobsd/test/config.nano $ sh nanobsd.sh -U -c ~/nanobsd/test/config.nano

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jlduran created this revision.

I think it's better if I split this commit further, to make it easier to review.

What do you think about a subsequent change to remove the non--U code, and always use the NO_ROOT mode? @imp?

What do you think about a subsequent change to remove the non--U code, and always use the NO_ROOT mode? @imp?

Love the idea

This revision is now accepted and ready to land.Apr 10 2025, 12:52 AM
This revision was automatically updated to reflect the committed changes.