Page MenuHomeFreeBSD

Add a new flag to mkimg (-a num) to specify the active partition for those partitioning schemes that have this concept. Implement it as an override for mbr's setting 0x80 in the flags for the first partition when we have boot code.
ClosedPublic

Authored by imp on Dec 5 2015, 6:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 6:31 PM
Unknown Object (File)
Wed, Oct 30, 7:49 AM
Unknown Object (File)
Oct 5 2024, 5:48 PM
Unknown Object (File)
Oct 1 2024, 8:05 AM
Unknown Object (File)
Sep 30 2024, 1:31 AM
Unknown Object (File)
Sep 27 2024, 11:51 AM
Unknown Object (File)
Sep 24 2024, 2:31 PM
Unknown Object (File)
Sep 20 2024, 12:42 PM

Details

Summary

NanoBSD needs to build images that are bootable, but whose first partition isn't the one booting. To do that, I need an active flag for that partition. This patch adds one to mkimg and makes mbr use it. Don't know if other schemes have this notion, or if there's better terminology that could be used.

Enjoy.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp retitled this revision from to Add a new flag to mkimg (-a num) to specify the active partition for those partitioning schemes that have this concept. Implement it as an override for mbr's setting 0x80 in the flags for the first partition when we have boot code..
imp updated this object.
imp edited the test plan for this revision. (Show Details)

Seems reasonable to me

usr.bin/mkimg/mkimg.1
159–160 ↗(On Diff #10802)

Can 0 mean none are marked active?

usr.bin/mkimg/mkimg.1
149 ↗(On Diff #10802)

gpt has the concept too, and calls the flag "bootme". It's trickier with gpt because multiple paritions can have the flag set, and there's also a 'bootonce' flag.

usr.bin/mkimg/mkimg.1
149 ↗(On Diff #10802)

True. The code only support the MBR scheme. However, point taken.

159–160 ↗(On Diff #10802)

It would be a code change, but not a big one.

usr.bin/mkimg/mkimg.1
149 ↗(On Diff #10802)

Also a typo "concent," but the text should be rewritten anyhow to claim that mkimg only supports this with mbr instead of only mbr supports this.

159–160 ↗(On Diff #10802)

0 seems more reasonable to me as the special case than e.g. 99999

wblock added inline comments.
usr.bin/mkimg/mkimg.1
146 ↗(On Diff #10802)

This can be simplified, converted from passive to active, and reduced:

The
.Ar active
option marks a partition as active.
Use of this option is only supported with the
.Ar mbr
partitioning scheme.
151 ↗(On Diff #10802)

Typo/transposition. This should be .Nm.

153 ↗(On Diff #10802)

Between "normally" and "only", it is kind of hard to understand this. Doesn't it just mean "By default"?

By default,
.Nm
marks the first partition active when boot code is specified.
156 ↗(On Diff #10802)

"it" is nonspecific--does "active" override just the partition number, or the action of setting an active partition only when boot code is specified?

158 ↗(On Diff #10802)

Passive->active, and I'm not sure if the meaning of "1-based" will be clear.

MBR partition numbering starts at 1 and corresponds with the number
after the 's' in the partition device name (like ada0s1).
160 ↗(On Diff #10802)

Agreed. This is still not quite as clear as desired, but kind of going in that direction:

No partitions are set to active when the value is 0.

new diff coming...

usr.bin/mkimg/mkimg.1
149 ↗(On Diff #10802)

gpt only has this concept because FreeBSD has implemented these flags as an extension to gpt, which may be difficult to do programatically. So I'm not going to support it for now.

158 ↗(On Diff #10802)

1-based and 0-based are basic terms anybody reading this document would almost-certainly know.
However, reworded to avoid it.

160 ↗(On Diff #10802)

Sounds good. I changed it to marked active which sounds better to my ear.

imp edited edge metadata.

Fix issues found in the review.

Updating D4403: Add a new flag to mkimg (-a num) to specify the active partition for

those partitioning schemes that have this concept. Implement it as an
override for mbr's setting 0x80 in the flags for the first partition
when we have boot code.

marcel edited edge metadata.

LGTM

I've been thinking about encoding this with the partition specification (i.e. as part of the -p option), but the specification is cryptic enough as it is. Maybe when there's a different way of specifying partitions (say, using a JSON or YAML file given instead of a number of -p options), will it be easier to add a "bootme" attribute that translates into setting the active flag. For now, this is simple and it works...

This revision is now accepted and ready to land.Oct 18 2016, 4:58 AM
This revision was automatically updated to reflect the committed changes.
juan.molina_club.fr added inline comments.
head/usr.bin/mkimg/mkimg.c
149

s/partion/partition