Re: systemd-repart help requested please

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

 



On Mo, 03.10.22 22:04, bleat@xxxxxxx bleat@xxxxxxx (bleat@xxxxxxx) wrote:

> Greetings to you all,
>
> I read through this
> https://0pointer.net/blog/fitting-everything-together.html, several
> times and was inspired to try build this
> https://0pointer.net/blog/images/partitions.svg, as an exercise to
> help me learn.
>
> I've got this https://gitlab.com/baaash/aio/-/blob/main/aio.org so
> far.  (probably worthy of a chuckle for some, but we all start
> somewhere right?)
>
> anyways, when I do a:
>
>     sudo mkosi
>
> the image builds fine.  cool.
>
> when i boot into with systemd-nspawn I see no such growing of
> partitions, and furthermore am prompted to enter a new root
> password.

systemd-nspawn will boot the image for you. It will mount the file
systems in the image first, and it will issue the fsgrow ioctls on the
mounted file systems if that's requested in the GPT partition
flags. But it will *not* grow the partitions, that's what systemd-repart
can do for you. You may use the "--image=" switch to invoke it
directly on the disk image. You can also specify "--size=" to grow the
image file on disk first. (this will work only if you have some
suitable /usr/lib/repart.d/ drop-ins in place that tell repart what to
actually grow)

So, if you build an image with mkosi, you could then grow/complete it
with systemd-repart, and then boot it up with nspawn, and things
should just work.

> The password thing I assume is because I need to remove the
> reference in mkosi, and pass this to systemd-nspawn, as described in
> the systemd.firstboot man page...[edit:confirmed], But the repart
> thing has me stumped.

you can either provision a root pw:

1. in mkosi via the mkosi.rootpw file
2. at first boot by padding in a credential via nspawn's new
   --set-credential=passwd.hashed-password.root:… switch
3. at first boot interactively via systemd-firstboot.

the systemd-firstboot stuff is done only on first boot, and if no root
pw has been configured yet. First boot is defined by whether
/etc/machine-id being initialized or not. Recent mkosi versions will
ensure that file is reset properly ensure this works. (in fact, for
now I'd recommend working with git versions of mkosi)

> Asking in IRC it was pointed out systemd-repart should just work
> automatically provided the partition info was sitting in
> /usr/lib/repart.d directory, but that it needs no MachineID set in
> order to qualify as "first.boot".

Correct.

> I don't have one set but one is being created in the process.  I'm
> missing a piece to this puzzle.
>
> my eyes burn, my head hurts, and i'm no closer to understanding
> this, so i wondered if anyone on the list can succinctly explain
> this to me or perhaps provide a link to a basic working example i
> can try get my head around; provided of course, someone has already
> undertaken this exercise on their own, and wouldn't mind sharing.

Happy to help!

We should probably open a group chat somewhere for people who want to
build images like that. Since I am usually at home in Signal for
things like that, maybe we should open a chat room there for that?

(nah, not an IRC fan, not gonna return there, sorry)

Lennart

--
Lennart Poettering, Berlin



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux