Linux系统启动失败与GRUB修复:命令行恢复指南¶
Linux 系统启动故障可能会在没有警告的情况下停止工作站、生产服务器和双启动笔记本电脑,让您陷入严重的困境。 grub rescue> 提示,最少 grub> 壳,一个 (initramfs) 或者 dracut:/# 紧急控制台,一个 systemd "You are in emergency mode" 维护提示,或黑屏且光标闪烁。
与将启动机制隐藏在不透明的图形错误代码后面的操作系统不同,Linux 直接向管理员公开启动管道的每个阶段。几乎每个 Linux 启动失败都源于五个可修复的根本原因之一:覆盖或错误配置的 GRUB 2 引导加载程序(通常在双引导 PC 上更新 Windows 后触发)、脏的 ext4/xfs/btrfs 突然断电后根文件系统损坏 /etc/fstab 磁盘 UUID 条目,100% 完整根(/)存储分区,或中断的内核和显卡驱动程序升级。将屏幕上的提示与相应的启动阶段精确匹配,可以让您干净地修复系统,而无需格式化驱动器或丢失数据。
现在就这样做¶
当您的 Linux 计算机或服务器拒绝启动时,请在运行任何破坏性磁盘命令之前执行以下六个立即诊断和安全步骤:
- 阅读屏幕上的确切提示以确定哪个启动阶段失败:
grub rescue>或者grub>:主板UEFI/BIOS加载了GRUB的第一阶段,但是GRUB无法定位/boot/grub或其配置文件(grub.cfg)。(initramfs)或者dracut:/#:GRUB 可以正常加载 Linux 内核和初始 RAM 磁盘,但内核无法挂载您的主根(/)文件系统(通常是因为fsck需要修复脏磁盘)。You are in emergency mode / Give root password for maintenance:根文件系统已安装,但是systemd未能安装列出的辅助驱动器/etc/fstab。- GRUB 菜单后出现黑屏且光标闪烁:操作系统已启动,但图形显示管理器(GDM、SDDM、LightDM)由于根磁盘 100% 完整或 Nvidia/AMD GPU 驱动程序损坏而失败。
- 首先尝试从 GRUB 菜单启动以前的 Linux 内核:重新启动计算机并按住 Shift (BIOS) 或在制造商徽标后反复点击 Esc (UEFI) 以显示 GRUB 菜单。选择 “Ubuntu / Debian / Fedora 的高级选项” 并选择列表中第二旧的内核。如果最近的内核更新破坏了您的
initramfs或 GPU 模块,以前的内核将在 10 秒内直接启动到您的桌面。 - 如果卡在黑屏上,请切换到虚拟 TTY 文本控制台:如果启动顺序在黑屏上冻结,并带有闪烁的下划线或卡住的启动徽标,请按
Ctrl + Alt + F3(或Ctrl + Alt + F2通过F6)。如果一个login:出现文本提示,您的 Linux 系统实际上正在运行,请使用您的用户名和密码登录以清理完整磁盘空间或修复图形驱动程序。 - 永远不要跑
fsck在当前以读写方式挂载的分区上:正在运行fsck在活动的、读写安装的文件系统上会损坏打开的索引节点表并破坏文件。只运行fsck从(initramfs)shell(其中 root 已卸载)、只读安装或来自 Live USB 记忆棒。 - 拔下所有不重要的外部 USB 硬盘和 SD 卡:中列出的出现故障的外部 USB 驱动器
/etc/fstab或者接管 BIOS 中的启动优先级将停止启动顺序。拔下外部驱动器并重新启动以进行测试。 - 如果 GRUB 或内核完全丢失,请准备一个 Live Linux USB 记忆棒:随身携带一个可启动的 Live USB 闪存驱动器(Ubuntu、Linux Mint、Fedora 或 SystemRescue),以便您可以挂载加密或标准分区并运行
chroot引导加载程序修复。
关键:什么不该做
永远不要跑 grub-install, dd, fdisk, 或者 mkfs 直到您使用以下命令验证了确切的磁盘和分区布局 lsblk -f 或者 blkid。设备节点名称如 /dev/sda 和 /dev/sdb 由 Linux 内核在启动时动态分配,并且在插入 Live USB 记忆棒时可以交换顺序。意外格式化或覆盖错误的分区表 /dev/sdX 驱动器会破坏您的数据。此外,切勿运行文件系统修复实用程序,例如 fsck 在以读写方式安装的分区上,在活动内核或引导加载程序包升级期间切勿强制关闭系统,并且切勿删除其中的系统库 /usr/lib 或者 /lib 尝试清理完整根驱动器上的空间。
决策树:诊断 Linux 启动失败的 5 个阶段¶
使用此诊断流程图可将您的确切屏幕输出跟踪到匹配的命令行修复:
flowchart TD
A["Linux 系统无法启动到桌面/登录"] --> B{"屏幕上显示什么?"}
B -->|"grub rescue> 或 grub> 提示符"| C["第 1 阶段失败:使用 ls 找到 /boot/grub,设置根目录和前缀,启动操作系统,然后运行 grub-install"]
B -->|"BusyBox (initramfs) 或 dracut:/# shell"| D["第 2 阶段失败:使用 blkid 识别根分区并运行 fsck -y /dev/partition"]
B -->|"紧急模式:提供 root 密码进行维护"| E["第 3 阶段失败:运行 mount -o remount,rw / 并修复或注释掉 /etc/fstab 中损坏的 UUID"]
B -->|"GRUB 后黑屏或光标闪烁"| F["第 4 阶段故障:按 Ctrl+Alt+F3(或启动 Emergency.target)清除 100% 已满磁盘或 GPU 驱动程序"]
B -->|"直接启动进入 Windows 或“无可启动设备”"| G["UEFI/EFI 引导顺序已擦除:引导 Live USB、挂载 Root + EFI、chroot 并重新安装 GRUB"]
Linux启动失败提示、原因及命令对比¶
| 屏幕错误/提示 | 已达到启动阶段 | 主要根本原因 | 最快的修复命令序列 |
|---|---|---|---|
error: no such partition / grub rescue> |
第 1 阶段(GRUB 核心) | 磁盘分区调整大小、克隆或 UUID 更改; GRUB 找不到 /boot/grub/normal.mod。 |
ls -> set root=(hdX,gptY) -> set prefix=(hdX,gptY)/boot/grub -> insmod normal -> normal |
grub>(标准 GRUB CLI) |
阶段 1.5(GRUB 正常) | /boot/grub/grub.cfg 尽管 GRUB 模块加载正常,但丢失或删除。 |
set root=(hdX,gptY) -> linux /boot/vmlinuz-... root=/dev/nvme0n1p2 -> initrd /boot/initrd.img-... -> boot |
BusyBox (initramfs) 或 dracut:/# |
第 2 阶段(内核 + Initramfs) | 不干净断电左 ext4/xfs 根日志脏,需要手动 fsck 批准。 |
blkid -> fsck -y /dev/nvme0n1p2 (或 xfs_repair -L 对于 XFS)-> reboot -f |
You are in emergency mode(sulogin 提示) |
第三阶段(systemd 坐骑) |
辅助驱动器或交换分区 /etc/fstab 被拔掉、重新格式化或损坏。 |
输入root密码-> mount -o remount,rw / -> nano /etc/fstab (添加 nofail 或者 #)-> systemctl daemon-reload -> reboot |
[FAILED] Failed to start GNOME Display Manager / 闪烁光标 |
第 4 阶段(显示管理器/GUI) | 根分区 / 100% 已满(0 字节可用 /tmp 或 Xorg 套接字)或损坏的 Nvidia 内核模块(dkms)。 |
按 Ctrl+Alt+F3 -> df -h -> journalctl --vacuum-size=100M & apt clean 或 ubuntu-drivers autoinstall |
场景一:逃离 grub rescue> 或者 grub> 没有 U 盘时提示¶
如果您的屏幕显示 error: unknown filesystem, error: no such partition, 或者 Minimal BASH-like line editing is supported 其次是 grub rescue> 或者 grub>,您的 Linux 安装和个人文件通常仍然完好无损地保存在您的 SSD 或硬盘驱动器上,GRUB 根本不知道哪个分区保存 /boot/grub。您可以在 2 分钟内从此提示直接启动到已安装的操作系统:
情况A:你在 grub rescue> 提示¶
在 grub rescue>,只有四个基本命令有效(ls, set, unset, 和 insmod)。仔细按照以下步骤操作:
- 列出主板固件看到的所有磁盘和分区:
GRUB 将打印如下一行:
(hd0) (hd0,gpt1) (hd0,gpt2) (hd0,gpt3)(或(hd0,msdos1)在较旧的 MBR 磁盘上)。 - 检查每个分区,直到找到 Linux 根目录(或
/boot) 目录: (请记住包含尾部斜杠/在每个的末尾ls检查 GRUB 列出该分区内的文件名): - 如果
(hd0,gpt1)/节目efi/,这是您的小型 FAT32 EFI 系统分区。 - 当分区输出
boot/ etc/ home/ usr/ var/ vmlinuz initrd.img,您已经找到了主要的 Linux 根分区(例如,(hd0,gpt2))。 (注意:如果您使用 Btrfs@Ubuntu/Fedora 上的子卷,ls (hd0,gpt2)/将显示@/ @home/,这意味着您的启动文件夹位于(hd0,gpt2)/@/boot/grub.) - 将 GRUB 指向您的分区并加载
normal模块: 假设你的 Linux root 已打开(hd0,gpt2):(如果您有单独的专用grub rescue> set root=(hd0,gpt2) grub rescue> set prefix=(hd0,gpt2)/boot/grub grub rescue> insmod normal grub rescue> normal/boot分区上(hd0,gpt2), 使用set prefix=(hd0,gpt2)/grub没有/boot.) - 桌面启动后永久修复:
一旦
normal运行后,您的常规 GRUB 菜单将出现并引导您的 Linux 系统。 重要:那些set命令在 RAM 中是临时的。登录 Linux 桌面后,打开终端并将正确的 GRUB 位置永久写入驱动器:
情况B:你符合标准 grub> 提示¶
如果你看到 grub> (没有这个词 rescue), 的 normal 模块已经加载,但是你的 grub.cfg 菜单文件丢失或损坏。您可以使用 Tab 自动完成 在四行中手动启动 Linux 内核:
grub> set root=(hd0,gpt2)
grub> linux /boot/vmlinuz-6.8.0-45-generic root=/dev/nvme0n1p2 ro
grub> initrd /boot/initrd.img-6.8.0-45-generic
grub> boot
linux /boot/vmlinuz 然后按 Tab 键,GRUB 将自动完成磁盘上安装的确切内核版本号。) 启动到操作系统后,运行 sudo update-grub (Debian/Ubuntu) 或 sudo grub2-mkconfig -o /boot/grub2/grub.cfg (Fedora/RHEL) 重新生成丢失的菜单文件。
场景 2:修复 (initramfs) 或者 dracut 贝壳与 fsck¶
如果您的 PC 通过 GRUB 菜单,会显示 Linux 启动画面几秒钟,然后变成黑色文本提示:
BusyBox v1.36.1 (Ubuntu) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs) _
(initramfs) 提示。十分之九,你会看到:
The root filesystem on /dev/nvme0n1p2 requires a manual fsck
逐步修复文件系统 (initramfs)¶
- 确认哪个分区需要修复:如果分区名称未打印在提示符的正上方,请键入
blkid然后按 Enter 键列出您的ext4,xfs, 或者btrfs分区。 - 运行匹配的文件系统修复工具:
- 对于
ext4/ext3文件系统(Ubuntu、Debian、Mint 上默认): 的-yflag 会自动对每个损坏的索引节点、孤立块和日志重播提示回答“是”,而不是让您按y500次。 - 对于
XFS文件系统(RHEL、AlmaLinux、Rocky Linux、CentOS 上默认): 标准型fsck对 XFS 不执行任何操作。在一个dracut:/#XFS 系统上的 shell,运行: (仅通过-L如果满足以下条件,则将 XFS 元数据日志标记为零xfs_repair由于无法安装的脏日志而拒绝运行,并且您没有其他选择)。 - 对于
Btrfs文件系统(Fedora、openSUSE 上默认): 首先尝试安全地清除 Btrfs 日志树btrfs rescue zero-log /dev/nvme0n1p2。永远不要跑btrfs check --repair除非得到 Btrfs 开发人员的指示或从 Live USB 备份数据后,否则--repair在 Btrfs 上被认为是危险的。
- 对于
- 退出并重新启动:一次
fsck版画***** FILE SYSTEM WAS MODIFIED *****,输入exit(或reboot -f)并按 Enter 键。您的系统将挂载干净的分区并正常启动。
场景 3:修复 /etc/fstab 中的错误 systemd 紧急模式¶
如果您的屏幕在启动过程中停止:
You are in emergency mode. After logging in, type "journalctl -xb" to view system logs,
"systemctl reboot" to reboot, or "exit" to continue bootup.
Give root password for maintenance (or press Control-D to continue):
/etc/fstab、格式化交换分区(更改了其 UUID),或拔下中列出的辅助内部/外部硬盘驱动器 /etc/fstab 没有 nofail 选项。默认情况下, systemd 如果列出了任何磁盘,则停止整个操作系统启动 /etc/fstab 90 秒内未响应。
如何修复 /etc/fstab 90秒后¶
- 输入您的 root 密码(或者如果在 Ubuntu 上 root 帐户被锁定并且直接将您带入,请按 Enter 键;如果 Ubuntu 说
Cannot open access to console, the root account is locked,参见init=/bin/bash请注意下面)。 - 将根文件系统重新挂载为读写:在紧急模式下,
/通常以只读方式安装,因此如果您尝试保存/etc/fstab,nano会说Error writing /etc/fstab: Read-only file system。首先运行这个: - 找出哪一行
/etc/fstab已损坏: 运行mount -a。无论驱动器损坏,都会立即打印错误(例如,mount: /mnt/backup: can't find UUID=4a8b...)。您还可以将您的真实驱动器 UUID 与/etc/fstab通过运行: - 编辑
/etc/fstab并添加nofail或注释掉坏行: 放一个#在损坏的辅助驱动器或交换线的开始处将其禁用(或添加,nofail到安装选项列,例如defaults,nofail因此,当外部驱动器拔出时,Linux 永远不会拒绝启动)。保存为Ctrl+O,按 Enter,然后按 ** 退出Ctrl+X**。 - 重新加载
systemd并在重新启动之前验证: 如果mount -a返回零错误,类型reboot并且您的计算机将正常启动。
Warning
如果 Ubuntu/Debian 说怎么办 "Cannot open access to console, the root account is locked" 在紧急模式提示符下? 因为 Ubuntu 禁用了 root 默认密码 sudo, sulogin 如果磁盘处于紧急模式,有时会将您锁定在紧急模式之外 /etc/fstab 失败。要在 30 秒内绕过该锁定:重新启动,按住 Shift 或点击 Esc 打开 GRUB 菜单,突出显示 Ubuntu,按 e 要编辑启动命令,请找到以以下内容开头的行 linux /boot/vmlinuz..., 替换 ro quiet splash 在该行的末尾加上 rw init=/bin/bash,然后按 Ctrl+X 或 F10。这绕过了 systemd 完全让你直接进入解锁状态 # root shell 具有读写访问权限,因此您可以运行 nano /etc/fstab。
场景 4:从 100% 完整根恢复(/) 磁盘或损坏的 GPU 驱动程序¶
如果您的电脑顺利通过 GRUB,没有显示文件系统错误,然后永远挂在黑屏上,左上角有一个闪烁的光标(或者每次输入密码并按 Enter 时循环回到登录屏幕),您的根分区(/) 几乎可以肯定100% 已满。当 / 有 0 MB 的可用空间,Xorg、Wayland 和 GNOME/KDE 无法在以下位置创建 4 KB 会话锁定文件 /tmp 或者 /var/lib,导致桌面无声地崩溃。
如何从 TTY 控制台释放 GB 空间¶
- 在黑色闪烁光标屏幕(或循环登录屏幕)上,按
Ctrl + Alt + F3(在笔记本电脑上,您可能需要Ctrl + Alt + Fn + F3) 从冻结的图形屏幕 (TTY1/TTY2) 切换到纯文本终端 (TTY3)。 - 使用普通用户名和密码登录,然后检查磁盘使用情况:
- 如果
Use%节目100%(或Avail节目0),运行这四个安全清理命令以立即释放 2 GB 到 25 GB 的空间:(如果失控的日志文件如# 1. Clear downloaded package cache (.deb / .rpm archives sitting in /var/cache): sudo apt-get clean # (Ubuntu/Debian/Mint) # sudo dnf clean all # (Fedora/RHEL) # 2. Shrink bloated systemd system logs down to 100 MB: sudo journalctl --vacuum-size=100M # 3. Remove old unused Linux kernel versions and orphaned packages: sudo apt-get autoremove --purge -y # 4. Find the top 10 largest folders inside /var (e.g., Docker, Snap, or runaway /var/log/syslog): sudo du -xh /var | sort -rh | head -n 15/var/log/syslog或者/var/log/ufw.log已经膨胀到 50 GB,立即清空它sudo truncate -s 0 /var/log/syslog.) - 为什么会这样
df -h有时表现出Avail: 0(100% 已满)当仅使用 95% 的磁盘时? 默认情况下,ext4保留 整个分区的 5% 专门用于root这样当普通用户填满磁盘时,root 服务仍然可以运行。在 1 TB SSD 上,5% 是 50 GB 的巨大空间。您可以通过运行以下命令立即为普通用户帐户回收 40+ GB 的保留缓冲区: - 曾经
df -h /显示有几千兆字节可用,运行sudo reboot您的图形桌面将正常登录。
如果 df -h 有足够的可用空间,并且在 Nvidia 驱动程序或内核更新后开始黑屏?¶
如果您的磁盘未满,并且在具有 Nvidia 显卡的 PC 上更新后立即开始黑屏,则 Nvidia 专有内核模块 (nvidia.ko) 编译失败 dkms 对于您的新内核,或者安全启动阻止了未签名的模块:
- 从
Ctrl + Alt + F3TTY控制台,通过运行检查驱动模块是否加载nvidia-smi。 - 如果
nvidia-smi说NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver,或者在主板 UEFI/BIOS 设置中禁用安全启动(如果安全启动阻止未签名的 DKMS 模块),或者重建内核标头和驱动程序:
场景 5:完整的 Live USB chroot 救援(针对擦除的 EFI/GRUB、LVM、LUKS 和 Btrfs)¶
当 Windows 11 更新覆盖您的 UEFI 启动条目时,内核更新会在断电时崩溃,或者 grub rescue> 无法读取您的分区,请从 Live Linux USB 驱动器 启动计算机(选择 “尝试 Ubuntu” 或实时桌面模式)并执行 chroot(更改根目录)修复。一个 chroot 让您的 Live USB 终端“进入”损坏的 SSD 安装并运行 apt, dnf, update-initramfs, 和 grub-install 就像系统正常启动一样。
第 1 步:识别并解锁您的存储布局(lsblk -f)¶
在 Live USB 桌面内打开终端并运行:
看看FSTYPE 列以查看您的 Linux 安装使用四种常见存储架构中的哪一种,并将其挂载到 /mnt 使用下面的匹配块:
- 案例 1:标准
ext4或者xfs分区(例如,根是/dev/nvme0n1p2和 EFI 是/dev/nvme0n1p1): - 案例2:加密的LUKS根分区(
crypto_LUKS) (安装过程中选中“加密我的磁盘”时的默认值): 挂载之前必须先解密 LUKS 容器:sudo cryptsetup luksOpen /dev/nvme0n1p3 cryptroot sudo vgchange -ay # Activates LVM volumes inside LUKS if used sudo mount /dev/mapper/cryptroot /mnt # (Or /dev/mapper/ubuntu--vg-ubuntu--lv) sudo mount /dev/nvme0n1p2 /mnt/boot # Mount separate unencrypted /boot partition sudo mount /dev/nvme0n1p1 /mnt/boot/efi # Mount FAT32 EFI partition - 案例 3:Btrfs 文件系统
@子卷(Fedora、openSUSE 和 Ubuntu Btrfs 安装上的默认值): 如果挂载 Btrfs 分区而不指定subvol=@,/mnt只会显示@和@home文件夹而不是/bin和/etc, 和chroot /mnt将会失败failed to run command '/bin/bash': No such file or directory。安装@子卷明确:
步骤2:绑定虚拟内核文件系统(包括UEFI efivars)并输入 chroot¶
对于 grub-install 和 apt (DNS 互联网访问)在内部工作 chroot,将 Live USB 的虚拟内核目录和 UEFI NVRAM 变量绑定挂载到 /mnt:
# Bind-mount virtual device, process, sysfs, run (for DNS resolv.conf), and UEFI variables:
for dir in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do
sudo mount --bind $dir /mnt$dir
done
# Step inside your installed Linux system:
sudo chroot /mnt /bin/bash
第三步:修复包,重建 initramfs,并在里面重新安装GRUB chroot¶
现在您的提示显示 root@ubuntu:/#,运行适用于您的发行版的修复命令:
# 1. Fix any half-installed kernel upgrades (Ubuntu/Debian):
dpkg --configure -a
apt-get install -f -y
# 2. Rebuild the initial ramdisk for all installed kernels:
update-initramfs -c -k all # (Debian / Ubuntu / Mint)
# dracut --regenerate-all --force # (Fedora / RHEL / Rocky)
# mkinitcpio -P # (Arch / Manjaro)
# 3. Reinstall GRUB to the EFI System Partition and regenerate grub.cfg:
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --recheck
update-grub # (Or: grub2-mkconfig -o /boot/grub2/grub.cfg on Fedora)
第 4 步:干净退出并重新启动¶
根据要求拔下 Live USB 驱动器。您的系统将直接启动到修复后的 GRUB 菜单和 Linux 桌面。区域企业标准、数据中心合规性和硬件认证¶
企业 Linux 引导加载程序管理和固件安全受到严格的国家标准和网络安全框架的约束:
- 美国: 政府和企业基础设施遵守国家标准与技术研究所 (NIST) 特别出版物 800-147B(服务器 BIOS 保护指南)和 SP 800-193(平台固件弹性指南)。运行 Red Hat Enterprise Linux (RHEL) 或 Rocky Linux 的联邦安装必须符合国防信息系统局 (DISA) 安全技术实施指南 (STIG)。这些标准要求对 GRUB 2 启动菜单进行密码保护,禁用交互式内核参数编辑,使用 Shim 第一阶段加载程序启用 UEFI 安全启动,并使用经 FIPS 140-⅔ 验证的 LUKS 加密模块加密根存储。
- 英国: 国家网络安全中心 (NCSC) 发布了企业 Linux 平台的设备安全指南,强制要求基于硬件的平台完整性。跨政府或关键国家基础设施部署的系统必须使用可信平台模块 (TPM 2.0) 测量来根据平台配置寄存器 (PCR) 密封 LUKS 磁盘加密密钥,确保仅当 UEFI 固件、安全启动密钥和 GRUB 二进制文件完全未被篡改时驱动器才会自动解锁。
- 欧盟: 在欧盟,德国联邦信息安全办公室 (BSI) 通过 IT-Grundschutz 构建块 SYS.1.3(服务器 Linux 和 Unix)建立基线安全性。 BSI 指南要求严格分离引导分区、不可变的引导加载程序配置和经过审核的维护程序。根据欧盟网络和信息安全指令 (NIS 2),运营基本数字服务的实体必须维护经过验证的裸机灾难恢复程序,以满足操作系统故障期间的恢复时间目标 (RTO)。
- 加拿大: 加拿大网络安全中心 (CCCS) 根据 ITSG-33(IT 安全风险管理)提供指导,指定企业 Linux 操作环境的控制措施。根据《个人信息保护和电子文档法》(PIPEDA),进行引导加载程序恢复或控制器更换的物理服务器硬盘必须使用硬件或卷级加密,以防止在维修期间数据泄露。
- 澳大利亚: 澳大利亚信号局 (ASD) 发布了信息安全手册 (ISM),其中规定了企业 Linux 系统的要求。 ISM 要求组织强制实施 UEFI 安全启动,保护引导加载程序配置免受未经身份验证的更改,并将紧急维护 shell 访问记录到集中审计存储库中,以保持对八项基本缓解策略的遵守。
常见问题¶
Why did my dual-boot Linux GRUB menu disappear after a Windows 10 or Windows 11 update?
Major Windows feature updates frequently reset the motherboard's UEFI NVRAM boot priority order, placing "Windows Boot Manager" back at #1 above "ubuntu" or "fedora" without actually deleting your Linux files. Before booting a Live USB, first enter your motherboard BIOS/UEFI settings at startup (press `F2`, `F12`, or `Del`) and check the **Boot Order / UEFI Boot Priority** list, often you can simply move `ubuntu` or `GRUB` back above `Windows Boot Manager`, save with `F10`, and your GRUB menu returns immediately. You can also run `bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi` inside an Administrator Command Prompt in Windows to restore GRUB without a USB stick.
Why does `chroot /mnt` say `failed to run command '/bin/bash': No such file or directory` when I try to rescue my system?
This error happens for one of three reasons: (1) You accidentally mounted your small `/boot` or `EFI` partition to `/mnt` instead of your main Linux root partition (verify with `ls /mnt`, you should see `bin`, `etc`, `usr`, and `var`); (2) your system uses the **Btrfs** filesystem with subvolumes, so `ls /mnt` only shows `@` and `@home`, unmount `/mnt` and remount with `sudo mount -o subvol=@ /dev/nvme0n1p2 /mnt` (or `subvol=root` on Fedora); or (3) you accidentally booted a 32-bit Live USB stick while trying to `chroot` into a 64-bit (`x86_64`) Linux installation.
What does the kernel panic message `VFS: Unable to mount root fs on unknown-block(0,0)` mean at boot?
This kernel panic means the Linux kernel started without a valid `initramfs` (initial RAM disk) image, usually because a system update was interrupted while generating `/boot/initrd.img-...` or because your `/boot` partition ran out of space during a kernel upgrade. Reboot, hold `Shift` or tap `Esc` to open the GRUB menu, select **"Advanced options"**, and boot into the previous older kernel listed right below the newest one. Once logged into your desktop on the older kernel, free up space in `/boot` with `sudo apt autoremove --purge` and rebuild the broken ramdisk with `sudo update-initramfs -c -k all && sudo update-grub`.
How can I temporarily bypass broken graphics drivers from the GRUB menu using `nomodeset`?
If your monitor turns completely black or loses signal right after the GRUB menu due to a GPU driver problem, reboot and tap `Esc` or hold `Shift` to open the GRUB menu. Highlight your Linux entry and press **`e`** on your keyboard. Use the arrow keys to find the line starting with `linux /boot/vmlinuz...`, move to the end of that line where it says `quiet splash`, and replace `quiet splash` with **`nomodeset`**. Press **`Ctrl + X`** or **`F10`** to boot. The `nomodeset` parameter tells the Linux kernel not to load hardware video drivers until after Xorg starts, using basic BIOS framebuffer graphics so you can see your screen and fix your GPU drivers.
Why did `grub-install` inside `chroot` warn that `EFI variables are not supported on this system`?
That error occurs for one of two reasons: either you accidentally booted your Live USB flash drive in **Legacy BIOS / CSM mode** instead of **UEFI mode** when selecting it in your motherboard's F12 boot menu (check by running `ls /sys/firmware/efi`, if that folder does not exist on the Live USB, reboot and select the `"UEFI: [USB Drive Name]"` entry in your BIOS boot menu), OR you forgot to bind-mount `/sys/firmware/efi/efivars` into `/mnt/sys/firmware/efi/efivars` before running `chroot /mnt`.
How do I prevent a secondary external or internal hard drive in `/etc/fstab` from ever crashing my Linux boot again?
Whenever you add any non-root storage drive (such as a second SSD, a RAID array, an external USB backup drive, or a network Samba/NFS share) to `/etc/fstab`, always include **`nofail,x-systemd.device-timeout=10`** in the fourth column (mount options), and set the sixth column (`pass` / `fsck` order) to **`0`** or **`2`**. With `nofail` enabled, if that drive is ever unplugged or fails, `systemd` waits only 10 seconds, logs a non-fatal warning, and boots normally into your desktop instead of dropping you into Emergency Mode.
急救认证和技术工作场所安全¶
硬件级启动诊断通常需要打开台式机机箱、更换电源或检查服务器机架设备。技术人员面临着因损坏的电容器、因锋利的金属板底盘造成的割伤以及因重型机架安装硬件造成的挤压伤而造成的严重电气危险。如果发生触电,请在接触受害者之前立即断开断路器并致电紧急服务部门。在服务器机房中,了解如何进行心肺复苏和处理严重出血或休克与技术故障排除一样重要。我们建议通过红十字会、圣约翰救护车或国家安全机构完成认可的急救、心肺复苏/自动体外除颤器以及工作场所健康和安全课程。
来源已检查¶
- GNU 项目/自由软件基金会(国际):官方 GNU GRUB 手册 2.12,从
grub>和grub rescue>命令外壳(gnu.org/software/grub/manual)。 - Linux 内核档案和 Kernel.org(国际):内核参数 (
admin-guide/kernel-parameters.txt),initramfs早期的用户空间和文件系统管理(docs.kernel.org)。 - 规范/Ubuntu 服务器和桌面文档(英国/国际):GRUB2 引导加载程序恢复、LiveCD Chroot 过程和磁盘空间管理(
help.ubuntu.com,ubuntu.com/server/docs)。 - Red Hat Enterprise Linux (RHEL) 和 Fedora 项目文档(美国):使用以下命令排除引导问题
dracut,xfs_repair, 和grub2-mkconfig(docs.redhat.com,docs.fedoraproject.org)。 - Arch Linux Wiki(国际):GRUB、Chroot、
fstab, 和mkinitcpio技术参考(wiki.archlinux.org)。 - Freedesktop.org/systemd 文档(国际):
systemd.unit紧急救援目标,journalctl吸尘,以及systemd.mount选项(freedesktop.org/software/systemd/man)。