我找到了 ubuntu initramfs-tools 来源。在这里你可以清楚地看到,Begin: "Mounting root file system"
消息是先打印的,但在mount_root
函数中fsck
是在实际挂载之前运行的。我省略了一些不相关的代码,只是为了表明顺序。(如果您要检查链接的源,您还会从屏幕截图中找到其他报告的脚本)。
/init
第 256 行
log_begin_msg "Mounting root file system"
# Always load local and nfs (since these might be needed for /etc or
# /usr, irrespective of the boot script used to mount the rootfs).
. /scripts/local
. /scripts/nfs
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mount_top
mount_premount
mountroot
log_end_msg
Run Code Online (Sandbox Code Playgroud)
/scripts/local
@第 244 行
mountroot()
{
local_mount_root
}
Run Code Online (Sandbox Code Playgroud)
/scripts/local
@第 131 行
local_mount_root()
{
# Some code ommited
# FIXME This has no error checking
[ -n "${FSTYPE}" ] && modprobe ${FSTYPE}
checkfs ${ROOT} root "${FSTYPE}"
# FIXME This has no error checking
# Mount root
mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
mountroot_status="$?"
if [ "$LOOP" ]; then
if [ "$mountroot_status" != 0 ]; then
if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
panic "<Error message ommited>"
fi
fi
mkdir -p /host
mount -o move ${rootmnt} /host
# Some code ommitted
}
Run Code Online (Sandbox Code Playgroud)
两种选择:
fsck
。Systemd是mint 上的init实现,因为你已经检查过它是否存在,所以这个选项不适用。/sbin/fsck.ext4
在“早期用户空间”中运行,由initramfs设置。在您的系统中很可能就是这种情况。即使您注意到/sbin/fsck.ext4
之前运行过systemd
,我也想详细说明一下。Systemd完全有能力fsck
在只读挂载的文件系统上自行运行。请参阅systemd-fsck@.service文档。很可能这个服务在 mint 中默认没有启用,因为它对于早期的用户空间服务来说是多余的。
我不知道 initramfs mint 的哪个实现正在运行,但我将dracut
用作示例。(在 Debian、openSuse 等中使用)它在其挂载准备文档中说明了以下内容:
当根文件系统最终变得可见时:
- 任何无法在已挂载的根文件系统上运行的维护任务都已完成。
- 根文件系统以只读方式挂载。
- 任何必须继续运行的进程(例如 rd.splash 屏幕助手及其命令 FIFO)都被提升到新安装的根文件系统中。
维护任务包括fsck
. 进一步的证据,在dracut cmdline 选项中有可能关闭fsck
:
跳过文件
对于 rootfs 和 /usr 跳过 fsck。如果您以只读方式挂载 /usr 并且 init 系统在重新挂载之前执行 fsck,您可能需要使用此选项来避免重复
可以使用systemd 基础设施实现动态(基于 udev)和灵活的 initramfs 。Dracut 就是这样一个实现,可能有发行版想要编写自己的发行版。
另一种选择是基于脚本的 initramfs。在这种情况下,busybox ash
它被用作脚本外壳,甚至可能替换udev
为mdev
,或者可能只是完全静态的。我发现有些人busybox
由于某些 fsck 错误 int mint被丢弃到shell,所以这个实现可以适用于 mint。
如果您真的想确定,请尝试解压缩 initramfs 文件/boot
并查看其中的内容。也可能会看到它安装在/initramfs
.
归档时间: |
|
查看次数: |
997 次 |
最近记录: |