- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
据我所知,initrd
充当 block 设备,因此需要文件系统驱动程序(例如 ext2
)。内核必须至少有一个内置模块用于检测 initrd
的文件系统。在这篇文章中,Introducing initramfs, a new model for initial RAM disks ,是这样写的:
But ramdisks actually waste even more memory due to caching. Linux is designed to cache all files and directory entries read from or written to block devices, so Linux copies data to and from the ramdisk into the "page cache" (for file data), and the "dentry cache" (for directory entries). The downside of the ramdisk pretending to be a block device is it gets treated like a block device.
什么是page cache
和dentry cache
?在该段落中,是否意味着数据被复制,因为 ramdisk
被视为 block 设备,因此所有数据都被缓存了?
相比之下,ramfs
:
A few years ago, Linus Torvalds had a neat idea: what if Linux's cache could be mounted like a filesystem? Just keep the files in cache and never get rid of them until they're deleted or the system reboots? Linus wrote a tiny wrapper around the cache called "ramfs", and other kernel developers created an improved version called "tmpfs" (which can write the data to swap space, and limit the size of a given mount point so it fills up before consuming all available memory). Initramfs is an instance of tmpfs.
These ram based filesystems automatically grow or shrink to fit the size of the data they contain. Adding files to a ramfs (or extending existing files) automatically allocates more memory, and deleting or truncating files frees that memory. There's no duplication between block device and cache, because there's no block device. The copy in the cache is the only copy of the data. Best of all, this isn't new code but a new application for the existing Linux caching code, which means it adds almost no size, is very simple, and is based on extremely well tested infrastructure.
总而言之,ramfs
只是文件打开并加载到内存中,不是吗?
initrd
和 ramfs
都是在编译时压缩的,但不同的是,initrd
是一个 block 设备,解压后由内核在启动时,而 ramfs
通过 cpio 解压到内存中。我对么?还是 ramfs
是一个非常小的文件系统?
最后,直到今天,initrd
镜像仍然显示在最新的内核中。然而,那个 initrd
真的是今天使用的 ramfs
并且这个名字只是为了历史目的吗?
最佳答案
我认为你是对的。
如果您按照启动时所需的步骤进行操作,很容易看出区别:
initrd
ramdev
block 设备。它是基于 ram 的 block 设备,即使用内存而不是物理磁盘的模拟硬盘。initrd
文件被读取并解压缩到设备中,就像您执行 zcat initrd | dd of=/dev/ram0
或类似的东西。 initrd
包含文件系统的镜像,因此现在您可以照常挂载文件系统:mount/dev/ram0/root
。自然,文件系统需要驱动程序,因此如果您使用 ext2,则必须在内核中编译 ext2 驱动程序。initramfs
tmpfs
:mount -t tmpfs nodev/root
。 tmpfs 不需要驱动程序,它总是在内核上。无需设备,无需额外的驱动程序。initramfs
直接解压缩到这个新文件系统中:zcat initramfs | cpio -i
,或类似的。是的,尽管它是一个 initramfs
,但在很多地方它仍然被称为 initrd
,尤其是在引导加载程序中,因为它只是一个 BLOB。操作系统启动时会产生差异。
关于linux - initrd 和 initramfs 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10603104/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
运行 Ubuntu 18.04 LTS。我已将脚本放在以下位置: /usr/share/initramfs-tools/scripts/init-bottom/dothis dothis 设置为 +x
有些硬件设备需要用户空间支持,例如守护进程运行和处理不适合(太复杂或与策略相关)内核空间的交互部分。 一旦到达用户空间,运行此类守护进程就很容易了——您可以在热插拔事件后运行它们,不用太担心。 一旦
我的系统 (ARM32) 正在通过 U-Boot 启动 Linux。内核从 u-boot 获取 console=ttymxc1,115200 作为参数。然后它在 initramfs 中使用带有 swi
我在 SmartFusion2 上运行 uClinux,作为构建小型立方体卫星的大学团队的一部分。但是,我在 Linux 内核方面不是很有经验,这个问题让我难过了几天。我试图让 SmartFusion
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
我正在coldfire板M5272C3上进行uclinux移植。现在我有从 RAM 运行的内核,并使用 romfs 作为我的根文件系统。我不清楚一些术语的含义以及何时使用它们...... 请用最简单的
我带来了一个RPi。现在使用 Raspbian 或其他哪个发行版? Raspbian 和其他发行版之间到底有什么区别。 http://elinux.org/RPi_Distributions 这些 z
我正在从 minimfs 编译 initramfs,但它在启动过程中无法检测到 init。我有 2 个 simlink,一个位于/init,另一个位于 sbin/init,均指向/sbin/init.
在运行 Linux 2.6.36 的嵌入式平台上,我偶尔会遇到一个问题,即根文件系统中的文件没有出现在我们的 initramfs cpio 文件中。 我正在从 cpio 列表文件构建 initramf
不知谁有过这样的经历。我们正在使用无盘 linux 服务器。在我们使用ramdisk之前,最近我们正在尝试用ramfs制作一个无盘服务器,我们成功地创建了rootfs镜像并启动了服务器。 那么这里的问
我有一 block 嵌入式主板,上面运行着 Linux。 Linux 是通过 uboot 启动的。完整的 Linux 镜像构建为 Initramfs。当系统启动时,我发现根 FS 是可读写的。我的理解
我想修改根设备节点作为 initramfs 脚本的一部分。我不想自己执行 switch_root(除非我必须这样做)。我想添加一个脚本,如果满足某些条件,它可以更改根设备。 我尝试了各种选项,例如读取
我在浏览 Linux 源代码时,在 initramfs 的第 400 行遇到了一段不熟悉的代码。 .我知道括号中的名称是 188 枚举中的状态。在我看来,这是一个默认数组设置函数指针(我可能是错的)。
据我所知,initrd 充当 block 设备,因此需要文件系统驱动程序(例如 ext2)。内核必须至少有一个内置模块用于检测 initrd 的文件系统。在这篇文章中,Introducing init
Linux 内核使用一种 ram 磁盘在早期引导阶段访问模块。出于好奇,我想了解我有一个问题:内核在此阶段必须可以访问包含 initramfs/initrd 的文件。这意味着内核必须支持适当的文件系统
我正在尝试使用 initramfs 作为 linux 内核引导的文件系统。我希望我的文件系统是最小的,所以我只使用没有 rootfs 的 initramfs。现在,一旦内核启动,它就会从 initra
使用gentoo规范为Thinkpad T430编译了内核 挂载空的 ext4 硬盘并在其上创建 boot/目录,将 bzImage 和 System.map 移入其中 使用“extlinux --i
我有这个与 initramfs 一起运行的 perl 脚本。我遇到了很多我不明白的小问题,这些问题肯定与 shell 有关。我要问的具体问题是: system("/sbin/e2fsck -f $de
我想通过编辑现有脚本或在已安装 CentO 的引导文件夹中的 initramfs 中添加新脚本来添加新的 ext3 分区。然后通过将新的 initramfs 镜像替换为其他已安装的 centos,只需
我是一名优秀的程序员,十分优秀!