只读 Initramfs Linux 系统

Read only Initramfs Linux system

我有一个嵌入式板,我在上面 运行 Linux。 Linux 通过 uboot 启动。完整的 Linux 映像构建为 Initramfs。当系统启动时,我发现根 FS 是可读写的。我的理解是 Initramfs 默认情况下应该是只读的。对吗?

我也试过把uboot中的启动参数改成只读,但是没有效果。我想知道如何使 Initramfs 默认只读?

The full Linux image is build as Initramfs.

这是一个措辞不佳的描述,如果不是不准确的话。
initramfs 使用 cpio 存档文件,它不是图像文件。
cpio 存档文件可以链接到 Linux 内核映像。

initramfs "image" 始终是 cpio 存档文件,而不是文件系统映像。


My understanding is that the Initramfs should be by default read only. Right?

错了。
将 initramfs 挂载为只读文件系统毫无意义。
创建并挂载 initramfs 后,它是一个空文件系统。
如果它以只读方式安装,则 initramfs 无法使用其 cpio 存档填充,并且 initramfs 将保持为空文件系统。

使用内核命令行参数(例如 root=/dev/ram ro)的建议表明(已弃用)ramdisk 和 ramfs 之间存在混淆。
参见 Linux 内核 Documentation/filesystems/ramfs-rootfs-initramfs.txt


I wonder what to do to make the Initramfs read only by default?

您可以将其重新挂载为只读。
参见 http://lkml.iu.edu/hypermail/linux/kernel/0908.1/01693.html

https://serverfault.com/questions/463828/linux-initramfs-read-only