27

I can no longer boot Ubuntu following a corruption problem initially reported here (How do I solve the "invalid arch dependent elf magic" error message).

When I power my laptop, I now get the following message:

GNU GRUB version 2.02~beta2-9ubuntu1.7
Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions.
Anywhere else TAB lists possible device or file completions." and then the prompt

grub>

Can anyone help me get back to Ubuntu ?

Mons
  • 269
  • Comments are not for extended discussion; this conversation has been moved to chat. – Thomas Ward Jul 02 '17 at 19:03
  • Big thumbs up to everybody. I chased down a few leads and finally solved the problem by booting from a live CD and entering the command "sudo update-grub" @derHugo your help was massively useful. – Mons Jul 02 '17 at 19:29
  • 1
    The various hints given by @derHugo can be found on the chat site on Stack Exchange here: https://chat.stackexchange.com/rooms/61451/discussion-on-question-by-mons-how-do-i-boot-my-pc-from-grub and in particular when he recommended googling the question, here: "Haha sorry always forget that ^^ anyway please Google it there are tons of articles addressing this issue e.g. here is another one". Anyway, I'm absolutely made up to be up and running on my laptop again. I know I'm not supposed to say thanks, but I will all the same. THANKS ! – Mons Jul 02 '17 at 21:59

3 Answers3

50

Ok, from grub type ls (hd0,1)/
you should see a file named vmlinuz or linux, and initrd.img

Type linux (hd0,1)/vmlinuz root=/dev/sda1 or linux (hd0,1)/linux root=/dev/sda1 depending on what you found with ls (hd0,1)/, then:

initrd (hd0,1)/initrd.img
boot

If you get initramfs rescue mode enter your password, then startx. You should now have a desktop.

Use gparted to check your file system, if it reports an error, then you need to boot from a LiveCD or other media to fix it .... DO NOT attempt to repair a mounted partition.

The following three commands fix many grub boot problems. They run quick so just do all three instead of trying to find which one you need.

sudo grub-install /dev/sda && sudo update-grub && sudo update-initramfs -u

Reboot and see what you get.

ravery
  • 6,874
  • 3
    Is it really innitrd or should it be initrd? – WinEunuuchs2Unix Jul 02 '17 at 19:52
  • 1
    It is actually initrd – answerSeeker Jul 02 '17 at 20:19
  • @wineunuuchs2unix -- thanks fixed. thou you could ave edited the typo – ravery Jul 02 '17 at 21:57
  • 1
    @ravery Yes I could have corrected the typo. I have a weird point of view thinking it's more polite to point out to the author and letting them make the change. That way an otherwise spotless answer doesn't have the "blemish" of an "edited by someone else" flag. I do edit new users' questions frequently though... Have another +1 :) – WinEunuuchs2Unix Jul 02 '17 at 22:18
  • You can't start a x session or run a GUI program from Initramfs... nothing has been mounted yet. – Ravexina Jul 05 '17 at 08:42
  • @ravexina - 'startx' will give a deafult "root" desktop it yours fails. everything has been mounted. that is why you specify root when loading the kernel. the steps given are the same thing grub does but with out all the options. it will load your install – ravery Jul 05 '17 at 08:49
  • 1
    IF you stuck in "INITRAMFS" not in a fully booted system you can't use startx cause there is no desktop there, what you are referring as initramfs should be multi-user.target. – Ravexina Jul 05 '17 at 08:53
  • the prompt says initramfs. and asks for password. I have root enabled so maybe that is the difference. but I can enter password and then startx and I get a default desktop – ravery Jul 05 '17 at 08:55
  • Seems to be ‘grub-install’ now, not ‘install-grub’ – Mike Wise Feb 02 '18 at 04:57
  • @MikeWise -- for a while both worked but corrected, thx – ravery Feb 02 '18 at 05:56
  • 3
    In case the files above aren't listed, try iterating on ls (hd0,1)/ command, as in: ls (hd0,2)/, ls (hd0,3)/, etc. as suggested in here. – Nae Dec 23 '18 at 17:46
  • This answer allowed me to boot my Debian, but then executing the 3 last commands didn't solve the boot issue, I'm again in the grub console :/ – ZedTuX Jan 09 '20 at 13:46
  • I got stuck at initrafms and startx didn't work. I am not even able to reach ubuntu shell. – Shashwat Aug 04 '20 at 07:13
  • Thank you!! It fixed my issue and now everything is booting as normal. – Arbel Sep 16 '20 at 21:02
  • After "startx", I see: Cannot open /dev/tty0. And I do not know how to start tty0 from initramfs. :-( – xerostomus Jan 06 '22 at 15:56
2

The most probable cause to that issue is installing the OS to a disk, grub to a different disk that is not removable. Then removing the OS disk.

You could just plug the USB stick back in. Problem solved.

RobotHumans
  • 29,530
2

Restart your system. Press f2 key while loading. Goto boot option. Press f5/f6 to change values (which os you want to install keep it in first place.). Enter f10 key....It may solve your problem. . . . If not enter this in grub rescue mode.... ls (hd0) (hd0,msdos6) (hd0,msdos5)....(hd0,msdos1) OR (hd0) (hd0,gpt6).....(hd0,gpt1)

set boot=(hd0,gpt6) OR set boot=(hd0,msdos6) set prefix=(hd0,gpt6)/boot/grub OR use msdos6 instead. insmod normal normal This may solve your problem.

  • these are various ways to launch grub. this is not the issue as OP states. grub launches but drops to recovery mode. The issue is that the grub config file is missing – ravery Jul 09 '17 at 08:23