this post was submitted on 29 Jul 2025
16 points (100.0% liked)

Linux

56914 readers
557 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

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.

top 1 comments
sorted by: hot top controversial new old
[–] gnuhaut@lemmy.ml 4 points 4 days ago* (last edited 4 days ago)

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.