• Re-install Grub2 from DVD Rescue

    Boot the Rescue from the DVD. This should be the same Arch as the installation: ie; 32 bit or 64 bit..


    Once the DVD rescue gets to 'login', type: root
    from there I run fdisk -l to confirm my HD partitition order.
    We need to mount root (for me that's sda3)

    Now mount / (sda3) with:
    Code:
    mount /dev/sda3 /mnt
    To mount the other devices
    Next do:
    Code:
    mount --bind /dev /mnt/dev
    Then chroot:
    Code:
    chroot /mnt
    Code:
    mount /proc
    Code:
    mount /sys
    Your prompt changes to: Rescue:/>
    Here type:
    Code:
    grub2-mkconfig -o /boot/grub2/grub.cfg
    Code:
    grub2-install /dev/sda
    You can see it all here: https://dl.dropbox.com/u/10573557/Gr...ect/rescue.jpg

    'exit'
    # reboot

    If you use LVM please check this post: https://forums.opensuse.org/vbcms-comments/478290-article-re-install-grub2-dvd-rescue-3.html#post2519005

    N.B: This method should also work from a live cd
    This should be the same Arch as the installation: ie; 32 bit or 64 bit..USE LIVE CD TO RESCUE
    Comments 83 Comments
    1. caf4926's Avatar
      caf4926 -
      Quote Originally Posted by Dexter1979 View Post
      Nice article, Carl. Would it be worth while mentioning that the live-cd needs to be of the same architecture as the system you are trying to take over with Chroot? I.e. if you are taking over a 64bit system you need to use a 64bit live-cd or you will get this or similar error when using chroot:

      Code:
      chroot: cannot run command '/bin/bash': Exec format error
      Quite correct.
    1. wakou's Avatar
      wakou -
      Thanks Caf, I just did this from the net-install iso on a USB thumb-drive, worked a treat!
    1. caf4926's Avatar
      caf4926 -
      Quote Originally Posted by wakou View Post
      Thanks Caf, I just did this from the net-install iso on a USB thumb-drive, worked a treat!
      Good to know it's still useful ...
    1. dayfinger's Avatar
      dayfinger -
      Thank you, caf4269, for this article. Really useful!

      Like others before me, I tried it on a LVM system. As I didn't read the subscript until I was finished (to look in another thread for LVM solution), I have still another take on how to do LVM. Mine seems a little more in line with your receipt, though. I also had a more split-up construct, that needed extra mounting in order to be complete.

      Here's my setup: openSUSEx86 13.1 64bit alone in a VMWare version 7 VM, MBR disk partitioning. Key disk details (you can see LVM and fdisk-output below):
      Code:
      /dev/sda1 = /boot - Ext4-formatted and is where I boot from, and where Grub2 is installed
      /dev/sd2  = LVM where everything else is installed.
                  Volume Group = "system" and it is subdivided into several logical sub-volumes:
                                 /     = system-root
                                 /swap = system-swap
                                 /usr  = system-usr
                                 /var  = system-var
                                 /home = system-home
                                 /tmp  = system-tmp
                                 /srv  = system-srv
      The "lvm lvs -a -o+devices" output:
      Code:
      linux:/> lvm lvs -a -o+devices
        LV   VG     Attr      LSize Pool Origin Data%  Move Log Copy%  Convert Devices        
        home system -wi-a---- 1.50g                                            /dev/sda2(0)   
        root system -wi-ao--- 5.00g                                            /dev/sda2(385) 
        srv  system -wi-a---- 1.00g                                            /dev/sda2(1666)
        swap system -wi-a---- 2.00g                                            /dev/sda2(1923)
        tmp  system -wi-ao--- 3.00g                                            /dev/sda2(2436)
        usr  system -wi-ao--- 8.00g                                            /dev/sda2(3205)
        var  system -wi-ao--- 2.50g                                            /dev/sda2(5254)

      The "fdisk -l" ouput. Note the "Disk /dev/mapper/system..." listing:
      Code:
      linux@linux:~> su -
      linux:~ # fdisk -l
      
      Disk /dev/sda: 26.8 GB, 26843545600 bytes, 52428800 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk label type: dos
      Disk identifier: 0x000dbee0
      
         Device Boot      Start         End      Blocks   Id  System
      /dev/sda1   *        2048     2105343     1051648   83  Linux
      /dev/sda2         2105344    52404223    25149440   83  Linux
      
      Disk /dev/mapper/system-root: 5368 MB, 5368709120 bytes, 10485760 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      
      
      Disk /dev/mapper/system-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      
      
      Disk /dev/mapper/system-usr: 8589 MB, 8589934592 bytes, 16777216 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      
      
      Disk /dev/mapper/system-var: 2684 MB, 2684354560 bytes, 5242880 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      
      
      Disk /dev/mapper/system-home: 1610 MB, 1610612736 bytes, 3145728 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      
      
      Disk /dev/mapper/system-srv: 1073 MB, 1073741824 bytes, 2097152 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      
      
      Disk /dev/mapper/system-tmp: 3221 MB, 3221225472 bytes, 6291456 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      My first attempt at using your receipt failed. Then I realised that what "fdisk -l" is listing, are disk devices and partitions. Did that mean that LVM's logical volumes could be handled as partitions too? In practical life, that would translate to using the "/dev/mapper/system...." entries for partitions in your receipt. I tried that, and it worked! Since I also had split up the normal root / -hierarchy into several partitions, I also needed more mounting entries. Combining that into one procedure (which BTW resambles a shameless rewrite of your receipt), here's what I did:

      (First: I booted off the "openSUSE 64bit 13.1 Resque CD" and entered as root).

      From the "lvm lvs -a -o+devices" and "fdisk -l" ouput above, I know that my /root is to be found on sda1. All the other parts are to be found at sda2 - but they are all LVM logical volumes (lvs). So I need to access them as such instead. You need to locate your mounting points similarly.

      We need to mount root. Only the first line here is necessary if you have all partitions/logical volumes in a single root /. Since I had split my structure into several separated lvs, I had to mount each and every one of them in order to keep a proper root / structure inside the coming chroot. Note that /boot is mounted from sda1 (in the last line):
      Code:
      linux:~ # mount /dev/mapper/system-root /mnt
      linux:~ # mount /dev/mapper/system-usr /mnt/usr
      linux:~ # mount /dev/mapper/system-var /mnt/var
      linux:~ # mount /dev/mapper/system-tmp /mnt/tmp
      linux:~ # mount /dev/sda1 /mnt/boot
      To mount the other devices
      Next do:
      Code:
      linux:~ # mount --bind /dev /mnt/dev
      Then chroot:
      Code:
      linux:~ # chroot /mnt
      Your prompt changes to: linux:/>
      Continue:
      Code:
      linux:/> mount /proc
      linux:/> mount /sys
      Here type:
      Code:
      linux:/> grub2-mkconfig -o /boot/grub2/grub-cfg
      The original "grub-install /dev/sda"-command gave a warning, so instead I simply typed
      Code:
      linux:/> grub-install

      That worked! Nice! Thank you - yet again! I couldn't have done that on my own.


      dayfinger
    1. pinysuse's Avatar
      pinysuse -
      The command
      Code:
      grub2-mkonfig -o /boot/grub2/grub.cfg
      complained as follows:
      Code:
      /usr/sbin/grub2-mkconfig: line 130: /proc/self/mountinfo: No such file or directory
      The directory /proc existed but was empty.

      So acc. linux - mount dev, proc, sys in a chroot environment? - Super User before chrooting I adjusted as follows:
      Code:
      mount --bind /proc /mnt/proc
      mount --bind /sys /mnt/sys
      and the grub2-mkonfig command worked.
    1. Knurpht's Avatar
      Knurpht -
      Quote Originally Posted by pinysuse View Post
      The command
      Code:
      grub2-mkonfig -o /boot/grub2/grub.cfg
      complained as follows:
      Code:
      /usr/sbin/grub2-mkconfig: line 130: /proc/self/mountinfo: No such file or directory
      The directory /proc existed but was empty.

      So acc. linux - mount dev, proc, sys in a chroot environment? - Super User before chrooting I adjusted as follows:
      Code:
      mount --bind /proc /mnt/proc
      mount --bind /sys /mnt/sys
      and the grub2-mkonfig command worked.
      Thanks for sharing. Ran into this yesterday, found the same (bold) was needed.
    1. caf4926's Avatar
      caf4926 -
      @Gertjan

      Are you suggesting we need to edit the article
    1. exponent's Avatar
      exponent -
      This is confusing because the commands typed don't match the screen shot. In particular

      mount /proc
      mount /sys

      I don't see those on the screenshot.
    1. caf4926's Avatar
      caf4926 -
      Quote Originally Posted by exponent View Post
      This is confusing because the commands typed don't match the screen shot. In particular

      mount /proc
      mount /sys

      I don't see those on the screenshot.
      Because edits were made to the post text to make it more complete
    1. fperal's Avatar
      fperal -
      Quote Originally Posted by eheman View Post
      Like some others that have commented, yesterday my OpenSuSE 12.2 system displayed the "GRUB_" text prompt on a black screen after having installed a grub2-related patch. This article was very useful, but lacked an important step that I had to figure out and add for my dual-boot and LVM based setup.

      My partition and LVM setup is:
      Code:
         Device Boot      Start         End      Blocks   Id  System
      /dev/sda1          206848   314572799   157182976    7  HPFS/NTFS/exFAT
      /dev/sda2   *   314572800  3906228223  1795827712    f  W95 Ext'd (LBA)
      /dev/sda5       314574848   314890239      157696   83  Linux
      /dev/sda6       314892288   315291647      199680   83  Linux
      /dev/sda7       315293696  3901593599  1793149952   8e  Linux LVM

      /dev/sda1 is a windows 7 system
      /dev/sda2 is an extended partition where grub2 resides (the bootable partition).
      /dev/sda5 is the small /boot partition for the opensuse 12.2 x86_64 system
      /dev/sda6 is empty (for some planned future use)
      /dev/sda7 is an LVM volume group partition

      The root, swap, and home mounts are defined as LVM logical volumes, not partitions for my OpenSuse 12.2 system..

      I had to modify the steps in the original post in the article to accommodate the logical volume use. After booting the rescue system from the install DVD and logging in as root, the steps for me were:

      Activate the LVM volume group

      Code:
      vgchange -ay <my.volume.group.name>

      Mount my root logical volume at /mnt

      Code:
      mount /dev/mapper/<my.volume.group.name>-<my.root.logical.volume.name>  /mnt
      Mount the /boot partition under /mnt. Failure to to do this step yields a failure in the grub2 install step if it is omitted.
      Code:
      mount /dev/sda5 /mnt/boot
      Now mount the other devices

      Code:
      mount --bind /dev /mnt/dev
      Then chroot
      Code:
      chroot /mnt

      Your prompt changes to: Rescue:/>
      Here type:
      Code:
      grub2-install  /dev/sda
      After these steps, I was able to reboot successfully. Hope this helps someone that uses LVM extensively like I do.

      I have the same problem:

      / is lvm /dev/dm-1
      /boot is a raid /dev/md1 (or /dev/md127 depends on the way I boot)

      I had to make a new initrd because the old one had not support for LVM.
      Once make initrd grub2 is not working, so I follow your steps


      Code:
      mount /dev/dm-1 /mnt
      mount /dev/md127 /mnt/boot
      mount --bind /dev /mnt/dev
      mount --bind /proc /mnt/proc
      mount --bind /sys /mnt/sys
      chroot /mnt
      grub2-mkconfig -o /boot/grub2/grub.cfg
      Its reports an error

      Code:
      Generating grub.cfg ...
      Found theme: /boot/grub2/themes/openSUSE/theme.txt
      Found linux image: /boot/vmlinuz-3.11.6-4-pae
      Found initrd image: /boot/initrd-3.11.6-4-pae
      Found linux image: /boot/vmlinuz-3.11.6-4-default
      Found initrd image: /boot/initrd-3.11.6-4-default
      Found linux image: /boot/vmlinuz-3.4.63-2.44-pae
      Found initrd image: /boot/initrd-3.4.63-2.44-pae
      Found linux image: /boot/vmlinuz-3.4.63-2.44-default
      Found initrd image: /boot/initrd-3.4.63-2.44-default
      Found linux image: /boot/vmlinuz-3.4.6-2.10-desktop
      Found initrd image: /boot/initrd-3.4.6-2.10-desktop
      ERROR: opening path /mounts/instsys/sys/block
      ERROR: failed to discover devices
      ERROR: opening path /mounts/instsys/sys/block
      ERROR: failed to discover devices
      ERROR: opening path /mounts/instsys/sys/block
      ERROR: failed to discover devices
      ERROR: opening path /mounts/instsys/sys/block
      ERROR: failed to discover devices
      ERROR: opening path /mounts/instsys/sys/block
      ERROR: failed to discover devices
      ERROR: opening path /mounts/instsys/sys/block
      ERROR: failed to discover devices
        /dev/mapper/control: mknod failed: No such file or directory
        Failure to communicate with kernel device-mapper driver.
        Check that device-mapper is available in the kernel.
      done

      But also says its done, so i try

      Code:
      grub2-install /dev/sda
      installation finished no errors reported
      So I try to boot and grub seems to be working, but when booting The kernel (any of them) reports an error


      Code:
      waiting for device /dev/1 to appear
      And It does not boot obviously because /dev/1 does not exist. It must be /dev/dm-1
    1. caf4926's Avatar
    1. fperal's Avatar
      fperal -
      Quote Originally Posted by caf4926 View Post
      Yes I did. And vgscan does report nothing, but

      Code:
         
      #vgscan -v
        Wiping cache of LVM-capable devices
         Wiping internal VG cache
         Reading all physical volumes.  This may take a while...
          Finding all volume groups
          Finding volume group "grupo1"
          Found volume group "grupo1" using metadata type lvm2

      Code:
      vgchange -ay grupo1
      reports nothing but

      Code:
      #vgchange -ay -v mount grupo1
          Using volume group(s) on command line
          Finding volume group "grupo1"
          2 logical volume(s) in volume group "grupo1" already active
          2 existing logical volume(s) in volume group "grupo1" monitored
          Found volume group "grupo1"
          activation/volume_list configuration setting not defined: Checking only host tags for grupo1/home
          Found volume group "grupo1"
          activation/volume_list configuration setting not defined: Checking only host tags for grupo1/raiz
          Activated 2 logical volumes in volume group grupo1
          2 logical volume(s) in volume group "grupo1" now active
      Code:
      mount /dev/mapper/grupo1-raiz
      returns an error because /dev/mapper only contains one file: control
      But there is /dev/dm-1 and /dev/dm-0 which result to be the raiz and home volumes, and I can mount them succsesfully.

      Then I followed the rest of the process described in my previous post but it seems to be some kind of error with dev-mapper


      regards
    1. caf4926's Avatar
      caf4926 -
      I can't help because I don't use LVM
      Typically I don't recommend it either
    1. fperal's Avatar
      fperal -
      Quote Originally Posted by caf4926 View Post
      I can't help because I don't use LVM
      Typically I don't recommend it either
      Me neither. It is my first time and may be the last one because It is a pain in the ass. Maybe using for /home is a good idea, but for / I'm thinking It's not.
    1. sid1950's Avatar
      sid1950 -
      Hi

      The "new" version of the forum is slightly broken. a number of links no longer work, including crucially, the link in your first post, and the link to "My Articles". I'm trying to fix a Grub2 problem, and could have done with your very good article. Luckily I found a summary of it on my backup drive!
    1. caf4926's Avatar
      caf4926 -
      Quote Originally Posted by sid1950 View Post
      Hi

      The "new" version of the forum is slightly broken. a number of links no longer work, including crucially, the link in your first post, and the link to "My Articles". I'm trying to fix a Grub2 problem, and could have done with your very good article. Luckily I found a summary of it on my backup drive!
      We know about the broken links
      It is being worked on. Not by me I hasten to add.
    1. dayfinger's Avatar
      dayfinger -
      When reading the comment of pinysuse above (January 4th 2014), I note that he is having problems where I didn't (my comment of December 16th 2013).

      So I made a check: My fstab DO HAVE /proc and /sys entries - these are not present by default in 13.1. I am running 13.1. How come this difference? My system was originally installed as 12.1, then upgraded to 12.2, to 12.3, and finally 13.1 using 'zypper dup'.

      Obviously, these fstab entries aren't removed during the upgrading process.

      dayfinger
    1. AugieHenriques's Avatar
      AugieHenriques -
      Hi,


      I have a similar problem like MikeTm, can't run grub2-install command.

      my fdisk reports

      Code:
         
        Device Boot      Start         End      Blocks   Id  System
      /dev/sda1           2048     4208639    21103296    7  Linux swap ?solaris
      /dev/sda2   *    4208640       10239  2145384448    f  W95 Ext'd (LBA)
      /dev/sda5        4210688       10239  2145383424   83  Linux


      When I try the LVM stuff, vgscan doesn't find any volumes. How do you know if you have/need the LVM fix?



      I'm at a loss of how to proceed to fix my problem.


      Please help?

      Thanks,
      Augie
    1. fperal's Avatar
      fperal -
      Quote Originally Posted by AugieHenriques View Post
      Hi,


      I have a similar problem like MikeTm, can't run grub2-install command.

      my fdisk reports

      Code:
         
        Device Boot      Start         End      Blocks   Id  System
      /dev/sda1           2048     4208639    21103296    7  Linux swap ?solaris
      /dev/sda2   *    4208640       10239  2145384448    f  W95 Ext'd (LBA)
      /dev/sda5        4210688       10239  2145383424   83  Linux


      When I try the LVM stuff, vgscan doesn't find any volumes. How do you know if you have/need the LVM fix?



      I'm at a loss of how to proceed to fix my problem.


      Please help?

      Thanks,
      Augie

      I don't understand. Do you have LVM? seems you have only ONE linux partition
    1. AugieHenriques's Avatar
      AugieHenriques -
      Hi,
      Any ideas why I can't run the grub-install?
      Thanks
      Augie