简体   繁体   English

只读Initramfs Linux系统

[英]Read only Initramfs Linux system

I have an embedded board which I am running Linux on it. 我有一个嵌入式板,正在其上运行Linux。 Linux is booted via uboot. Linux通过uboot引导。 The full Linux image is build as Initramfs. 完整的Linux映像作为Initramfs构建。 When the system is booted I find that the root FS is read write. 引导系统后,我发现根FS是读写的。 My understanding is that the Initramfs should be by default read only. 我的理解是,默认情况下,Initramfs应该是只读的。 Right? 对?

I have tried to change boot parameter in uboot as well to have it read only, but it had no effect. 我试图更改uboot中的启动参数以及使其只读,但没有任何效果。 I wonder what to do to make the Initramfs read only by default? 我想知道如何使Initramfs默认为只读?

The full Linux image is build as Initramfs. 完整的Linux映像作为Initramfs构建。

That's a poorly worded, if not inaccurate, description. 这是措辞不佳的描述,即使不是准确的描述。
An initramfs uses a cpio archive file, which is not an image file. initramfs使用cpio存档文件,该文件不是映像文件。
The cpio archive file can be linked into the Linux kernel image. cpio存档文件可以链接到Linux内核映像。

An initramfs "image" is always a cpio archive file, and not a filesystem image. initramfs“映像”始终是cpio存档文件,而不是文件系统映像。


My understanding is that the Initramfs should be by default read only. 我的理解是,默认情况下,Initramfs应该是只读的。 Right? 对?

Wrong. 错误。
It makes no sense to mount the initramfs as a read-only filesystem. 将initramfs挂载为只读文件系统没有任何意义。
When the initramfs is created and mounted, it's an empty filesystem. 创建并装入initramfs时,它是一个空文件系统。
If it was mounted read-only, then the initramfs could not be populated with its cpio archive, and the initramfs would remain an empty filesystem. 如果以只读方式安装,则无法使用cpio归档文件填充initramfs,并且initramfs将保持为空文件系统。

The suggestion to use a kernel command line parameter such as root=/dev/ram ro indicates a confusion between (deprecated) ramdisk and ramfs. 建议使用内核命令行参数(例如root=/dev/ram ro表明(不建议使用的)ramdisk和ramfs之间存在混淆。
See Linux kernel Documentation/filesystems/ramfs-rootfs-initramfs.txt 请参阅Linux内核文档/filesystems/ramfs-rootfs-initramfs.txt


I wonder what to do to make the Initramfs read only by default? 我想知道如何使Initramfs默认为只读?

You can remount it to be read-only. 您可以将其重新安装为只读。
See http://lkml.iu.edu/hypermail/linux/kernel/0908.1/01693.html 参见http://lkml.iu.edu/hypermail/linux/kernel/0908.1/01693.html
and
https://serverfault.com/questions/463828/linux-initramfs-read-only https://serverfault.com/questions/463828/linux-initramfs-read-only

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM