Skip to contentSkip to conversation

Can initramfs be mounted read-only?

DISCUSSION David Wuertele 3 participants 4 messages Aug 12, 2009

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
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/cmdline it 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

#2 lore raw
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