bootc icon indicating copy to clipboard operation
bootc copied to clipboard

Injecting configuration files after installation, before first boot

Open jmpolom opened this issue 1 year ago • 6 comments

How does one inject a configuration file post bootc install but before the first system boot? A customized /etc/fstab is a good example or perhaps some systemd mount units. With a non-ostree system when the installation chroot is setup this is a straightforward copy operation. bootc should document this process a bit better or provide a more convenient method as it will be a common need to drop some configuration files in place post install but before the system boots for the first time. Not everyone will want to adopt ignition to do these tasks.

jmpolom avatar May 15 '24 00:05 jmpolom

bootc should document this process a bit better or provide a more convenient method

See https://github.com/containers/bootc/pull/267 for a more convenient method. We are indeed in a relatively inconsistent situation where e.g. Anaconda allows this, but bootc-image-builder and bootc install don't in any kind of direct way; the above PR helps.

Not everyone will want to adopt ignition to do these tasks.

Yes, agreed.

cgwalters avatar May 15 '24 00:05 cgwalters

I gathered there was divergent functionality here and this was not really supported now. What is the present day workaround?

~~What is going on in your PR with let target_etc = root.open_dir("etc").context("Opening deployment /etc")?;? Are you effectively just grabbing the etc directory of the ostree deployment in sysroot?~~ figured this out for myself.

As for a workaround, should I just dump stuff into <physroot>/ostree/deploy/default/deploy/<hash>/etc/? What I've come up with to use in a script with a filesystem install to get to this location: ostree admin status | head -n 1 | cut -d ' ' -f 3 -

jmpolom avatar May 15 '24 02:05 jmpolom

As for a workaround, should I just dump stuff into <physroot>/ostree/deploy/default/deploy/<hash>/etc/? What I've come up with to use in a script with a filesystem install to get to this location: ostree admin status | head -n 1 | cut -d ' ' -f 3 -

ostree admin status --sysroot=<wherever sysroot is mounted> ~~doesn't work right after install as it reports~~ works only if the boot partition is mounted otherwise it reports No deployments. It looks like ostree rev-parse --repo=<wherever sysroot is mounted>/ostree/repo ostree/1/1/0 could work if boot isn't mounted for some reason.

It would be a much more pleasant experience if bootc install subcommands could cleanly output this bit of info. It is present internally.

jmpolom avatar May 16 '24 21:05 jmpolom

ostree admin status --sysroot= doesn't work right after install as it reports No deployments.

It's almost certainly because you have a distinct /boot filesystem which isn't mounted, and ostree uses the bootloader configs as source of truth.

cgwalters avatar May 17 '24 12:05 cgwalters

ostree admin status --sysroot= doesn't work right after install as it reports No deployments.

It's almost certainly because you have a distinct /boot filesystem which isn't mounted, and ostree uses the bootloader configs as source of truth.

This is exactly what the issue was. The documentation for ostree admin status does not indicate it pulls data from /boot, however. I wrongly presumed it inspected the repository somehow.

jmpolom avatar May 17 '24 23:05 jmpolom