after “boot repair”, grub not working

Forum Forums New users New Users and General Questions after “boot repair”, grub not working

  • This topic has 13 replies, 5 voices, and was last updated Sep 28-9:57 pm by stevesr0.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #89847
    Member
    stevesr0

      Hi all,

      Long post to explain my current mess. Main points for forum members who develop grub problems is (1) I think boot-repair did something worse than update-grub (although I thought boot repair just invokes update-grub) and (2) I think working with grub rescue is arcane and the thread I linked might be of use to people using grub rescue, when a traditional procedure (? https://phoenixnap.com/kb/grub-rescue) doesn’t work.

      The story.

      I have a computer on which I had a dual boot setup with antiX and Windows 10. Recently, did a new install over the old antiX-17 install using the late 2021 antiX-21 full live usb.

      Everything seemed to go well.

      Yesterday, I wanted to get into Windows and realized that it wasn’t listed as a choice on the Grub menu.

      After doing a couple of “update-grub” from the command line without anything changing, I tried (a) mounting the Windows partition, (b) rerunning os-prober and then (c) running grub-mkconfig. This didn’t alter the bootup process – Windows was still missing from the grub menu.

      During the early boot process prior to the appearance of the grub menu, I made the Windows boot manager the initial selection, first trying this with F12, then by going into the UEFI Boot menu and altering the order of the boot drives.

      Still went to a grub menu with no Windows option.

      Finally, I tried “boot repair” from the antiX control centre. I chose reinstall grub to the esp partition and after this, I was no longer able to get to a working grub menu.

      The system now boots to Grub rescue displaying and error message – grub_native_sectors not found. I found a suggestion to look for the boot partition at the grub rescue command line using the ls command, but when I try this, all I get is the partition filesystem (ext2 or unknown).

      I also found a solution (https://forums.debian.net/viewtopic.php?p=756547#p756547) that involves running (at the grub rescue command line dpkg-reconfigure grub-efi-amd64 and then forcing the install to the removable directory (/boot/efi/EFI/boot), which will be used by grub if the regular location isn’t working.

      Presumably, after regaining the ability to boot into the installed antiX-21 system, I can try to further rehabilitate grub, if I understand how what is wrongly configured that update-grub and boot repair couldn’t fix.

      All assistance and advice appreciated.

      stevesr0

      #89849
      Moderator
      Brian Masinick
        Helpful
        Up
        0
        ::

        @stevesr0: I’d have to “think about this” some more to give you really good advice, because it’s been quite a few years now since I’ve had ANY Windows instance on any of my computers. I used to keep one handy, 1) to have and retain knowledge of the boot loader and boot manager for multiple OS situations. but that is in the distant past at this point. 2) It is definitely still possible to boot with multiple operating system types as well as distributions.

        I’ll take a look in a moment, maybe even before I complete this note, but the first thing I’d check is whether the Windows partition is viewable or accessible from fdisk or a similar disk partitioning tool. If system tools like this don’t recognize the presence of another OS image, then the boot loaders won’t either; fdisk SHOULD be able to identify the partition.

        The EndeavourOS has a huge thread related to the GRUB problem that many people recently experienced. There may be a few tidbits you can “glean” from that thread if you scan through it, (though if you attempt to read the entire thread, it’ll be VERY time consuming, with 1311 entries as I write this (and climbing), see here: https://forum.endeavouros.com/t/grub-2-2-06-r322-gd9b4638c5-1-wont-boot-and-goes-straight-to-the-bios-after-update/30653

        Other topics that may help in some way:
        https://linuxconfig.org/booting-a-ms-windows-os-using-grub
        https://linuxconfig.org/manjaro-linux-windows-10-dual-boot
        https://itsfoss.com/no-grub-windows-linux/
        https://www.tomshardware.com/how-to/dual-boot-linux-and-windows-11

        That ought to be sufficient. Just for reference, keep the official GRUB 2 page handy too (I always keep a bookmark of this):
        https://www.gnu.org/software/grub/manual/grub/grub.html

        Hope this helps; if you have any questions about the content in any of these, I ought to be able to answer; hopefully they’re reasonably self-explanatory.

        --
        Brian Masinick

        #89850
        Moderator
        Brian Masinick
          Helpful
          Up
          0
          ::

          Reading the GRUB 2 manual, I DO remember something I had to do in my custom configuration, and with GRUB 2, it’s the ONLY way I’ve ever successfully booted Linux and Windows systems on the same computer:

            5.4.4 DOS/Windows

          GRUB cannot boot DOS or Windows directly, so you must chain-load them (see Chain-loading). However, their boot loaders have some critical deficiencies, so it may not work to just chain-load them. To overcome the problems, GRUB provides you with two helper functions.

          If you have installed DOS (or Windows) on a non-first hard disk, you have to use the disk swapping technique, because that OS cannot boot from any disks but the first one. The workaround used in GRUB is the command drivemap (see drivemap), like this:

          drivemap -s (hd0) (hd1)

          This performs a virtual swap between your first and second hard drive. “

          --
          Brian Masinick

          #89851
          Member
          stevesr0
            Helpful
            Up
            0
            ::

            Hi Brian M.,

            Thanks for your quick response.

            I will have a look at the links you mentioned.

            AMAZINGLY, immediately after posting, I tried changing the boot order in the BIOS – moving MX21 ahead of antiX21 and the computer booted in a normal fashion to the grub menu (which lists antiX21 as the only OS).

            Why this should work I don’t understand.

            I know that there IS an MX efi boot file in addition to the antiX21 efi boot file, but MX has never been installed on this computer. (Perhaps this is because the two distros are “cousins” and share a jointly developed efi boot setup.)

            It does suggest to me that the problem might be my antiX boot efi file got damaged by too much fotzing with update-grub and “boot repair”.

            Now, my only remaining problems are:

            (1) How to boot Windows 10 and (2) whether I need to fix the antiX21 boot file to avoid future problems if the MX boot file changes.

            stevesr0

            #89852
            Moderator
            Brian Masinick
              Helpful
              Up
              0
              ::

              re: (1) How to boot Windows 10 and (2) whether I need to fix the antiX21 boot file to avoid future problems if the MX boot file changes.

              Personally I’d fix both.
              First, try running sudo update-grub, then examine /boot/grub/grub.cfg and see if it has what you want.
              Second, switch to root (sudo su -) ought to do it, and then closely examine the /boot tree, particularly the contents within /boot/efi, possibly /boot/efi/EFI. Anything foreign you can probably remove, but then make sure that you run update-grub again, then re-examine /boot/grub/grub.cfg to make sure you still have a bootable system.

              Finally, add drivemap -s (hd0) (hd1) after the primary entries, (do this in /etc/grub.d/40_custom, then add the chainloader –
              this one provides a few examples that might be helpful: https://wiki.gentoo.org/wiki/GRUB/Chainloading

              /etc/grub.d/40_custom – Chainloading another bootloader

              menuentry "Custom Super Bootloader Example" {
                   insmod part_msdos
                   insmod chain
                   chainloader (hd1,1)+1
              }

              --
              Brian Masinick

              #89853
              Moderator
              Brian Masinick
                Helpful
                Up
                0
                ::

                You may have to alter the specific chainloader reference depending on your specific setup, but this is pretty close to what you need.

                --
                Brian Masinick

                #89860
                Member
                olsztyn
                  Helpful
                  Up
                  0
                  ::

                  re: (1) How to boot Windows 10 and (2) whether I need to fix the antiX21 boot file to avoid future problems if the MX boot file changes.
                  Personally I’d fix both.
                  First, try running sudo update-grub, then examine /boot/grub/grub.cfg and see if it has what you want.
                  Second, switch to root (sudo su -) ought to do it, and then closely examine the /boot tree, particularly the contents within /boot/efi, possibly /boot/efi/EFI. Anything foreign you can probably remove, but then make sure that you run update-grub again, then re-examine /boot/grub/grub.cfg to make sure you still have a bootable system.

                  Thank you Brian for a good lesson to me as well on how to approach the task of fixing Grub. Although I do not use Grub too often I can sympathize with stevesr0 as I used to get all kinds of issues with messing up Grub in dual boot scenario.
                  In most cases though my running Boot Repair from antiX 21 Live was sufficient in my case to re-instate Windows entry in the menu.
                  In principle the Windows partition should be intact and should be bootable, just Grub menu is an issue to fix.
                  @ stevesr0:
                  You should be able to boot Windows in the following way, just to prove Windows partition is fine:
                  Boot antiX 21 Live USB and from the initial boot screen go to Grub Menus / Boot Rescue menu. Run Boot Rescue function and let it discover Windows Boot loader. Select the Windows Boot Loader from the menu and press Enter to boot Windows. Windows should boot normally.
                  Live antiX has these precious tools buried deep in the antiX live boot menus and they are as good as any third party tools…

                  Live antiX Boot Options (Previously posted by Xecure):
                  https://antixlinuxfan.miraheze.org/wiki/Table_of_antiX_Boot_Parameters

                  #89865
                  Anonymous
                    Helpful
                    Up
                    0
                    ::

                    Hello steve,

                    unfortunately you do not specify which version of grub-pc, os-prober and WINDOWS you are using.

                    I assume the error is in the compination of the three:
                    – os-prober is set to “not executable” in the future
                    – grub-efi had a problem with WIN-11

                    For a sid user it is generally not a good idea to use these “antiX tool’s”. The terminal is always the measure of all things and reading Debian-Changelog leads to general understanding.

                    I think at least grub2 (2.06-3) and an update-grub, should take care that the WIN-11 appears in the menu again.

                    #89867
                    Member
                    stevesr0
                      Helpful
                      Up
                      0
                      ::

                      Thanks Brian M., olsztyn and male,

                      FIRST OF ALL (mea culpa)

                      I have to make clear what I think is the particular basis for the Windows problem – its boot directory including the efi/bootmgfw.exe file is gone. I don’t know when or how, but I think it occurred when I (uh-hem, blush) deleted (IIRC) /bin/bash.

                      So I am planning to follow the standard instructions (after I have studied/practiced them) for regenerating that directory. I have a neighbor who is an serious computer user who mainly uses Windows who I hope will be able to assist.

                      SECONDLY,

                      I appreciate all the useful advice and I do think it is all valid in the usual situation when one hasn’t bolloxed (sp?) their system as I did mine.

                      I will follow up with any progress – it might be especially edifying to other noobies with loose fingers.

                      stevesr0

                      #89872
                      Member
                      Robin
                        Helpful
                        Up
                        0
                        ::

                        I made the Windows boot manager the initial selection, …

                        In my understanding this implies: Windows is installed on a second physical drive. Is this assumption correct?

                        …first trying this with F12, then by going into the UEFI Boot menu and altering the order of the boot drives.

                        Then this implies something is wrong with the windows hdd boot sector itself. (Maybe you’ve managed unintentionally to install a grub there also, overwriting the windows bootsector of this drive) Otherwise using the direct boot to a specific physical medium via selection during startup must boot from the windows drive, whithout seeing the grub on the other hdd at all. Make sure you’ve set BIOS or UEFI to “don’t try other boot devices”. When booting this way it should display something like “no OS found on boot medium found” if it can’t start windows for some reason, instead of automatically booting from the next drive (which contains grub boot loader). You could even try to disable the second hdd completely in BIOS for testing purpose, or plug it off physically for this test. Then Windows must come up, otherwise the Windows installation is damaged and needs to be fixed in the first place. So repair the windows installation.

                        After you’ve made sure windows can boot when the second hdd is not present, then plug in, add or activate the second hdd containing linux and grub bootmanager again. Check that you can boot into windows still when using the early boot selector provided by BIOS/UEFI. If this works, boot to the second boot medium containing grub and linux the same way.

                        Now you need to make grub aware of this windows system on the other hdd. For this it is crucial to have this windows and efi drive properly in your fstab, so it can be seen by the grub menu config tools. Try mounting both of them using the ntfs and vfat mount option, e.g. sudo mount -t ntfs … and sudo mount -t vfat … for the efi partition.
                        Make sure your grub.cfg in use (or /etc/default/grub) contains the string GRUB_DISABLE_OS_PROBER=false. You need to update-grub or grub-mkconfig -o /path/to/grub.cfg to copy the changes to your grub.cfg, it should recognise the windows install on the other hdd and add the respective entry to the grub menu now.

                        If grub still doesn’t recognise the windows on the other hdd, you can try to add a chainload manually to the grub.cfg

                        menuentry "Windows" {
                        insmod part_gpt
                        insmod chain
                        set root=(hd0,gpt1)
                        chainloader /EFI/Microsoft/Boot/bootmgfw.efi
                        }
                        

                        where the entry behind set root= is to be set to your actual findings, it must point to the efi boot partition, not the windows partition itself. You can get the proper partition and drive naming as grub sees it during boot, when entering grub console while startup and use the ls command in it. Refer to grub manual for details about naming convention.

                        If no efi partition present, and windows runs plainly on ntfs the entry would look like this:

                        menuentry "Windows" {
                        	insmod chain
                        	insmod ntfs
                        	set root=(hd0,1)
                        	chainloader +1
                        }

                        Also here you need to modify the values behind set root= to your actual findings. But no idea whether the modern windows versions will accept this way without efi, this is how I did id for Win2000/XP systems long ago. Anyway, it’s worth trying.

                        Don’t forget update-grub or grub-mkconfig -o /path/to/grub.cfg always after manually editing the grub config to make the effects take place in the boot menu.

                        Some more knowledge about grub2 configuration you’ll find in this advisory, it doesn’t care it’s from ubuntu, the concept is identically for all debian derivates.

                        Windows is like a submarine. Open a window and serious problems will start.

                        #89873
                        Member
                        Robin
                          Helpful
                          Up
                          0
                          ::

                          its boot directory including the efi/bootmgfw.exe file is gone.

                          OK, your posting wasn’t there when I started writing my lengthy advisory above.
                          And yes, this was my first guess, your windows must have been damaged in some way, otherwise it would have come up via early boot selector menu provided by bios/uefi.

                          Windows is like a submarine. Open a window and serious problems will start.

                          #89879
                          Moderator
                          Brian Masinick
                            Helpful
                            Up
                            0
                            ::

                            stevesr0 said:

                            I have to make clear what I think is the particular basis for the Windows problem – its boot directory including the efi/bootmgfw.exe file is gone. I don’t know when or how, but I think it occurred when I (uh-hem, blush) deleted (IIRC) /bin/bash

                            In that case, step 1 would be to run a Windows repair procedure (with a Windows boot repair device, if you have one). If not, look for a way to obtain one, assuming you still want to retain the Windows image and make it accessible.

                            Another alternative MIGHT be to grab a Linux boot recovery image, such as Super Grub2 Disk or Parted Magic. When I had a messed up GRUB setup recently, I used Super Grub2 Disk to literally access any of my systems. However, given your comment above, repairing the Windows boot point is vital; if either of these tools can do this (and I’m not sure either way, but it’s worth a try), you may be in business; otherwise, either of them are great tools to work with your systems; Super Grub2 Disk is very handy finding boot records anywhere, and Parted Magic is really good for setting up partitions; they’re not the only tools or the only way to work with boot blocks or partitions, but they do come in handy.

                            I would suggest a Windows recovery tool is appropriate for Windows, then once that’s fixed, these other tools and methods described in this thread will become useful tools for other matters. You can also use our own tools, but these three things are probably good to keep around too.

                            --
                            Brian Masinick

                            #89885
                            Moderator
                            Brian Masinick
                              Helpful
                              Up
                              0
                              ::

                              I hope I’m not “beating this topic too far into the ground”, but since it’s likely to be something that comes up fairly often, not only for stevesr0, but many of us, myself included, occasionally have to repair our boot loader, boot manager, or both.

                              SystemRescue is yet another tool that I have bookmarked, and I happened to look at another article on their site today that may be helpful to someone in the future; so at the risk of too much information, here’s another resource to keep handy, and possibly to add to the bookmarks and items in our personal toolchest:

                              https://www.system-rescue.org/disk-partitioning/Repairing-a-damaged-Grub/

                              --
                              Brian Masinick

                              #89900
                              Member
                              stevesr0
                                Helpful
                                Up
                                0
                                ::

                                Hi all responders,

                                First of all thanks.

                                I will look over all the references (thanks), and plan to report back after I fix things with anything I believe would be useful to other dual booters who find themselves trying to fix similar problems.

                                As Brian M. said, not to drag out this thread (at this point <g>).

                                stevesr0

                                P.S. That is not to say anyone with a neat thought shouldn’t post <g>.

                              Viewing 14 posts - 1 through 14 (of 14 total)
                              • You must be logged in to reply to this topic.