Fedora25 boot into grub prompt

On starting my PC after it powered off due to low battery, I was met with a grub prompt  as shown below

grub prompt

I didn’t have explanation for what had happened cause my PC hadn’t failed or given warning prior to this, but I made an update earlier which I suspected could be buggy or didn’t complete before I lost internet connectivity but nonetheless I had to fix this.

My working knowledge of grub2 was minimal since grub2 config is automatically installed and configured. Being a Fedoraproject user I found  this  good  wiki resource on fedoraproject. I followed the wiki page and was able to fix the problem though not immediately, I hope my solution would help someone using lvm and device mapper device types, below is a sample of my df -h before the issue

lvm partition details

Lets start working on fixing the issue, on the grub prompt run the command ls

Note: Below is how it appeared on my grub terminal, yours could be a little different especially if you aren’t using lvm
grub> ls
(hd0) (hd0,gpt1) (hd0,gpt2) (hd0,gpt3) (lvm/fedora-swap) (lvm/fedora-root) (lvm/fedora-home)

 

from the listed entries above you would need to find where your root file system in installed and also where your kernel (vmlinuz and initramfs) entries was installed, below are my own entry

Note if you don’t add the “/” at the back of the filesystem it would only give you the type of filesystem you are trying to access e.g ext2 or fat.
grub> ls (hd0,gpt2)/

kernel entries

 

grub> ls (lvm/fedora-root)/

Os root treeOnce you got the above previous entries you are good to go, just do the following

Note: first value passed to root is from ls result where our os tree reside, yours could be different based on device type
*linuxefi and initrdefi are for efi type, linux and initrd works for non efi.
*the root value is the device type for lvm, check the fedora wiki page for other scenario

grub> set root=(lvm/fedora-root)
grub> linuxefi (hd0,gpt2)/vmlinuz-4.9.4-201.fc25.x86_64 root=/dev/mapper/fedora-root rhgb quiet selinux=0
grub>initrdefi (hd0,gpt2)/initramfs-4.9.4-201.fc25.x86_64.img
grub>boot

Once it has finish booting you can open a terminal and

grub2-mkconfig -o /boot/grub2/grub.cfg

Issue the grub2-install command to install grub2 to your hard drive and make use of your config:

grub2-install –boot-directory=/boot /dev/sda # Note: your drive may have another device name. Check for it with mount command output.

The command above is likely to fail for efi system, try the below if that happens

# dnf install grub2-efi-modules
# grub2-install –boot-directory=/boot /dev/sda.

Johnny At FedoraProject

nix.akinsola.me

JJC Fedora

 

I have decided to be more active in the open source community and be an active contributor of FOSS. I have been procrastinating this for a very long time, I was initially inspired  by the creator of Ubuntu Mark Shuttleworth, he was an active Debian Developer and later moved on to create Ubuntu one of the most popular linux OS based on Debian.

Recently I joined none other than the FedoraProject my distro of choice, I have used all the main Redhat family( Redhat, Centos and Fedora) Fedora is my last stop and best bet for freedom so far.

A popular saying in my country Johnny Just Come(JJC) for now am Johnny at Fedoraproject,  JJC simply means a newcomer, you can check my wiki profile.

I am currently a  approved member of the QA group and yet to be approved  in the Ambassadors group which am looking forward to.

If you want to join fedoraproject click the link  or send me an email to faskinss AT gmail dot com for any info.