I want to create an ext4 filesystem, and add some files to it, then freeze it so it is henceforth read-only.I know it's possible to use the ro mount option. But is there some way to indicate in the filesystem itself that it is read-only?I see that tune2fs has an option -o to set default mount options, but -o ro is not a valid option.I also see that tune2fs has an option -E mount_opts. I tried -E mount_opts=ro on a loopback filesystem (Ubuntu 14.10):dd if=/dev/zero of=ext4test bs=1M count=32mkfs.ext4 -L test ext4testtune2fs -E mount_opts=ro ext4testmkdir ext4testmntsudo mount ext4test ext4testmntHowever, the file system is still mounted as read-write.
Mark an ext4 filesystem as read-only
ext4;readonly
This is supported in recent kernels (4.0 and later) and, since late February 2015, in e2fsprogs (as of this writing you'll need to clone the git repository and build the current WIP version yourself).With the appropriate kernel and tools, you can flag an ext4 filesystem read-only using tune2fs:tune2fs -O read-only ext4testand clear the flag as always withtune2fs -O ^read-only ext4test