2

I'm running a fresh Ubuntu 16.04.2 on a brand new machine (2 weeks old), but 2 nights ago (May 2-3) a kernel update completely broke my system. I have reasons to believe I could fix it if I could tell grub to pick an older kernel at startup.

Problem, this is a single-boot install so grub's menu is disabled by default, and I can't get it to show up by pressing Shift, repeatedly or not (or hitting the space bar or whatever.) So far I can only get grub's command-line interface to show up by pressing Esc. That's all I have at the moment as I can't even open a session, less so a terminal, so I can't edit grub's config file or anything else.

I've tried to do

grub> configfile /boot/grub/grub.cfg

but it just tries to launch my system as usual without me being able to interfere to pick another kernel.

I've heard it's possible to launch grub's menu interface from the CLI, but it isn't explained how one is supposed to do that in the manual. At the moment, it seems to be my only option. Ideas?

EDIT: Since I can't edit config files or use Shift to bring up the grub menu, this is NOT a duplicate of this other question

d a i s y
  • 5,511
Jaumito
  • 23
  • That is not how you most easily boot an old kernel. Hold the shift key see https://askubuntu.com/questions/82140/how-can-i-boot-with-an-older-kernel-version . If you use grub command line use tab completion. – Panther May 04 '17 at 17:22
  • @bodhi.zazen: as I wrote above holding the shift key did nothing at all in my case. TopHat's solution wasn't exactly the answer I was looking for, but it solved my problem anyway (thanks again, man!) – Jaumito May 04 '17 at 20:13
  • Voting to Reopen - The duplicate doesn't address the fact the Shift Key doesn't bring up the grub menu in order to select an older kernel version. There is an answer below which addresses this fact. – WinEunuuchs2Unix Mar 24 '18 at 00:27

1 Answers1

4

You can manually select the kernel and initrd from the GRUB command line. This will only change things for the one boot though. After the system booted up you'd have to make the necessary adjustments to GRUB in order to make it permanent.

grub> set root=(hd<disk with kernel and initrd>,msdos<partition with kernel and initrd>)
grub> linux /boot/vmlinuz-<kernel version you want to boot from> root=/dev/<root device>
grub> initrd /boot/initrd-<same version as chosen kernel>
grub> boot

Depending on if /boot were a seperate partition, that above can be slightly different. You would set the initial root= to be the /boot disk and partition, then when delcaring linux and boot you wouldn't include boot/ since it would be starting in that directory. The root= in the linux line would still point to the root disk/partition though.

---Edit to include information from comments---

Based on what we've discussed in the comments you should try these commands to boot:

grub> set root=(hd1,gpt2)
grub> linux /boot/vmlinuz-<version you want to boot from> root=/dev/sdb2
grub> initrd /boot/initrd-<same version as chosen kernel>
grub> boot
TopHat
  • 3,971
  • I actually considered that, and will try it as a last resort. Because there's a list of parameters (like, root=UUID=I don't have any idea what is supposed to go here) that's rather intimidating to me. – Jaumito May 04 '17 at 16:59
  • @Jaumito Understandable. If you think you could provide me more details, I could probably get you a more specific set of commands to run in order to help you. Worst case scenario it fails to boot and we try again. ¯\(ツ) – TopHat May 04 '17 at 17:03
  • Thanks a lot. Well, just tell me what you need and I'll try to provide (if that helps, when I installed 16.04.2 I told it to overwrite the previous system and I don't think I did anything funny, so (hd0), etc. should have their default value, even if I don't really know what they mean. If I can get anything useful from the grub CLI, just ask. – Jaumito May 04 '17 at 17:11
  • 1
    @Jaumito the most useful output will be what shows when you try to tab complete some of these commands. So for example, type in set root=(hd and then hit tab twice to see if it fills in 0 for you or provides you with options. Then do set root=(hd0,msdos and hit tab twice again. Also for the linux command do a linux and then hit tab twice and it should show the filesystem. If you see a /boot directory then do linux /boot/ and hit tab twice again. That should give me enough to start with. Paste the results into a pastebin.com link since that will most likely be a lot of output. – TopHat May 04 '17 at 17:15
  • set root=(hd gives hd0 hd1 followed by error messages crap forget this can't edit will give a better summary in a few mins – Jaumito May 04 '17 at 17:21
  • set root=(hd
    • replies with

    hd0 hd1 immediately (no break line) followed by 3 reading error messages on sectors 0xfc, 0xe0, 0x0 on hd0. Doesn't look too good, does it?

    set root=(hd0,msdos

    • is unresponsive.

    ls

    • replies

    (hd0) (hd1) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) followed by the same errors messages as above.

    There's certainly a /boot, I'd checked that previously with ls /boot and the kernels are all there. The one I'm supposed to run to fix my problem has the 4.8.0-49-generic suffix.

    – Jaumito May 04 '17 at 17:47
  • @Jaumito what does this show? set root=(hd1,gpt then tab twice. – TopHat May 04 '17 at 17:52
  • hd1,gpt1: FAT, UUID B658-3F7A - begins at 1024 K - total size 524288 K hd1,gpt2: ext*, UUID 31cc8370-c8ba-44c2-9322-b30ae96b97e4 - begins at 525312 K - totsize ~ 967881728 K hd1,gpt3: unknown - begins at 968407040 K - totsize 8354816 K – Jaumito May 04 '17 at 18:03
  • @Jaumito I edited my answer to have specific commands for you to try. On the linux command I'm hoping you didn't use LVM or something and that the hd disks match hd0 -> sda, hd1 -> sdb. I'm fairly certain your root filesystem is on gpt2 since it's has the standard filesystem defaulted by Ubuntu during install – TopHat May 04 '17 at 18:10
  • @Jaumito if you want to advise me what specific kernel version you're wanting to boot from I can include that in my response as well – TopHat May 04 '17 at 18:11