linux-GRUB_DEFAULT似乎在尝试通过Debian 8上的ID引导自定义内核时无效

前端之家收集整理的这篇文章主要介绍了linux-GRUB_DEFAULT似乎在尝试通过Debian 8上的ID引导自定义内核时无效前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Debian 8机器上构建了一个自定义内核,我想将它设置为默认值.一个看似简单的任务,但我不能让它为我的生活工作.

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

  1. $sudo make modules_install install

这在grub中安装了一个新的菜单项,如果你在启动时手动选择它,它确实有效.这很好.

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

  1. 'GRUB_DEFAULT'
  2. The default menu entry. This may be a number,in which case it
  3. identifies the Nth entry in the generated menu counted from zero,or the title of a menu entry,or the special string 'saved'. Using
  4. the id may be useful if you want to set a menu entry as the default
  5. even though there may be a variable number of entries before it.
  6.  
  7. For example,if you have:
  8.  
  9. menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
  10. ...
  11. }
  12.  
  13. then you can make this the default using:
  14.  
  15. GRUB_DEFAULT=example-gnu-linux
  16.  
  17. PrevIoUsly it was documented the way to use entry title. While
  18. this still works it's not recommended since titles often contain
  19. unstable device names and may be translated
  20.  
  21. If you set this to 'saved',then the default menu entry will be
  22. that saved by 'GRUB_SAVEDEFAULT' or 'grub-set-default'. This
  23. relies on the environment block,which may not be available in all
  24. situations (*note Environment block::).
  25.  
  26. The default is '0'.

首先,从散文中不清楚“id”是否与“title”相同.除此之外,看起来我应该在生成的grub配置中的–id之后使用字符串.

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

  1. 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' {
  2. load_video
  3. insmod gzio
  4. if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
  5. insmod part_msdos
  6. insmod ext2
  7. set root='hd0,msdos1'
  8. if [ x$feature_platform_search_hint = xy ]; then
  9. search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-bareMetal=ahci0,msdos1 197f20c1-1808-41b5
  10. -831f-b85a40358757
  11. else
  12. search --no-floppy --fs-uuid --set=root 197f20c1-1808-41b5-831f-b85a40358757
  13. fi
  14. echo 'Loading Linux 3.16.36krunsystickless+ ...'
  15. linux /boot/vmlinuz-3.16.36krunsystickless+ root=UUID=197f20c1-1808-41b5-831f-b85a40358757 ro quiet console=ttyS0,115200n8 intel_psta
  16. te=disable
  17. echo 'Loading initial ramdisk ...'
  18. initrd /boot/initrd.img-3.16.36krunsystickless+
  19. }

在设置文件$menuentry_id_option的前面的位置:

  1. if [ x"${feature_menuentry_id}" = xy ]; then
  2. menuentry_id_option="--id"
  3. else
  4. menuentry_id_option=""
  5. fi

所以假设我应该将/ etc / grub / default中的GRUB_DEFAULT设置为:

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

然后运行:

  1. $sudo update-grub
  2. Generating grub configuration file ...
  3. Found linux image: /boot/vmlinuz-3.16.36softdevnohzfullall
  4. Found initrd image: /boot/initrd.img-3.16.36softdevnohzfullall
  5. Found linux image: /boot/vmlinuz-3.16.36krunsystickless+
  6. Found initrd image: /boot/initrd.img-3.16.36krunsystickless+
  7. Found linux image: /boot/vmlinuz-3.16.36krunsystickless+.old
  8. Found initrd image: /boot/initrd.img-3.16.36krunsystickless+
  9. Found linux image: /boot/vmlinuz-3.16.0-4-amd64
  10. Found initrd image: /boot/initrd.img-3.16.0-4-amd64
  11. done

在最终重启之前.

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

我尝试过的其他事情:

>数字索引GRUB_DEFAULTS – 似乎没有任何效果.
>转义内核ID中的加号.
> grub-set-default

我现在要调查feature_menuentry_id,但我觉得这将是一个红鲱鱼.如果有人能在此期间让我摆脱苦难,我将非常感激.

谢谢

解决方法

最后,我设法使用/ etc / default / grub中的以下行启动我的内核:
  1. 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菜单. >上面(我没有在文档btw中找到)意味着“进入这个子菜单”.

我希望这有助于其他人对同一问题感到困惑.

干杯

猜你在找的Linux相关文章