我在Debian 8机器上构建了一个自定义内核,我想将它设置为默认值.一个看似简单的任务,但我不能让它为我的生活工作.
我使用官方源代码(通过git)构建我的内核,而不是使用我的debian提供的供应商tarball.构建完成后,我安装了内核和模块:
- $sudo make modules_install install
这在grub中安装了一个新的菜单项,如果你在启动时手动选择它,它确实有效.这很好.
现在,要默认启动它,我必须编辑/ 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”相同.除此之外,看起来我应该在生成的grub配置中的–id之后使用字符串.
因此,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设置为:
- 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-b85a40358757>gnulinux-3.16.36krunsystickless+-advanced-197f20c1-1808-41b5-831f-b85a40358757
该文档具有误导性.如果涉及子菜单,您不能简单地将ID放入GRUB_DEFAULT.您必须考虑使用(可能很多)ID导航grub菜单. >上面(我没有在文档btw中找到)意味着“进入这个子菜单”.
我希望这有助于其他人对同一问题感到困惑.
干杯