简单使用grub shell

这篇博客介绍了如何在虚拟机中搭建测试环境,利用Linux维护盘创建虚拟机,并详细讲解了如何在Grub2 Shell中查看磁盘分区及手动引导系统。还提到了Grub2的配置文件位置,并给出了Linux Mint Cindy、Ubuntu 18.04及PhoenixOS的配置实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

搭建测试环境

使用deepinLinux维护盘 :https://www.deepin.org/en/download/,选择下载deepin live

使用virtualbox安装deepin linux live,vmware貌似不支持EFI,开启后直接中断。

在virtualbox中新建虚拟机

名称:grub2

固定大小:2G(自己分配)

内存:1024M

创建完选择grub2,选择设置\系统\启用EFI

确定完运行虚拟机,iso选择深度维护光盘。

在选择菜单按c进入grub shell

grub>

右边的ctrl退出虚拟机对鼠标键盘的控制

使用grub shell

grub shellLinux Shell类似,tab补全命令,help查看帮助。

查看win10磁盘分区情况

grub> ls
(hd0) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1,gpt2) (hd1,gpt1)

hd0为物理C盘,hd1为物理D盘。用DiskGenius可以查看分区内容。

(hd0,gpt1)为C盘第一分区:ESP分区

(hd0,gpt2)为C盘第二分区:MSR分区

(hd0,gpt3)为C盘第三分区:Primary分区

grub> set root=(hd0,gpt1)
grub> ls /
efi/
grub> chainloader /efi/linuxmint/grubx64.efi

chainloader手动引导系统,Linux下为linux(旧版为kernel)

grub> insmod video
grub> halt
grub> reboot

安装模块,关机,开机。

grub manual https://www.gnu.org/software/grub/manual/grub/grub.html

grub配置文件

文件位置:/boot/grub/grub.cfg

一些实例

Linux Mint Cindy

if loadfont /boot/grub/font.pf2 ; then
	set gfxmode=auto
	insmod efi_gop
	insmod efi_uga
	insmod gfxterm
	terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

menuentry "Start LMDE 3 Cinnamon 64-bit" {
    set gfxpayload=keep
    linux   /live/vmlinuz boot=live live-config live-media-path=/live quiet splash --
    initrd  /live/initrd.lz
}
Ubuntu 18.04
menuentry "Try Ubuntu without installing" {
	set gfxpayload=keep
	linux	/casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash ---
	initrd	/casper/initrd
}
menuentry "Install Ubuntu" {
	set gfxpayload=keep
	linux	/casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity quiet splash ---
	initrd	/casper/initrd
}
PhoenixOS
set timeout=5
set gfxmode=1024x768
#terminal_output gfxterm
set default=Windows

if [ -s /EFI/Boot/grubenv ]; then
	set have_grubenv=true
	load_env
fi

if [ "${next_entry}" ]; then
	set default="${next_entry}"
	set next_entry=
	save_env next_entry
	set timeout=0
fi

menuentry 'Windows' {
	search --file --no-floppy --set=root /EFI/Microsoft/Boot/bootmgfw.efi
	chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}

menuentry "Phoenix OS" {
	search --file --set=root /EFI/PhoenixOS/kernel
	linux /EFI/PhoenixOS/kernel quiet root=/dev/ram0 androidboot.hardware=android_x86 SRC=/PhoenixOS vga=788
	initrd /EFI/PhoenixOS/initrd.img
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值