我想将新的菜单项添加到我的 GRUB2 列表中。这就是我尝试执行此操作的方法以及必要的信息:
埃罗斯从 GRUB2 列表中选择“Debian Wheezy”菜单条目后:
error:file not found
error:you need to load the kernel first
/etc/grub.d/12_debian
#!/bin/sh -e
cat << EOF
menuentry "Debian Wheezy" {
set root=(hd0,5)
linux /boot/vmlinuz-3.2.0-3-amd64
initrd /boot/initrd.img-3.2.0-3-amd64
}
EOF
ls /启动
config-3.2.0-3-amd64 initrd.img-3.2.0-3-amd64 vmlinuz-3.2.0-3-amd64
grub System.map-3.2.0-3-amd64
分区
sda1 - ntfs - Windows boot
sda2 - ntfs - Windows C:
sda3 - ntfs - Windows D:
sda4 - extended
-sda5 - ext4 - /boot
-sda6 - lvm - Debian testing
And inside sda6 there's LVM group calld G1 divided into volumes:
home, root, tmp, usr, var, swap
来源我在设置一切失败期间使用过的。
GRUB 2 引导加载程序 - Dedoimedo.com 上的完整教程
怎么了?
编辑#1
fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 83473739 41633446 7 HPFS/NTFS/exFAT
/dev/sda3 83473799 935802314 426164258 7 HPFS/NTFS/exFAT
/dev/sda4 935802315 976771071 20484378+ f W95 Ext'd (LBA)
/dev/sda5 935802880 936779775 488448 83 Linux
/dev/sda6 936781824 976771071 19994624 8e Linux LVM
编辑#2
Grub 控制台
linux /[TAB]
Possible files are:
lost+found/ bin/ share/ sbin/ lib/ include/ src/ games/ local/
set root=(hd0,msdos5)
linux/[TAB]
Possible files are:
lost+found/ config-3.2.0-3-amd64 vmlinuz-3.2.0-3-amd64 grub/
System.map-3.2.0-3-amd64 initrd.img-3.2.0-3-amd64
Grub 控制台、启动测试
set root=(hd0,msdos5)
linux /vmlinuz-3.2.0-3-amd64 root=/dev/G1/root
initrd /initrd.img-3.2.0-3-amd64
boot
#Many, many, many lines of text. After few seconds they stop. The most
#interesting i think are:
ALERT! /dev/G1/root does not exist. Dropping to a shell!
/bin/sh: can't access tty; job control turned off
再次尝试 /etc/grub.d/12_debian
#!/bin/sh -e
cat << EOF
menuentry "Debian Wheezy" {
insmod ext4
set root=(hd0,msdos5)
echo 'loading...'
linux /vmlinuz-3.2.0-3-amd64
echo 'starting kernel...'
initrd /initrd.img-3.2.0-3-amd64
}
EOF
结果:
error:file not found
loading...
starting kernel...
编辑#3
/boot/grub/grub.cfg 的一部分
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Debian GNU/Linux, with Linux 3.2.0-3-amd64' --class debian -- class gnu-linux --class gnu --class os {
insmod gzio
insmod lvm
insmod part_msdos
insmod ext2
set root='(G1-root)'
search --no-floppy --fs-uuid --set=root 94215fad-dcbe-4339-92be-f562b1b37133
echo 'Loading Linux 3.2.0-3-amd64 ...'
linux /boot/vmlinuz-3.2.0-3-amd64 root=/dev/mapper/G1-root ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.2.0-3-amd64
}
### END /etc/grub.d/10_linux ###
/etc/grub.d/12_debian 下次尝试
#!/bin/sh -e
cat << EOF
menuentry "Debian Wheezy" {
insmod ext4
set root=(hd0,msdos5)
echo 'loading...'
linux /vmlinuz-3.2.0-3-amd64 root=/dev/mapper/G1-root
echo 'starting kernel...'
initrd /initrd.img-3.2.0-3-amd64
}
结果
error:file not found
loading...
starting kernel...
答案1
因为您有一个专用的 /boot 分区(您可能不需要),该分区没有名为 /boot 的目录,因此找不到这些文件。从路径中删除 /boot。
答案2
menuentry "Debian Wheezy" {
insmod ext4
set root='(hd0,msdos5)'
echo 'loading ..'
linux /boot/vmlinuz-3.2.0-3-amd64
echo 'starting kernel ...'
initrd /boot/initrd.img-3.2.0-3-amd64
}
答案3
嗯...旧线程,但似乎从未产生有效的答案。我最近遇到了类似的问题,现已修复。对于其他有类似问题的人,我建议更改
set root='(hd0,msdos5)'
到以下
search --no-floppy --fs-uuid --set=root '5bbd33b6-3333-3a33-3333-8045d333bb63'
其中 1234-567A 是从以下位置获取的所需分区的 UUID
sudo blkid /dev/sda5
其结果如下所示。
/dev/sda1: LABEL="SYSTEM" UUID="5bbd33b6-3333-3a33-3333-8045d333bb63" TYPE="ext4" PARTLABEL="EFI system partition" PARTUUID="0c33e3ab-d3dc-3af3-333d-a33eee3c333c"