is /run shared to the real filesystem after the initrd stage? like what directories are shared to the real filesystem after initrd, or what files. Or is everything just inaccessible in the real filesystem from the initrd phase.
man switch_root
switch_root moves already mounted /proc, /dev, /sys and /run to newroot and makes newroot the new root filesystem and starts init process.
WARNING: switch_root removes recursively all files and directories on the current root filesystem.
If you look at the source code, it uses
mount(2)
with the MS_MOVE flag to move the /proc, /dev, /sys, /run to the new root, then deletes all the files on the old root fs recursively, then MS_MOVE-mounts the new root over the old one. As the comment in the source code points out:/* Don’t try to unmount the old “/”, there’s no way to do it. */
This is presumably why it deletes the files on the initrd, because it is a ram disk and the files would be eating up memory if left there.