当前位置:首页 > linux > 正文

linux grub修改启动项(linux grub模式下命令)

  • linux
  • 2024-03-15 21:05:21
  • 9758
Linux GRUB 修改启动项
GRUB(Grand Unified Bootloader) 是 Linux 系统中常用的启动加载器,负责在计算机启动时加载操作系统。 要修改 GRUB 启动项,需要编辑配置文件 /boot/grub/grub.cfg。
修改要素:
1. 启动项标题
title My Custom Boot Option
为启动项指定一个名称。
2. 内核镜像
linux /boot/vmlinuz-5.15.0-52-generic
指定要加载的内核镜像。
3. 内核参数
initrd /boot/initrd.img-5.15.0-52-generic
指定与内核一起传递的初始 RAM 磁盘。
4. 启动选项
options quiet splash
指定启动内核时使用的额外选项。
5. 根设备
root (hd0,msdos1)
指定要挂载为根设备的分区。
举例:
添加一个新的启动项,将内核 5.15.0-52-generic 加载为静默模式:
menuentry "My Custom Boot Option" {
title My Custom Boot Option
linux /boot/vmlinuz-5.15.0-52-generic initrd /boot/initrd.img-5.15.0-52-generic
options quiet
}
修改现有启动项以使用不同的内核版本:
menuentry "Ubuntu" {
title Ubuntu
linux /boot/vmlinuz-5.15.0-47-generic initrd /boot/initrd.img-5.15.0-47-generic
}
从 GRUB 菜单中删除一个启动项:
sudo sed -i '/title My Custom Boot Option/d' /boot/grub/grub.cfg