FedoraForum.org - Fedora Support Forums and Community
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2015
    Location
    canada
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    Join Date
    Jul 2013
    Location
    UK
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  3. #3
    Join Date
    Jun 2005
    Location
    Montreal, Québec, Canada
    Age
    85
    Posts
    10,213
    Mentioned
    35 Post(s)
    Tagged
    0 Thread(s)

    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
    We get too soon old, and too late smart!

  4. #4
    Join Date
    Mar 2015
    Location
    canada
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  5. #5
    Join Date
    Jul 2013
    Location
    UK
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  6. #6
    Join Date
    May 2010
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to reinstall grub2 on fedora 21 using a live image and chroot

    Quote Originally Posted by humbleRumble
    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.

  7. #7
    Join Date
    Mar 2015
    Location
    canada
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

Similar Threads

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •