Overlay FS for templates?

For almost any distribution, we have base OS template and a set of customized derivatives with custom sets of apps installed. Every single one is updated separately. Would an overlay system like UnionFS make this more handy?

2 Likes

Sounds like a good idea.

The base template would become easier swappable since you don’t have to change anything on it itself and could do it all in separate unionfs layers.

If implemented, you could manage your qubes and the unionfs layers as groups, assign a set of tools to the vms that need them.

The issues I see are that you would need to provide additional block devices - the layers - to each vm. If a user goes very granular, xen would need to add ~50 more devices to each vm. Don’t know how well that would work out.

The update process would need to be redesigned. You’d either need to boot into every layer version and update your apps there or have a new way that allows for a single update vm to chroot every version and do the updates.

Sounds like a lot of effort to do it right…

For your current situation, maybe use flatpak+appimages for very niche installs and allow for some unused apps in the template. That might allow you to get your template count down.

1 Like

I have been working on something similar (without UnionFS) for some time, however it seems more challenging than it appears. Package dependencies themselves can be quite complicated and with the additional complexity of updating package sets in a non-duplicating and non-breaking way it becomes a nightmare.

While I haven’t given up, I think we should probably consider something along these lines.

2 Likes

I think the trickiest part would be keeping package updates consistent across the layers, rather than the overlay mechanism itself.

Suppose a customized layer contains an older version of a library or overrides a configuration file. Updating the base template wouldn’t necessarily update what the derived template actually sees, because the upper layer could still mask the changed file.

That gets particularly important with security updates. You’d need a reliable way to determine which package versions are effectively installed in each derived environment, not just which updates have been applied to the base.

For the current use case, I wonder if a more practical approach would be to maintain one updated base template and use Salt states to reproduce the different customized templates from it.

It wouldn’t save as much disk space as a proper layered filesystem, and the variants would still need to be rebuilt or updated. But the configuration would be reproducible, and you could review exactly which packages and changes belong to each variant.

I like the general idea of layered templates. I’d just want a clear answer for package-manager state, file overrides, rollback and security updates before making the layers persistent.

2 Likes

Such layering increases both complexity and attack surface.

1 Like

I do not think either increases. If everything is kept up to date, it is no more complex than what we have now.

1 Like

How is it not more complex when you add things to it?

If you have these layers and the template has access to each one of them that directly increases attack surface compared to having each layer in a separate template.

Maybe I am missing something in your idea?

1 Like

Nope, in each template you have the whole structure of layers collapsed to one filesystem, making it harder to inspect. So it is a matter of discussion. It is more observable when layers are split.

1 Like

But how do you collapse it, so that the template/AppVMs cannot (under any circumstance) see the other layers? The filesystem itself is always controlled by the qube itself. If you can’t isolate the layers, using external control mechanism (Xen), it is still in-qube security and the more stuff you add inside, the larger the attack surface.

If I am still missing your point, please provide specific example of how you would do it.

1 Like

Do you need to, if none of layers except the topmost one are writable from the qube? My idea that management tasks that involve rebuilding / updating the layers are done outside of it. Just like docker does, separating immutable parts and code from the data.

1 Like

updates, mostly. update one core OS image instead of all templates individually, quickly see what extra apps are where and so on, better SBOMs and manageability improvements, less configuration drift when all changes are isolated.

1 Like

A vulnerable package can exists on a masked layer.

There are also things like:

1 Like

it is the opposite: on a masked layer it is detectable, but not exploitable. but overlayfs surely may have bugs by itself.

1 Like