HOWTO: Restore Non-UEFI MBR from Live ISO

Post your tutorials and howtos here.
User avatar
ScottQuier
Posts: 1781
Joined: 18 Jul 2013 15:55
Location: Newport News, VA

HOWTO: Restore Non-UEFI MBR from Live ISO

Postby ScottQuier » 15 Apr 2014 23:34

This is not my idea. I'm just putting it all in one place so it's easy to find as it gets asked a lot.
  1. Boot your Live ISO
  2. Open a command terminal and run

    Code: Select all

    sudo os-prober
    You'll get an output that will look something like this:

    Code: Select all

    solydxk@solydxk:~$ sudo os-prober
    /dev/sda2:SolydXK (1):SolydXK:linux
    solydxk@solydxk:~$ 
    This tells us that, in this example, my SolydXK is installed in /dev/sda2
  3. Mount the SolydXK partition with this command

    Code: Select all

    sudo mount /dev/sda2 /mnt
    Remember, I'm using "2", you may need to use a different number.
  4. Now, install grub to MBR with

    Code: Select all

    sudo grub-install --root-directory=/mnt /dev/sda
  5. Reboot the computer and it should show all your install operating systems, even Windows, should that be in there somewhere :)
Scott
Quoting zerozero, "The usage of PPA's in debian-based
systems is risky at best and entails serious compatibility
problems; usually it's the best way to destroy an install"

User avatar
zerozero
Posts: 5373
Joined: 10 Feb 2013 23:37
Location: West Midlands, England
Contact:

Re: HOWTO: Restore MBR from Live ISO

Postby zerozero » 16 Apr 2014 16:12

this method doesn't work with UEFI installations;
it goes without errors but next boot we are presented with

Code: Select all

error invalid arch independent elf magic
the proposed fixes i found until now don't work
http://askubuntu.com/questions/72003/ho ... agic-error
i'm left at the same point or at grub rescue >

my feeling is that the solution is pretty simple but i couldn't put my finger on it yet
(even tried chrooting but that didn't help)
bliss of ignorance

User avatar
m00se
Posts: 63
Joined: 19 Mar 2014 17:06
Location: Alaska

Re: HOWTO: Restore MBR from Live ISO

Postby m00se » 17 Apr 2014 04:45

Thanks!! Ya Saved my bacon. :D
Fixed my GRUB and I'm in like Flynn! 8-)

This was the only option that ended up fixing my issues. Kinda wish I tried this first, but hey I learned a lot!


tea
Posts: 35
Joined: 16 Nov 2013 19:51
Location: UK

Re: HOWTO: Restore MBR from Live ISO

Postby tea » 17 Apr 2014 13:34

I had to use boot repair disk to get grub working again via reinstall grub on UEFI

User avatar
Bainespal
Posts: 9
Joined: 02 Mar 2014 22:01

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby Bainespal » 22 Apr 2014 22:56

ScottQuier wrote:[*]Now, install grub to MBR with

Code: Select all

sudo grub-install --root-directory=/mnt /dev/sda
[*]Reboot the computer and it should show all your install operating systems, even Windows, should that be in there somewhere :)[/list]
At this step I get this error:

Code: Select all

grub-probe: error: failed to get canonical path of /cow.
Installation finished. No error reported.
I assume it doesn't matter that I used my old Mint 15 DVD instead of a SolydK ISO.

Edit: That message not withstanding, it did seem to fix the immediate problem. At least, it fixed "file not found" error message.

User avatar
Graybyrd
Posts: 33
Joined: 22 Nov 2013 22:54
Location: Whidbey Island, WA
Contact:

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby Graybyrd » 14 Feb 2015 03:57

@ScottQuier

