On Mon, Jun 16, 2025 at 03:21:47AM +0800, Kang-Che Sung wrote:
> On 15/06/2025 16:09, Alexey Gladkov wrote:
> > On Sun, Jun 15, 2025 at 03:35:17PM +0100, Harald van Dijk wrote:
> >> 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.
> 
> I'm +1 for util-linux's approach. It's simple and addresses Alexey's
> overlayfs problem without being destructive.

Yes, but that would leave the modified data at the upper level in my case.

> Alexey has said that overlayfs won't touch the lower layer, and thus
> in this case, deleting files from an overlayfs root might not free
> memory that much as you would think. Here, it might be better to leave
> the files alone and not 'rm -rf' them.

Typically overlayfs is used to temporarily modify read-only images such as
docker/podman. When the base image (lower layer) is left unchanged and all
changes are written to tmpfs and lost.

If you don't delete the data in switch_root, it will be a waste of memory
since you are not supposed to go back to root. This is a big difference
from rm -rf.

-- 
Rgrds, legion

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

Reply via email to