On Sun, Jun 15, 2025 at 03:35:17PM +0100, Harald van Dijk wrote:
> On 15/06/2025 14:48, Alexey Gladkov wrote:
> > If a mounted image is used as root, overlayfs is typically used to
> > provide write access. In this case, it is safe to execute switch_root.
> 
> But when overlayfs is used, this does not guarantee that it is safe, and 
> does risk the exact sort of destructive behaviour that is meant to be 
> protected against. It's only safe with specific uses of overlayfs.

Hm. The overlayfs by design does not allow you to change lower layers.
Also, the filesystem does not propagate changes to lower layers.

In which case if the whole overlayfs root can it be dangerous to do
remove a root content ?

> util-linux's version of switch_root does the same ramfs/tmpfs check that 
> busybox does, but reacts to it differently: rather than exiting with an 
> error for other file systems, it simply prints a warning and carries on 
> without removing any files. Would doing that instead in busybox too be 
> enough to work for your use case?

Yes, it will absolutely be better than a fatal error. I'm using
switch_root in initramfs and of course I'd like to clean up root, but this
way at least I can use switch_root from busybox.

Is it possible to add an option to delete content from root ?

-- 
Rgrds, legion

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to