Ubuntu+Windows双系统修复引导+更改启动顺序

修改 GRUB 配置(推荐)

在 Ubuntu 中按 Ctrl + Alt + T 打开终端,执行以下命令编辑 GRUB 配置文件:

bash 复制代码
sudo nano /etc/default/grub

配置文件中关键参数说明:

conf 复制代码
GRUB_DEFAULT=0                # 默认启动项索引(从0开始)
GRUB_TIMEOUT=10               # 菜单显示等待时间(秒)
GRUB_TIMEOUT_STYLE=menu       # 显示样式(hidden/menu)

确定 Windows 启动项位置:

bash 复制代码
grep "menuentry" /boot/grub/grub.cfg

设置默认启动项(两种方式):

conf 复制代码
GRUB_DEFAULT=1                # 数字索引方式(示例为第2项)
GRUB_DEFAULT="Windows Boot Manager (on /dev/sda1)"  # 精确名称匹配
#如果是固态硬盘则设置如下:
GRUB_DEFAULT="Windows Boot Manager (on /dev/nvme0n1p1)"

调整超时时间(可选):

conf 复制代码
GRUB_TIMEOUT=5                # 建议保留3秒以上操作时间

保存修改并更新配置:

bash 复制代码
sudo update-grub
sudo reboot

使用 GRUB 自定义菜单(高级)

创建自定义配置文件:

bash 复制代码
sudo nano /etc/grub.d/40_custom

添加自定义启动项示例:

conf 复制代码
menuentry "Windows 10 (Custom)" {
    insmod part_gpt
    insmod chain
    set root='(hd0,gpt1)'
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

更新配置后验证:

bash 复制代码
sudo update-grub
grub-mkconfig | grep "menuentry"  # 检查新条目

应急恢复方案

当配置错误导致无法启动时:

  1. 使用 Ubuntu 安装U盘启动
  2. 选择"Try Ubuntu"进入Live模式
  3. 挂载原系统分区并修复:
bash 复制代码
sudo mount /dev/sda2 /mnt
sudo mount /dev/sda1 /mnt/boot/efi
sudo chroot /mnt
grub-install /dev/sda
update-grub

注意事项

  • 修改前建议备份原配置文件:
bash 复制代码
sudo cp /etc/default/grub /etc/default/grub.bak
  • 精确名称匹配时需注意:
    • 区分英文引号与中文引号
    • 保留原始条目中的特殊符号
    • EFI分区路径可能随硬件变化

验证配置

成功更新后,终端会显示:

复制代码
Generating grub configuration file ...
Found Windows Boot Manager on /dev/sda1
done
相关推荐
淮北49412 小时前
ubuntu22 默认输入法调整频率
运维·服务器·git·ubuntu·elasticsearch
码字的特恩12 小时前
微软确认暂不为 Windows 11 加入透明效果自定义功能,建议用户使用第三方工具
人工智能·windows·算法·microsoft·计算机·大模型·编程
神奇小梵12 小时前
安全和开发的需要了解的知识————下载内容的安全,和下载内容如何运行
android·windows·安全·个人开发
雾时之林12 小时前
Linux---计算机网络常见面试题
linux·运维·计算机网络
10mAh13 小时前
【Linux】error while loading shared libraries 怎么解决?——ldd、RPATH 与动态链接排错
java·linux·前端
zhangfeng113313 小时前
Windows AMD显卡跑PyTorch
人工智能·pytorch·windows
楷哥爱开发13 小时前
如何在 Windows、macOS 和 Linux 上安装 scikit-learn (sklearn)
linux·windows·macos
十年磨一剑~13 小时前
CAAM不落盘存储密钥方式处理
linux·ubuntu
zhangrelay13 小时前
ROS 2 Lyrical 第2章 ROS 2系统架构与核心概念
linux·笔记·学习·ubuntu·ros2
2603_9651481113 小时前
eBay商品数据API:寻找海外仓与价格洼地
大数据·人工智能·windows·python·microsoft