0dc4f1b core: do not serialize mounts and automounts for switch-root

Authored and Committed by zbyszek 2 years ago
    core: do not serialize mounts and automounts for switch-root
    
    When e.g. tmp.mount is present in the initrd, and we serialize it, switch root,
    and deserialize, the new systemd is confused because it thinks /tmp is mounted.
    In general, it doesn't make sense to serialize anything that refers to paths in
    the old root file system.
    
    This fixes two errors for me:
    
    1. tmp.mount was not mounted properly before local-fs.target. It would be
    mounted as some point (I guess when we re-read /proc/self/mountinfo for some
    other reason). In effect systemd-tmpfiles-setup.service would see one fs, and
    some other units started later a different one. In particular gdm.service would
    fail because the pre-created /tmp/.X11-unix with proper permissions would not
    exist at time it was started.
    
    2. # systemd[1]: proc-sys-fs-binfmt_misc.automount: Got hangup/error on autofs pipe from kernel. Likely our automount point has been unmounted by someone or something else?
       # systemd[1]: proc-sys-fs-binfmt_misc.automount: Failed with result 'unmounted'.
       # systemd[1]: Mounting proc-sys-fs-binfmt_misc.mount...
       # systemd[1]: Mounted proc-sys-fs-binfmt_misc.mount.
       # systemd[1]: Starting systemd-binfmt.service...
       # systemd[1]: Finished systemd-binfmt.service.
       # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
       # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount.
       # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
       # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount.
       # systemd[1]: proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
       # systemd[1]: Failed to set up automount proc-sys-fs-binfmt_misc.automount.
       # systemd[1]: Stopping systemd-binfmt.service...
       # systemd[1]: systemd-binfmt.service: Deactivated successfully.
       # systemd[1]: Stopped systemd-binfmt.service.
    
    I couldn't understand the error here, but in retrospect the first line is entirely
    correct: "someone or something else" was the old systemd unmounting the old root.
    
    (cherry picked from commit 755021d43448011ef169f20ec3a08d4e92c824af)
    
        
file modified
+1 -0
file modified
+1 -5
file modified
+1 -0
file modified
+14 -2
file modified
+3 -0