c2620a6 pid1: skip cleanup if root is not tmpfs/ramfs

Authored and Committed by zbyszek a year ago
    pid1: skip cleanup if root is not tmpfs/ramfs
    
    in_initrd() was really doing two things: checking if we're in the initrd, and
    also verifying that the initrd is set up correctly. But this second check is
    complicated, in particular it would return false for overlayfs, even with an
    upper tmpfs layer. It also doesn't support the use case of having an initial
    initrd with tmpfs, and then transitioning into an intermediate initrd that is
    e.g. a DDI, i.e. a filesystem possibly with verity arranged as a disk image.
    
    We don't need to check if we're in initrd in every program. Instead, concerns
    are separated:
    - in_initrd() just does a simple check for /etc/initrd-release.
    - When doing cleanup, pid1 checks if it's on a tmpfs before starting to wipe
      the old root. The only case where we want to remove the old root is when
      we're on a plain tempory filesystem. With an overlay, we'd be creating
      whiteout files, which is not very useful. (*)
    
    This should resolve https://bugzilla.redhat.com/show_bug.cgi?id=2137631
    which is caused by systemd refusing to treat the system as an initrd because
    overlayfs is used.
    
    (*) I think the idea of keeping the initrd fs around for shutdown is outdated.
    We should just have a completely separate exitrd that is unpacked when we want
    to shut down. This way, we don't waste memory at runtime, and we also don't
    transition to a potentially older version of systemd. But we don't have support
    for this yet.
    
    This replaces 0fef5b0f0bd9ded1ae7bcb3e4e4b2893e36c51a6.
    
    (cherry picked from commit a940f507fbe1c81d6787dc0b7ce232c39818eec9)
    
        
file modified
+8 -11
file modified
+12 -10