Home Learn Linux Linux Tutorials How to Rescue a Non-booting GRUB 2 on Linux

How to Rescue a Non-booting GRUB 2 on Linux

grub command shellOnce upon a time we had legacy GRUB, the Grand Unified Linux Bootloader version 0.97. Legacy GRUB had many virtues, but it became old and its developers did yearn for more functionality, and thus did GRUB 2 come into the world.

GRUB 2 is a major rewrite with several significant differences. It boots removable media, and can be configured with an option to enter your system BIOS. It's more complicated to configure with all kinds of scripts to wade through, and instead of having a nice fairly simple /boot/grub/menu.lst file with all configurations in one place, the default is /boot/grub/grub.cfg. Which you don't edit directly, oh no, for this is not for mere humans to touch, but only other scripts. We lowly humans may edit /etc/default/grub, which controls mainly the appearance of the GRUB menu. We may also edit the scripts in /etc/grub.d/. These are the scripts that boot your operating systems, control external applications such as memtest and os_prober, and theming./boot/grub/grub.cfg is built from /etc/default/grub and /etc/grub.d/* when you run the update-grub command, which you must run every time you make changes.

The good news is that the update-grub script is reliable for finding kernels, boot files, and adding all operating systems to your GRUB boot menu, so you don't have to do it manually.

We're going to learn how to fix two of the more common failures. When you boot up your system and it stops at the grub> prompt, that is the full GRUB 2 command shell. That means GRUB 2 started normally and loaded the normal.mod module (and other modules which are located in /boot/grub/[arch]/), but it didn't find your grub.cfg file. If you see grub rescue> that means it couldn't find normal.mod, so it probably couldn't find any of your boot files.

How does this happen? The kernel might have changed drive assignments or you moved your hard drives, you changed some partitions, or installed a new operating system and moved things around. In these scenarios your boot files are still there, but GRUB can't find them. So you can look for your boot files at the GRUB prompt, set their locations, and then boot your system and fix your GRUB configuration.

GRUB 2 Command Shell

The GRUB 2 command shell is just as powerful as the shell in legacy GRUB. You can use it to discover boot images, kernels, and root filesystems. In fact, it gives you complete access to all filesystems on the local machine regardless of permissions or other protections. Which some might consider a security hole, but you know the old Unix dictum: whoever has physical access to the machine owns it.

When you're at the grub> prompt, you have a lot of functionality similar to any command shell such as history and tab-completion. The grub rescue> mode is more limited, with no history and no tab-completion.

If you are practicing on a functioning system, press C when your GRUB boot menu appears to open the GRUB command shell. You can stop the bootup countdown by scrolling up and down your menu entries with the arrow keys. It is safe to experiment at the GRUB command line because nothing you do there is permanent. If you are already staring at the grub> or grub rescue>prompt then you're ready to rock.

The next few commands work with both grub> and grub rescue>. The first command you should run invokes the pager, for paging long command outputs:

grub> set pager=1

There must be no spaces on either side of the equals sign. Now let's do a little exploring. Type ls to list all partitions that GRUB sees:

grub> ls
(hd0) (hd0,msdos2) (hd0,msdos1)

What's all this msdos stuff? That means this system has the old-style MS-DOS partition table, rather than the shiny new Globally Unique Identifiers partition table (GPT). (See Using the New GUID Partition Table in Linux (Goodbye Ancient MBR). If you're running GPT it will say (hd0,gpt1). Now let's snoop. Use the ls command to see what files are on your system:

grub> ls (hd0,1)/
lost+found/ bin/ boot/ cdrom/ dev/ etc/ home/  lib/
lib64/ media/ mnt/ opt/ proc/ root/ run/ sbin/ 
srv/ sys/ tmp/ usr/ var/ vmlinuz vmlinuz.old 
initrd.img initrd.img.old

Hurrah, we have found the root filesystem. You can omit the msdos and gpt labels. If you leave off the slash it will print information about the partition. You can read any file on the system with the cat command:

grub> cat (hd0,1)/etc/issue
Ubuntu 14.04 LTS \n \l

Reading /etc/issue could be useful on a multi-boot system for identifying your various Linuxes.

Booting From grub>

This is how to set the boot files and boot the system from the grub> prompt. We know from running the ls command that there is a Linux root filesystem on (hd0,1), and you can keep searching until you verify where /boot/grub is. Then run these commands, using your own root partition, kernel, and initrd image:

grub> set root=(hd0,1)
grub> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
grub> initrd /boot/initrd.img-3.13.0-29-generic
grub> boot

The first line sets the partition that the root filesystem is on. The second line tells GRUB the location of the kernel you want to use. Start typing /boot/vmli, and then use tab-completion to fill in the rest. Type root=/dev/sdX to set the location of the root filesystem. Yes, this seems redundant, but if you leave this out you'll get a kernel panic. How do you know the correct partition? hd0,1 = /dev/sda1. hd1,1 = /dev/sdb1. hd3,2 = /dev/sdd2. I think you can extrapolate the rest.

The third line sets the initrd file, which must be the same version number as the kernel.

The fourth line boots your system.

On some Linux systems the current kernels and initrds are symlinked into the top level of the root filesystem:

$ ls -l /
vmlinuz -> boot/vmlinuz-3.13.0-29-generic
initrd.img -> boot/initrd.img-3.13.0-29-generic

So you could boot from grub> like this:

grub> set root=(hd0,1)
grub> linux /vmlinuz root=/dev/sda1
grub> initrd /initrd.img
grub> boot

Booting From grub-rescue>

If you're in the GRUB rescue shell the commands are different, and you have to load the normal.mod andlinux.mod modules:

grub rescue> set prefix=(hd0,1)/boot/grub
grub rescue> set root=(hd0,1)
grub rescue> insmod normal
grub rescue> normal
grub rescue> insmod linux
grub rescue> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
grub rescue> initrd /boot/initrd.img-3.13.0-29-generic
grub rescue> boot

Tab-completion should start working after you load both modules.

Making Permanent Repairs

When you have successfully booted your system, run these commands to fix GRUB permanently:

# update-grub
Generating grub configuration file ...
Found background: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
Found background image: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
Found linux image: /boot/vmlinuz-3.13.0-29-generic
Found initrd image: /boot/initrd.img-3.13.0-29-generic
Found linux image: /boot/vmlinuz-3.13.0-27-generic
Found initrd image: /boot/initrd.img-3.13.0-27-generic
Found linux image: /boot/vmlinuz-3.13.0-24-generic
Found initrd image: /boot/initrd.img-3.13.0-24-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.

When you run grub-install remember you're installing it to the boot sector of your hard drive and not to a partition, so do not use a partition number like /dev/sda1.

But It Still Doesn't Work

If your system is so messed up that none of this works, try the Super GRUB2 live rescue disk. The official GNU GRUB Manual 2.00 should also be helpful.



Subscribe to Comments Feed
  • Marc F. Said:

    Great post...thanks for all. Grub is robust but when is broken....the miracle is on progress :-)

  • Sharath Gunaje Said:

    good info, thank you ...... I was using live CDs to fix the grub errors, now I can try this :-)

  • Abderrahim Said:

    Sometimes, I have this problem, and I fix this using a live CD. Thanks for the tips :)

  • copernicus Said:

    A nice article. Two points: 1.set root=(hd0,1) tells GRUB where the kernel and initrd are. root=/dev/sda1 tells the kernel where to find /sbin/init. They fulfil two different, independent functons. Both are essential. 2. hd0,1 = /dev/sda1 etc, etc. (hd0,1) is what GRUB sees. /dev/sdX is what the kernel sees. Beware of thinking that (hd0,1) corresponds to /dev/sda1. Try booting an OS from a USB device. (hd0,1) could be /dev/sdc1.

  • erinn Said:

    Thank you Copernicus, I didn't know that before.

  • Shekhar (Sam) Said:

    Hi Copernicus, To boot a device from USB, you must set it to the right partition on the usb drive. 1. /dev/sda - Internal Hard Disk (In single hard disk systems like many laptops and desktop) 2. /dev/sdX ; where 'X' may be 'b','c','d' etc depending on the order of plugging the device. Or sometimes the numbers are chosen randomly. So try finding out with the "ls (hdQ,M)" ; where 'M' is the partition number starting from 1 as in sdX for 'X'. And 'Q' is the drive number, 0 for default, 1 for 1st USB and so on.. And a special thanks to the author for sharing this stuff.. It saved a lot of my time.. Thanks again.

  • Albin Said:

    I've used the open source GUI "Boot-Repair" - one click fix - several times when dual boot installs got messed up. I'd recommend trying it before going terminal:

  • djf Said:

    Very good article for a ubuntu grub2 boot.- and redhat is very similar but the separate boot partition must be referenced: grub> set root=(hd0,2) grub> linux (hd0,5)/vmlinuz-(tab-complete) root=/dev/sda2 grub> initrd (hd0,5)/initramfs-(tab-complete) grub> boot This booted my fedora system - and I never would have figured how to boot either ubuntu or fedora in grub2 had it not been for your article - thanks again. In fact I am no longer as angry about the move from grub to grub2

  • djf Said:

    NOTE: the above example assumes the root partition is /dev/sda2 and the /boot partition is /dev/sda5

  • DavidWP Said:

    Newbie? within article: "If you are practicing on a functioning system, press C when your GRUB boot menu appears to open the GRUB command shell. How do I get to 'when your boot menu appears' ? -- hold during boot OR initiate from CLI? Thank you for fielding my query and for the article.

  • erinn Said:

    Hi David, Just wait until you see your normal GRUB boot menu, then press C.

  • joeching Said:

    this is exactly what happened to me. now i m more than ever convinced that linux will replace windows. here is what happened to me yesterday and a week before: MY WINDOWS PC IS DYING! I don't blame China for wanting to get out the Windows PC mess. We here in America might just have to die along with Windows. My story begins with the new desktop PC I bought, one year and 11 months ago. it's speed and capacity r more than i could possibly make complete use. then quickly it starts to slow down, even after i subscribed to many optimization online speed-up and security products. and finally i settled down with a superior-tech support group, out of india, for $400/2 yrs in replacing the piling up costs of other support subscriptions. we this outfit kept my pc running like a whistle, without the bothers of other support-scam schemes. well, that's only lasted until we almost lost our ability for the superior-tech group to connect to my pc and work on it as if it's own. they had to go from a support tech, to advanced support tech and to top support tech to finally realize the situation is hopeless. then i had to put on my own supercomputing hat to trace back to what new software package and actions of mine that could triggered this problem. it turned out to be the korean learning digital gadget i purchased recently that was the culprit. we worked so intense and intimately enough to end up talking politics. i just mentioned the recent expression from china to get out of windows pc and that china and india should cooperate to support their own computing. he immediately replied that india and china could never work together. then i say may be india should first learn to live with pakistan, since it's the british who cause the hostile divide between the two countries. he then whispered to me something that i could not here. it turn out to be:"the british was not bad for india." so, i gave up. anyway, the next time i needed support was when i crashed my pc completely by the dual-boot installation of a scientific linux on it. i heard the news of scientific linux is trying to maintain backward compatibility for computing software on linux. so, i thought my current installation of the ubutus linux should be replace to solve the backward compatibility problem with packages on fortran, c, f2c(fortran to c) and xwindows. somehow the windows booting on this kind of new pc was able to prevent the comparative inexperienced scientific linux from even get its foot in the door of the pc. the superiortech best tech support could only tell me to get a dvd from hp computer, so i did and luckily found out my warranty had another month to go. but not so unlucky was my action of helping out a friend who's also in pc support business to revive and salvage the 10000 files on the pc. he lost all my files and installed something that crashed the first time i tried again the scientific linux installation. i got to calm down and backup up a bit. so, i tried all the past linux versions i bought and downloaded and finally found the mandriva linux(from france) 2011 with 32 bits works on a dual boot with the crashed windows operating system. and what's more shocking is that when i downloaded the fortran and f2c compilers from scientific linux archive, my backward compatibility disappeared also! and for a whole week, the linux pc zaps along like a rocket. this prompted me to migrate to linux, this time, for real. toward this end, i v been contacting some local linux pc outfit,, and try to see if they could come up with a scientific linux pc that will run my software automation package, robacus. being completely snowed in under pongfu drilling and korean learning, i was able to take this huge detour due to the emerging of this young man from shanghai, jack liu. jack can play the role of the liaison between me and zareason, if he shows that he understands the mystery of robacus, which often bedazzles the best of the tech types for it's non-tech nature. well, jack is a trained in liberal art, so he's taking on robacus in strides. why, i had been given out 3 sets of working and tested robacus/linux pcs, 1 to peking university and 2 to north pacific university, but the kids there could hardly login into robacus the minute the took it home. while i gave jack a broken down pc, but he got it repaired in the shop and started to using robacus to learn natural-language programming and how to live with software robots. the bad news upto now for u readers of this article is that thus far i v just described the background of the dire windows pc. but the good news is now i can tell what happened to we yesterday that rang the death toll of windows pc. around noon, i got a call from a superior-tech-alike outfit predicting that the spare windows notebook pc was not doing well. well, it did deteriorate fast the 2 weeks that i had it turned on for use. but i didnt care because i only need its service for another week before the windows7 dvd arrives from hp. besides, the hp linux pc is working like a marvel. in fact, it worked so well that i laughed at the idea that some friend, taipan yew, suggested that i use a emulator on it for windows -- just to ruining a good things? the sup-tech people worked diligently with me to get themselves on my notebook windows. then they say they could make it run like a whistle for a hundred bucks. i reject the offer but they begged. so i gave them the ultimatum of $50. they countered at $70. i told them that i m just using this notebook to see how windows dies and i m only willing to buy a front row of my own show for at most $50. they agreed, then we spent an hour just to get thru the an extremely insecurity-minded security online system for them to make me pay themselves. at the end, they instructed me never to pay anyone else from now on and leave the windows running for them for another 2 hours. five minutes after i hang up the phone with them, i got a call from western union and was informed a money transfer is being made. i told them i know and it's ok. then before we hang up, i mention the $50, and they hesitated in hanging up and said:"there is a bit difference. the transfer is for $200." and before i started to explain in detail, they suggested that we drop the whole thing. i agreed. then 15 minutes later, i noticed that the motion on my window7 notebook stopped. so, i send the sup-tech an email with address: , but the email didnt get thru. then i decided to call my local wells fargo bank, who advised me to initiate a claim with their claim office about the money transfer out of my visa card, only after a big lecture on never giving out my card no. and get me to cancel the card, only after telling that a $220 in pending to go out of it. i then call the claim office, who get me to call the western union, whom i pleaded to check, by way of my name, the deal, which they found to be dropped, and tried to make a three-way call with wells fargo claim office unsuccessfully. actually in all the many calls i made to wells fargo, the getting thru were very difficult and the serves, except thru the final concluding email, were very reluctant. maybe they r as afraid of the online indian digital scammers as anybody by now. i hereby therefore predict windows pc will die from the bad-guy hackers who have made a business of generating their own job security by routinely make windows pc sluggish so that they could force the the users to subscribe to their protection -- until the scam fails for every body. but finally what will really put windows to rest in peace in its misery should be a unified effort to come up with a centralized linux supercomputer, hopefully run out of robacus, out of china. this story of "2025 showdown between robacus and windows" will be the subject of my next article.

  • joeching Said:

    by the way, all the commotion that started my migration to linux for real came from the article i read on scientific linux here. thanks.

  • marvinudy Said:

    Carla, Thanks for the article. I had a timely need to fix 'grub error' on my multi boot machine. I did find it necessay to use the full addresses. ie (hd1,msdos2). However, the result was a success.

  • Charles Said:

    Thanks. I have successfully entered the system with this method. However after I booted into the system and run "sudo update-grub" and "sudo grub-install /dev/sda", the system will restart into grub command again. No error reported during the update. Anyone could help? I copied the content from /etc/default/grub here: GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX=""

  • BerT Said:

    Thanks for this great and very useful how-to. It works for me with grub rescue. I don't believe it, still yet.

  • Maciek Said:

    - I recently tried upgrade from 13.10 to 14.04 using GUI when upgrading, got errors about libc upgrade, but install continued... - on first reboot getting this error on boot run-init: /sbin/init: No such file or directory Kernel panic - not syncinig: attempted to kill init - manual boot from old image still getting the same error grub> set root=(hd0,1) grub> linux /vmlinuz.old root=/dev/sda1 grub> initrd /initrd.img.old grub> boot - tried adding init=/bin/sh (and /bin/bash) to linux command above, got: run-init: /bin/bash: no such file or directory - verified that /bin/bash, /bin/sh, /sbin/init files all exist - now I am lost - what to do next?

  • Georg Said:

    OMG THANKS SO MUCH!! Acutally my UEFI Bios destroyed GRUB.. Now its working again! Thanks!!

  • viens Said:

    wow, vay emine kodumun neguzel yazmissin kiz zilli THANKS!!!!!!!!!!

  • Mike Said:

    After searching the net for hours I found your blog and solved all my grub2 problems at once. Zhank you very much for this comprehencive guide! Exellent! Mike

  • AlanHarper Said:

    Thank you very much, it was the only solution to my broken system.

  • bulevardi Said:

    Tried booting from grub, but then my screen went flooding messages like: "pciehp 00000..... card not present in slot // failed to check link status" all the time. Tried different times. Anyone had this before too? Following boot commands: set root=(hd0,6) linux (hd0,1)/vmlinuz-3.13.0-40-lowlatency root=/dev/sda6 initrd (hd0,1)/initrd.img-3.13.0-40-lowlatency boot

  • bulevardi Said:

    Tried booting from grub, but then my screen went flooding messages like: "pciehp 00000..... card not present in slot // failed to check link status" all the time. Tried different times. Anyone had this before too? Following boot commands: set root=(hd0,6) linux (hd0,1)/vmlinuz-3.13.0-40-lowlatency root=/dev/sda6 initrd (hd0,1)/initrd.img-3.13.0-40-lowlatency boot

  • David Draguta Said:

    Thank you so much! You are a life saver!

  • Khim Lal Said:

    Very Very helpful link regarding grub-rescue. :)

  • rizki Said:

    I'm having this problem an hours ago, I cant boot to the grub option instead the screen displaying a grub rescue shell command Then I follow this article and when I'm still in "normal" command it already fix it for me Thank you very much

  • Qasim Said:

    Beautiful, works successfully , thanks

  • Arjun Said:

    root must be set as read the actual command should be grub> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1 ro

  • ankit Said:

    after prefix+(....) using ls / but showing unknown filesystem

  • Peter G. Said:

    You wrote "hd3,2 = /dev/sdd2" but perhaps that should be sdc2 instead?

  • Capn' Munch Said:

    Thank you! This post just saved me. My system stopped showing the grub menu after I deleted some non-relevant entries using grub-customizer but I was able to get up and running again using your info. Many thanks.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board