Thank you for saving my butt! (I upgraded my desktop machine, my laptop, my wife's laptop from SolydX HE to Jessie. All went well.)

Feeling confident, I then upgraded my wife's desktop machine (WinXP; SolydX dual-boot) from HE to Jessie. At the very end, the Grub screen popped up, but wouldn't allow a choice of installing grub to SDA ... it simply toggled between "yes" and "no" ...

Sad result: grub destroyed. Machine boots to "Grub Rescue>_" prompt. Now the bad thing about this: my wife's machine contains her $2k-bux Windows sewing machine & embroidery software [ !! ] and she would be somewhat unhappy with me ...

Happy Ending! Thanks to your post here, the restoration worked! One small difference: the os-prober returned two results.

"/dev/sda2 : MS XP ... :Windows:chain"
"/dev/sda3 : SolydX 32-bit (1):SolydXK:linux"

so in the "sudo mount /dev/sda#" step, I mounted both sda2 and sda3. The final "sudo grub-install" to sda worked perfectly. No errors.

No ... I did NOT tell my wife of the panic situation. But I'm telling you generous folks a bit "Thanks" for your expertise!

User avatar
bas_otten
Posts: 204
Joined: 19 Oct 2013 12:22
Location: Netherlands

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby bas_otten » 14 Feb 2015 08:27

Very useful topic. And glad you could save you machines, Graybyrd.

I also have excellent experience with
http://sourceforge.net/projects/boot-repair-cd/

It saved me lately, imagine why:
  • the jessie transition upgrades grub and requires actions in this area
  • when restoring a transitioned image (partimage) onto another computer grub's img-files in MBR are not upgraded there
  • on this target computer the Live ISO USB (to perform ScottQuier's original hint) would not boot due to the Plymouth splash bug
  • and then it becomes really funny: selecting Advanced options to start without plymouth was impossible because somehow my Logitech wireless keyboard was not detected as this stage
Thén I discovered the 'boot-repair-cd' and it did the trick :P
Regards, Bas.

User avatar
Graybyrd
Posts: 33
Joined: 22 Nov 2013 22:54
Location: Whidbey Island, WA
Contact:

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby Graybyrd » 12 Jun 2015 05:27

First off, the new community edition SolydX/K 32-bit is lovely. On top of Debian 8, it's a distinct winner.

Problem: installed 32-bit SolydX on older non-UEFI laptop, Pentium M, non-PAE, intending to dual-boot with WinXP install. (Have done this sort of dual-boot Linux install several times on other hardware. Usually no problem.)

Reboot finds start screen showing ONLY the SolydX menu. No WinXP menu.

Attempted repair: live boot SolydX install dvd.
--> sudo os-probe shows WinXP on sda1; SolydX on sda2.
--> do procedure: sudo mount /dev/sda2 /mnt
--> sudo grub-install --root-directory=/mnt /dev/sda

Should have both. Do not. Boot screen is exactly same as from former DVD install.

What can I do to repair the MBR for dual boot?

Thanks

User avatar
grizzler
Posts: 2114
Joined: 04 Mar 2013 15:45
Location: The Hague, NL

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby grizzler » 12 Jun 2015 06:00

Does running os-prober from inside the installed SolydX also show WinXP? Are there any errors when you run it or grub-install / update-grub?

The MBR doesn't need to be repaired as it only contains the code to call GRUB's core image. The core image should pick up the grub.cfg file, which apparently doesn't have the necessary lines to present the choice to start XP. If running update-grub doesn't fix that, there's always a way to add that bit manually. It's just odd that grub.cfg appears to be incomplete, since os-prober did see the XP install...
Frank

SolydX EE 64 - tracking Debian Testing

User avatar
Graybyrd
Posts: 33
Joined: 22 Nov 2013 22:54
Location: Whidbey Island, WA
Contact:

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby Graybyrd » 12 Jun 2015 06:05

From inside the SolydX install: os-prober returns "/dev/sda1:Windows NT/2000/XP (loader) :Windows:chain"

also, no errors reported when doing the commands above.

User avatar
grizzler
Posts: 2114
Joined: 04 Mar 2013 15:45
Location: The Hague, NL

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby grizzler » 12 Jun 2015 06:11

And running update-grub still doesn't add it to the menu? Strange.

I need to check the exact code to add manual entries. Will post it here later.
Frank

SolydX EE 64 - tracking Debian Testing

User avatar
Graybyrd
Posts: 33
Joined: 22 Nov 2013 22:54
Location: Whidbey Island, WA
Contact:

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby Graybyrd » 12 Jun 2015 06:14

Just a sec ... there was no "update-grub" command ...

Alright ... :oops: ... color me face red. In my defense, I've always been terrified of messing about with Grub cuz it seems to be one of the "dark arts" and leads to bad things. But in this case, running a simple "update-grub" did the trick (after I did a cat of the grub config file in /boot/grub ...

It works perfectly. Thanks very much for the boost.

-=GB=-

User avatar
grizzler
Posts: 2114
Joined: 04 Mar 2013 15:45
Location: The Hague, NL

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby grizzler » 12 Jun 2015 06:35

Glad you got it sorted. And don't feel bad about not wanting to mess with GRUB. That's a good thing, in my view. ;)
Frank

SolydX EE 64 - tracking Debian Testing

docke
Posts: 26
Joined: 12 Apr 2015 00:00

Re: HOWTO: Restore Non-UEFI MBR from Live ISO

Postby docke » 12 Jan 2016 06:19

ScottQuier wrote:This is not my idea. I'm just putting it all in one place so it's easy to find as it gets asked a lot.
..........................
..........................
[*]Reboot the computer and it should show all your install operating systems, even Windows, should that be in there somewhere :)
Thank you so much.
Thanks your recipe, I just recovered my Grub.
:clap: :clap: :clap:


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 3 guests