4

I did this setup due to Kernel upgrade bug:

GRUB_DEFAULT = 4

in /etc/default/grub

Than I executed

sudo setup-grub

However, it didn't work out. My desired version is 4.2.0-16-generic, because 4.2.0-18 and 4.2.0-17(which actually isn't listed) doesn't work. In the list, 4.2.0-16 is 4th.

When it didn't work, I tried this:

GRUB_DEFAULT = "Advanced options for Ubuntu>Ubuntu, with Linux 4.2.0-16-generic"

and

sudo setup-grub

however, it still didn't work and opened a not-working version of kernel. Currently I can only access 4.2.0-16 manually through Advanced options for Ubuntu, but I want it to load automaticly. What solution would you reccomend me?

The dpkg --list | grep linux-image outputs:

ii  linux-image-extra-4.2.0-16-generic                          4.2.0-16.19                                amd64        Linux kernel extra modules for version 4.2.0 on 64 bit x86 SMP
ii  linux-image-extra-4.2.0-17-generic                          4.2.0-17.21                                amd64        Linux kernel extra modules for version 4.2.0 on 64 bit x86 SMP
ii  linux-image-extra-4.2.0-18-generic                          4.2.0-18.22                                amd64        Linux kernel extra modules for version 4.2.0 on 64 bit x86 SMP
ii  linux-image-generic                                         4.2.0.18.20                                amd64        Generic Linux kernel image

as a last 4 outputs(only ones for Ubuntu 15.10 which contains Kernel 4.2.0).

4 Answers4

8

You need to use the IDs of the corresponding submenu and menuentry lines.

Note "Advanced options for Ubuntu" is a submenu, you need to use its ID.

Run grep -E "^\\s*(menuentry|submenu) " /boot/grub/grub.cfg

For example if the output is:

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
        menuentry 'Ubuntu, with Linux 4.4.0-140-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-140-generic-advanced-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
        menuentry 'Ubuntu, with Linux 4.4.0-140-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-140-generic-init-upstart-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
        menuentry 'Ubuntu, with Linux 4.4.0-140-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-140-generic-recovery-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
        menuentry 'Ubuntu, with Linux 4.4.0-101-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-101-generic-advanced-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
        menuentry 'Ubuntu, with Linux 4.4.0-101-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-101-generic-init-upstart-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
        menuentry 'Ubuntu, with Linux 4.4.0-101-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-101-generic-recovery-7da0d9d5-45bc-40e4-b17e-18cff7a59b76' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {

The correct setting would be:

GRUB_DEFAULT="gnulinux-advanced-7da0d9d5-45bc-40e4-b17e-18cff7a59b76>gnulinux-4.4.0-101-generic-advanced-7da0d9d5-45bc-40e4-b17e-18cff7a59b76"

Note you can also use a 0-based numbering, but do take the submenu entries into account:

GRUB_DEFAULT="1>3"

Don't forget to run update-grub at the end.

Per Lundberg
  • 163
  • 8
rustyx
  • 1,066
  • 15
  • 17
5
  1. Take a backup of your current grub.

    sudo cp /etc/default/grub /etc/default/grub.bak

  2. Now, open the file.

    sudo gedit /etc/default/grub

  3. Open another terminal and type:

    cat /boot/grub/grub.cfg | grep 4.2.0-16

    You will see a line like this:

    menuentry 'Ubuntu, with Linux 4.2.0-16-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.2.0-18-generic-advanced-esx5367c-b4ug-19sd-v6j8-ty2hj01ui3kj' {..........

  4. Copy this line & paste it:

EDITED FROM:

GRUB_DEFAULT ="gnulinux-4.2.0-16-generic-advanced-2e2221b2-b6c7-4553-815f-67afdc924a98"

EDITED TO:

GRUB_DEFAULT ="gnulinux-advanced-2e2221b2-b6c7-4553-815f-67afdc924a98>gnulinux-4.2.0-16-generic-advanced-2e2221b2-b6c7-4553-815f-67afdc924a98"

  1. Save the file.

  2. Now, type the command:

    sudo update-grub

Raphael
  • 8,135
0

Little bash function to list all Ubuntu kernels suitable for inserting into GRUB_DEFAULT in /etc/default/grub

 MENUID=$( grep -E "^\\s*(submenu) " /boot/grub/grub.cfg  | grep -oP "gnuli.*(?=')"    )
grep '(?<=menuentry_id_option ).gnuli\S+' /boot/grub/grub.cfg  -Po | \
    sed "s@'@@g" |grep -vE 'recovery|simple|gnulinux-advanced' | sed "s@^@GRUB_DEFAULT=\"${MENUID}>@; s@\$@\"@"

Output:

GRUB_DEFAULT="gnulinux-advanced-20dfee37-ad84-49b2-8c69-a54699da855d>gnulinux-6.6.10-usb2-advanced-20dfee37-ad84-49b2-8c69-a54699da855d"
GRUB_DEFAULT="gnulinux-advanced-20dfee37-ad84-49b2-8c69-a54699da855d>gnulinux-5.15.0-35-generic-advanced-20dfee37-ad84-49b2-8c69-a54699da855d"

Then simply pick one and paste into /etc/default/grub & run update-grub & reboot.

0

OK! I found the solution. I had to link a PPA to grub-customizer.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer

Than I did:

sudo apt-get update

Next step is

sudo apt-get install grub-customizer

After that I open the grub-customizer through unity dash and select the desired kernel from there and tada!:)