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



1、编辑 /etc/default/grub



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:

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

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

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:

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:


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.