I use Linux overlay
fs as root filesystem to keep the real root partition read-only and write changes to another fs (e.g., tmpfs or another partition).
However, when the root filesystem is finally in place (after 'pivot root'), the original mounts (let's say at /dev/sda
at /mnt/root-write-protected
) is hidden in the initial root (eg. init ramdisk), but still actively mounted. However, it is not visible from inside the root filesystem anymore, nor can the original device be mounted again in a writeable fashion, as mount
says:
mount: /dev/sda is already mounted
despite no entry is listed by mount
or cat /etc/mtab
.
How can I access (e.g., read from, remount) this hidden mount?
overlayroot
, that installs all scripts needed. Also there are older scripts lurking in the internet, that can be installed to the initrd to write-protect the root partition. If you try to do it manually, it's quite involved as you have to do it in early boot (when the kernel mounts the root partition) and therefore you need to do scripting in the initrd./etc/overlayroot.conf
. There is some documentation inside.dm
devices, by the way. They appear not used (as reported bydmsetup info
--open count 0 reported) when they are in fact used as a layer in a overlay fs! Ventoy+Ubuntupersistent
(via casper) creates something like that. (I think the issue is thatdmsetup info
is only able to see/report simple mounts, but not uses in an overlay.)