Debian 8 GRUB2 自定义默认启动内核

参考链接:http://www.linuxquestions.org/questions/slackware-14/grub2-change-default-to-custom-kernel-4175547962/#post5391277

总结:

1、编辑 /etc/default/grub

GRUB_DEFAULT=saved

2、查看所有启动菜单入口

grep "submenu\|^\smenuentry" /boot/grub/grub.cfg | cut -d "'" -f2,4

输出格式为:标题’ID (中间以 ‘ 号间隔)

结果中含“Advanced options”的一行是 submenu ,底下紧跟的行是 menuentry。

3、设置默认启动菜单(内核),使用步骤2中的 ID 而非标题

#grub-set-default  "(submenu ID)>(menuentry ID)"

4、重新生成 /boot/grub/grub.cfg

#grub-mkconfig -o /boot/grub/grub.cfg

原文摘要:
GRUB2 change default to custom kernel

I have made the switch from LILO to GRUB2 on all my Slackware boxes. Still learning all the ins and outs. I am running into an issue though when I want to change the default kernel to a custom compiled on. No matter what I do, the changes won’t take. Has anyone been successful in doing so? I have tried playing around with changing GRUB_DEFAULT=saved to GRUB_DEFAULT=2 and even using the actual title, but no success. I’ve also tried this:
Code:

Open /etc/default/grub and ensure this line exists:

GRUB_DEFAULT=saved
Apply the change to grub.cfg by running:

grub-mkconfig -o /boot/grub/grub.cfg
Now list all possible menu entries

grep “submenu\|^\smenuentry” /boot/grub/grub.cfg | cut -d “‘” -f2
Now set the desired default menu entry

grub-set-default “<submenu title>><menu entry title>”
Verify the default menu entry

grub-editenv list

Which I modified from this link. Still no luck.

Any help would be appreciated.

Old 07-14-2015, 12:09 PM #2
stormtracknole
Member

Registered: Aug 2005
Location: The Big Easy
Distribution: Slackware, RHEL
Posts: 927

Original Poster
Rep: Reputation: 114Reputation: 114

Figured it out! For GRUB_DEFAULT, I was using:
Code:

GRUB_DEFAULT=”Slackware-14.1 GNU/Linux, with Linux 3.18.18-local”

However, upon running grub-mkconfig -o /boot/grub/grub.cfg, I was instructed to use this instead:
Code:

GRUB_DEFAULT=”gnulinux-advanced-e246d5eb-623e-4518-ae21-96df0820c0c3>gnulinux-3.18.18-local-advanced-e246d5eb-623e-4518-ae21-96df0820c0c3″

I’m sure this code will be different depending on the kernel version used and probably other factors. I ran the grub-mkconfig command again, and this time, the correct kernel was loaded. Marking this thread as solved. Hopefully it can be of help to others.