Fedora Linux Support Community & Resources Center
  #1  
Old 24th March 2015, 12:18 AM
humbleRumble Offline
Registered User
 
Join Date: Mar 2015
Location: canada
Posts: 11
linuxchrome
How to reinstall grub2 on fedora 21 using a live image and chroot

This is applicable to LVM and UEFI (where grub2-install will fail)

This is a collection of the commands which I found necessary to reinstall grub from a live image using a chroot environment. I found all of these commands in various forum posts around the web and thought i would post them in one place as none of the individual posts worked for me while together they do have good information. please feel free to post if you think this is helpful so that it can possibly help someone else. thank you.

Notice: if anything in your system is installed in a non-standard location you may have to change some of the lines

Open a terminal and enter the following commands

Code:
su -
cd /mnt
mount /dev/fedora/root ./
mount /dev/fedora/home home/
mount -t proc proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
mount --rbind /var/run/ var/run/
chroot /mnt/
mount /boot/efi
dhclient `/sbin/route -n | grep "^0.0.0.0" | rev | cut -d' ' -f1 | rev`
yum -y update
yum -y reinstall grub2 grub2-efi grub2-efi-modules shim
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda

Last edited by humbleRumble; 16th June 2015 at 02:40 AM. Reason: Updated to run without input
Reply With Quote
  #2  
Old 24th March 2015, 12:42 AM
wintonian Offline
Registered User
 
Join Date: Jul 2013
Location: UK
Posts: 207
linuxfedorafirefox
Re: How to reinstall grub2 on fedora 21 using a live image and chroot

I usually refer to the solution here for legacy BIOS.

I can attest that 'alt' method mentioned there (and linked to here) does in fact work and save some typing.

Mainly mount your root then:

Code:
# mkdir /mnt/<MYROOT>
# mount /dev/mapper/fedora-root /mnt/<MYROOT>
# grub2-install --root-directory=/mnt/<MYROOT> /dev/sd<x>
Not forgetting to mount /boot if on a different partition.

At least has worked for me without using LVM (as in the solution).

Last edited by wintonian; 9th April 2015 at 07:43 AM. Reason: To clarify that instructions are only good for old style BIOS thanks to 'chrismurphy' bellow pointing that out.
Reply With Quote
  #3  
Old 24th March 2015, 02:09 AM
lsatenstein Online
Registered User
 
Join Date: Jun 2005
Location: Montreal, Que, Canada
Posts: 3,823
linuxfedorafirefox
Re: How to reinstall grub2 on fedora 21 using a live image and chroot

I take the flashdrive that I used to create the Linux, I use the recovery LInux therein and follow the instructions.
Eventually a demand is to perform a chroot sysimage command. That latter command puts me into the Linux that has the invalid grub.cfg file.

You have to identify the boot volume and thereafter is perform a grub2-install /dev/boot_partition.

When you reboot grub.cfg should be in its proper place, and the boot chain (If you have uefi bios) will also be there. Your system will restart.
__________________
Leslie in Montreal

Interesting web sites list
http://forums.fedoraforum.org/showth...40#post1697840
Reply With Quote
  #4  
Old 8th April 2015, 07:01 PM
humbleRumble Offline
Registered User
 
Join Date: Mar 2015
Location: canada
Posts: 11
linuxfirefox
Re: How to reinstall grub2 on fedora 21 using a live image and chroot

@wintonian: I use lvm (as this is default in fedora 20) so your method does not work.
@isatenstein: fedora 20 workstation live image doesnt have a rescue option

It seems with lvm I cant get away with just a grub-install. just had to do this again after a failed hibernate corrupted grub yet again

---------- Post added at 12:01 PM ---------- Previous post was at 11:59 AM ----------

As it stands by modifying the first line of my example it will work for a non lvm setup as well and if no other solution works this one will, therefore i think it is very useful for others to be able to get this information.
Reply With Quote
  #5  
Old 8th April 2015, 07:43 PM
wintonian Offline
Registered User
 
Join Date: Jul 2013
Location: UK
Posts: 207
linuxfedorafirefox
Re: How to reinstall grub2 on fedora 21 using a live image and chroot

You will need to mount the LVM first.

Unfortunately I can't help you here as I don't use LVM, having found it to be more trouble than it's worth. Something which your issue illustrates again that IMO for most uses LVM creates an extra unnecessary obstacle.

Anyway here's a Google search to get you started.
Reply With Quote
  #6  
Old 9th April 2015, 01:20 AM
chrismurphy Offline
Registered User
 
Join Date: May 2010
Posts: 1,056
macoschrome
Re: How to reinstall grub2 on fedora 21 using a live image and chroot

Quote:
Originally Posted by humbleRumble View Post
mount /boot/efi
This suggests the system has UEFI firmware, instead of legacy BIOS. If so, grub2-install is not applicable, and with default packages it will fail. Reinstalling GRUB on UEFI means reinstalling shim and grub2-efi packages.
Reply With Quote
  #7  
Old 20th April 2015, 03:27 PM
humbleRumble Offline
Registered User
 
Join Date: Mar 2015
Location: canada
Posts: 11
linuxchrome
Re: How to reinstall grub2 on fedora 21 using a live image and chroot

edited the original post to reflect that this affects LVM and UEFI.
Reply With Quote
Reply

Tags
chroot, f21, fedora, grub2, image, live, reinstall

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I reinstall Fedora 16 with the live same DVD and keep all my stuff? Oakems EOL (End Of Life) Versions 4 28th January 2014 11:29 PM
[SOLVED] Why do we reinstall grub2 after fedup upgrade LongTimeDabbler Using Fedora 7 21st July 2013 04:45 PM
Ntfs recognized as swap after F17 reinstall (Grub2) Arkael Using Fedora 1 6th December 2012 12:51 AM
SELinux relabel forced after GRUB2 reinstall sliptrap Using Fedora 1 1st December 2012 12:54 PM
[SOLVED] F16 64 - how to reinstall grub2 johnlvs2run Using Fedora 29 24th November 2012 04:51 PM


Current GMT-time: 21:02 (Wednesday, 29-03-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat