Can initramfs be mounted read-only?
I've been trying to create a system with a read-only rootfs using initramfs, but I'm not having any luck. I've included "ro" on my command line and when I cat /proc/cmdline it reports "ro" like I expect. But when I type "mount", I see this:
rootfs on / type rootfs (rw)
And I can create new files and write to them just fine. Is it possible to mount an initramfs read-only?
The documentation for early userspace and initramfs does not talk about read/write permissions.
Thanks,
Dave
Quoted 6 lines · David Wuertele
I've been trying to create a system with a read-only rootfs using initramfs, but I'm not having any luck. I've included "ro" on my command line and when I cat
/proc/cmdlineit reports "ro" like I expect. But when I type "mount", I see this:rootfs on / type rootfs (rw)
Changing this could potentially break a lot of systems. At least Debian has "ro" as a default boot option, and it uses an initramfs by default.
Quoted 5 lines
And I can create new files and write to them just fine. Is it possible to mount an initramfs read-only?
The documentation for early userspace and initramfs does not talk about read/write permissions.
Have you tried running "mount / -oremount,ro" in an init script?
Regards
Alan
Quoted 5 lines · Alan Jenkins <sourcejedi.lkml <at> googlemail.com> writes:
Quoted 1 line
I've been trying to create a system with a read-only rootfs using initramfs,
Changing this could potentially break a lot of systems. At least Debian has "ro" as a default boot option, and it uses an initramfs by default.
I don't want to change it for everybody, just my own system. Since I'm not using Debian, or any other distribution, I can handle the consequences.
Quoted 4 lines
Quoted 2 lines
Is it possible to
mount an initramfs read-only?Have you tried running "mount / -oremount,ro" in an init script?
Yes, and it works (the rootfs appears read-only after doing this). I was hoping to get it to be read-only before init gets run.
Dave
Try cramfs or romfs instead? Those are definitely readonly.