是否可以在不创建initrd映像的情况下引导Linux内核? [英] Is it possible to boot the Linux kernel without creating an initrd image?

查看:166
本文介绍了是否可以在不创建initrd映像的情况下引导Linux内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,initrd是一个可加载到RAM中的小图像.它用于引导带有所有可加载模块的完整内核.作为该过程的一部分,我们需要vmlinuz内核映像,它是bzImage的重命名版本.

是否可以在不创建initrd映像的情况下引导内核?

解决方案

initrd/initramfs是可选的,不是必需的. bzImage是纯内核映像,可以由引导程序直接引导.但是,可能需要执行一些通常需要访问文件系统和用户空间工具的任务(例如,加载文件系统模块,用于磁盘访问的驱动程序,从某些没有固定名称/路径的可交换媒体安装根文件系统等). /p>

这就是 initramfs 的作用:这是一个CPIO归档文件,它要么附加到内核映像本身,要么附加到内核映像(内核映像是initramfs的容器,而不是其他方式),或在引导时由引导程序加载.

该CPIO存档包含一个初始rootfs,其中包含设置所有设备以访问正确的根文件系统所需的模块,以及一些程序来标识那些设备,加载模块,执行其他一些启动任务,以将正确的根文件系统重新安装到/和开始/sbin/init

initrd 相似,主要区别在于它是一个文件系统映像,可以并且通常被压缩.内核必须支持内置使用的文件系统,并将此映像安装为初始/.

由于CPIO简化了几个数量级,因此initramfs比initrd更受青睐,因为这样既节省了对内置任何文件系统模块的需求,又使initramfs的创建更加容易.无需创建ext2映像,而是通过loopdevice挂载并填充它,它可以简化为简单的归档创建过程,与使用tar不同.

但是,如果您使用内置在内核映像中的所有必需驱动程序和模块来编译内核,并且您的根文件系统设备在系统中具有固定名称,则您不需要initramfs,因为内核可以自行执行操作

As I understand, initrd is a small image that is loadable in the RAM. It is used to boot a complete kernel with all the loadable modules. As part of the process, we need the vmlinuz kernel image which is a renamed version of bzImage.

Is it possible to boot the kernel without creating the initrd image?

解决方案

initrd/initramfs is optional and not a requirement. bzImage is the pure kernel image and can be booted directly by the bootloader. However it might be neccesary to execute some tasks (loading filesystem modules, drivers for disk access, mounting the root file system from some exchangeable media without fixed name/path, etc.) that would usually require access to a filesystem and userspace tools.

That's what initramfs is for: It is a CPIO archive that gets attached to the kernel image (the kernel image is the container for the initramfs not other way round) either in the kernel image itself, or by the bootloader at boot time.

That CPIO archive contains an initial rootfs with the modules required to setup all devices to access the proper root filesystem and some programs to identify those devices, load the modules, do some other startup tasks remount the proper root file system to / and start /sbin/init

initrd is similar, with the main difference that it is an filesystem image, that may be and usually is compressed. The kernel must have support for the filesystem used built in and will mount this image as the initial /.

Since CPIO is simpler by several orders of magnitudes, initramfs is prefered over initrd, as this saves both the requirement for any filesystem modules being built in and also makes initramfs creation easier. Instead of having to create an ext2 image, loopdevice mount and populate it, it boils down to a simple archive creation, not unlike using tar.

However if you compile your kernel with all required drivers and modules built into the kernel image, and your root file system device has a fixed name in the system you don't need a initramfs as the kernel can do things by itself then.

这篇关于是否可以在不创建initrd映像的情况下引导Linux内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