系统 initramfs 或 initrd 损坏/丢失

2024-11-22   访问量:1010

现象描述

执行命令或系统启动的过程中,出现 VFS: Unable to mount root fs on unknow-block 或者 error:file '/boot/initramfs-`uname -r`.img' not found 等报错信息。

可能原因

1. 系统启动失败,输出 VFS: Unable to mount root fs on unknow-block 可能是 initramfs 或 initrd 有问题,需要重新 生成 initramfs 或 initrd:。如下图所示:







2. 系统启动失败,输出 error:file '/boot/initramfs-`uname -r`.img' not found 可能是 /boot 目录下缺少 initramfs/initrd 文件。如下图所示:







上面两种情况,都会导致系统无法正常启动。您可以参见 故障处理,检查并重新生成 initramfs/initrd。

故障处理

1. 参见 使用救援模式,进入救援模式。

2. 执行其中的 mountchroot 等命令。mkdir -p /mnt/vm1mount /dev/vda1 /mnt/vm1mount -o bind /dev /mnt/vm1/devmount -o bind /dev/pts /mnt/vm1/dev/ptsmount -o bind /proc /mnt/vm1/procmount -o bind /run /mnt/vm1/runmount -o bind /sys /mnt/vm1/syschroot /mnt/vm1 /bin/bash

3. 执行以下命令,重新生成 initramfs/initrd。wget http://mirrors.tencentyun.com/install/cts/linux/cvmrescue_main.sh && chmod +x cvmrescue_main.sh && ./cvmrescue_main.sh -m rebuild_initramfs

碰到域名解析失败的可以在 /etc/hosts 中配置 hosts 169.254.0.3 mirrors.tencentyun.com。

4. 输出如下,表示 initramfs 或 initrd 新建成功。







5. 参见 使用救援模式,退出救援模式,启动系统。


热门文章
更多>