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).

  • Just a heads up, you confuse whatever setup-grub on your machine is with update-grub, but seem to have found that out by yourself already. To answer your comment: "Why did Canonical provide us with a Kernel package that doesn't wrok and actually harms the computer?" Don't assume such a thing, check that the kernel packages have been installed and initramfs images generated properly with all the modules that your machine needs. If the machine still does not properly boot up then disable the boot splash and note down the information or take a photo and report a bug. – LiveWireBT Nov 11 '15 at 19:03
  • I don't understand some stuff. What is boot splash? What is initramfs? – Adrians Netlis Nov 11 '15 at 19:56
  • Disable boot splash temporarily http://askubuntu.com/q/5065/40581 – the command to update initramfs http://manpages.ubuntu.com/manpages/trusty/en/man8/update-initramfs.8.html (sudo update-initramfs -u -k <version> or -k all for all) – more detail about initramfs https://wiki.ubuntu.com/Initramfs – LiveWireBT Nov 11 '15 at 20:25
  • Aww... I don't like anything releated to that stuff... Anything releated to system. Do you know if this bug has been reported and if Ubuntu is fixing it? – Adrians Netlis Nov 12 '15 at 11:29

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
  • 161
  • 7
rustyx
  • 917
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,035
  • Nop! Didn't work out... gnulinux-4.2.0-16-generic-advanced-2e2221b2-b6c7-4553-815f-67afdc924a98 I pasted this line. I updated grub. But it still leads to not working version. P.S. Why did Canonical provide us with a Kernel package that doesn't wrok and actually harms the computer? – Adrians Netlis Nov 11 '15 at 13:06
  • I edited the line to above could you please see if it works now, there is text entered till >. Please review and see if it works now. – Raphael Nov 11 '15 at 13:08
  • You mean it how?

    The full lines:

    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-16-generic-advanced-2e2221b2-b6c7-4553-815f-67afdc924a98' { echo 'Loading Linux 4.2.0-16-generic ...' linux /boot/vmlinuz-4.2.0-16-generic root=UUID=2e2221b2-b6c7-4553-815f-67afdc924a98 ro quiet splash $vt_handoff initrd /boot/initrd.img-4.2.0-16-generic

    – Adrians Netlis Nov 11 '15 at 13:12
  • @AdriansNetlis - See the answer now, its been edited. – Raphael Nov 11 '15 at 13:16
  • OK! Still nothing...:( Adding > and another copy of line didn't solve it. BTW, is it possible to access latest few boot logs? Maybe they can tell us something? – Adrians Netlis Nov 11 '15 at 13:23
  • I just did it to test your question on my laptop and it works, though in the grub menu you might see the star beside the Advanced option, but it will boot your chosen kernel on timeout. – Raphael Nov 11 '15 at 13:25
  • I will edit my answer with your UUID, just copy and paste it. – Raphael Nov 11 '15 at 13:26
  • http://www.pasteall.org/62156 Still doesn't work... It looks like this(the etc/default/grub) – Adrians Netlis Nov 11 '15 at 13:40
  • @AdriansNetlis - You didn't paste it correctly. Check again carefully. – Raphael Nov 11 '15 at 13:48
  • firstly - you added space before =. But even without it, it still didn't work. I copied your text pretty accurately(as accurately as Ctrl+C does, lol). – Adrians Netlis Nov 11 '15 at 17:22
  • But the link that you shared has the wrong code, you can compare if you see. – Raphael Nov 11 '15 at 17:25
  • http://www.pasteall.org/62158 What about this one? And it doesn't work... – Adrians Netlis Nov 11 '15 at 17:47
  • Yes thats correct. But I did the same thing and its working for me. :'( – Raphael Nov 11 '15 at 17:48
  • Maybe your kernels are not broken? So if the syntax of it have mistake, it sets it to use 0 instead of what is located there, I guess. And for you 0 works, but not for me. However, I tried all the numbers from 0 to 4 and none worked... – Adrians Netlis Nov 11 '15 at 17:56
  • Yes thats the only difference, mine aren't broken. – Raphael Nov 11 '15 at 17:58
  • But why did some people receive broken 4.2.0-17 and 4.2.0-18, but others did not? Wait a minute - did I actually try the 4.2.0-18, lol? I had set it to 4 before latest updated. I forgot to sudo update-grub when I think so now... Maybe I must try running 18? – Adrians Netlis Nov 11 '15 at 18:01
  • Hmm Maybe, please share your results – Raphael Nov 11 '15 at 18:03
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!:)