尝试在Debian 8上通过ID引导自定义内核时,GRUB_DEFAULT似乎不起作用

我在Debian 8机器上构build了一个定制的内核,我想将它设置为默认值。 一个看起来很简单的任务,但我不能为它的生活工作。

我使用官方的源代码(通过git)构build我的内核,而不是使用供应商tarball提供的debian。 一旦build成,我安装了内核和模块:

$ sudo make modules_install install 

这在grub中安装了一个新的菜单项,如果你在启动的时候手动select的话,这个菜单确实有效。 所以这很好。

现在,为了默认启动它,我必须编辑/etc/default/grub并更改GRUB_DEFAULT 。 在文件顶部是一个注释,指向用户的信息页面,其中说:

 'GRUB_DEFAULT' The default menu entry. This may be a number, in which case it identifies the Nth entry in the generated menu counted from zero, or the title of a menu entry, or the special string 'saved'. Using the id may be useful if you want to set a menu entry as the default even though there may be a variable number of entries before it. For example, if you have: menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux { ... } then you can make this the default using: GRUB_DEFAULT=example-gnu-linux Previously it was documented the way to use entry title. While this still works it's not recommended since titles often contain unstable device names and may be translated If you set this to 'saved', then the default menu entry will be that saved by 'GRUB_SAVEDEFAULT' or 'grub-set-default'. This relies on the environment block, which may not be available in all situations (*note Environment block::). The default is '0'. 

首先,散文中“id”与“title”是否相同尚不清楚。 除此之外,它看起来像我应该使用生成的grubconfiguration中的--id之后的string。

因此, make install将以下内容插入到/boot/grub/grub.cfg

  menuentry 'Debian GNU/Linux, with Linux 3.16.36krunsystickless+' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.36krunsystickless+-advanced-197f20c1-1808-41b5-831f-b85a40358757' { load_video insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 197f20c1-1808-41b5 -831f-b85a40358757 else search --no-floppy --fs-uuid --set=root 197f20c1-1808-41b5-831f-b85a40358757 fi echo 'Loading Linux 3.16.36krunsystickless+ ...' linux /boot/vmlinuz-3.16.36krunsystickless+ root=UUID=197f20c1-1808-41b5-831f-b85a40358757 ro quiet console=ttyS0,115200n8 intel_psta te=disable echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-3.16.36krunsystickless+ } 

其中,在文件$menuentry_id_option设置:

 if [ x"${feature_menuentry_id}" = xy ]; then menuentry_id_option="--id" else menuentry_id_option="" fi 

所以大概我应该把/etc/grub/default GRUB_DEFAULT /etc/grub/default为:

 gnulinux-3.16.36krunsystickless+-advanced-197f20c1-1808-41b5-831f-b85a40358757 

然后运行:

 $ sudo update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.16.36softdevnohzfullall Found initrd image: /boot/initrd.img-3.16.36softdevnohzfullall Found linux image: /boot/vmlinuz-3.16.36krunsystickless+ Found initrd image: /boot/initrd.img-3.16.36krunsystickless+ Found linux image: /boot/vmlinuz-3.16.36krunsystickless+.old Found initrd image: /boot/initrd.img-3.16.36krunsystickless+ Found linux image: /boot/vmlinuz-3.16.0-4-amd64 Found initrd image: /boot/initrd.img-3.16.0-4-amd64 done 

最后重启之前。

但是这似乎不起作用。 与以前相同的内核被引导。 有谁知道为什么?

其他的东西,我试过了:

  • 数字索引GRUB_DEFAULTS – 似乎没有效果。
  • 退出内核ID的加号。
  • grub-set-default

我现在要去看看feature_menuentry_id ,但我有一种感觉,那就是一条红色的鲱鱼。 如果有人能够让我摆脱我的痛苦,我将非常感激。

谢谢

最后,我设法用/etc/default/grub的以下行启动我的内核:

 GRUB_DEFAULT=gnulinux-advanced-197f20c1-1808-41b5-831f-b85a40‌​358757>gnulinux-3.16‌​.36krunsystickless+-‌​advanced-197f20c1-18‌​08-41b5-831f-b85a403‌​58757 

文档是误导性的。 如果涉及子菜单,则不能简单地将ID放入GRUB_DEFAULT 。 你必须考虑使用(可能很多)ID来浏览grub菜单。 上面的(我没有在文档中findbtw)的意思是“进入这个子菜单”。

我希望这可以帮助别人对同样的问题感到困惑。

干杯