View Full Version : Howto: Easy GRUB Bootloader Repair without external media
tuxcantfly
February 8th, 2008, 12:39 AM
Purpose
Let's say you've just reinstalled Windows, and are up and running fine, only you can't boot your Ubuntu install anymore because Windows has wiped out GRUB, the bootloader needed to boot Ubuntu. If you're a seasoned Linux guru, you'll instantly whip out your collection of recovery disks and hammer out a few commands to restore GRUB; however, if you're simply an average user who hasn't memorized the commands required to restore GRUB, don't have the necessary liveCDs or can't boot them, or simply want to avoid the command line, this guide will help you easily restore GRUB.
Requirements
A bootable Windows install; any version from 98 to Vista will work.
Note: An existing install of a modern Linux distro (Ubuntu, Fedora, etc) will also work (same instructions, just use the deb/rpm/sh package on the download page), though this guide focuses on Windows.
What this Does (technical details)
When you run the .exe file, it modifies your Windows bootloader to provide an option to load GRLDR from GRUB4DOS (https://gna.org/projects/grub4dos/). GRLDR, in turn, loads a floppy image containing the Super Grub Disk (http://supergrub.forjamari.linex.org/) bootloader repair utility via Memdisk (http://syslinux.zytor.com/memdisk.php). This way, it loads the floppy image into RAM and boots from it, allowing you to start up the GRUB recovery tool and repair/restore your GRUB install. Afterwards, upon the next Windows bootup, the utility uninstalls itself and removes the extra menu entry for loading the Super Grub Disk image from Windows, thus leaving you with only a standard dual-boot GRUB configuration between Windows and Ubuntu.
Instructions
1. Download (http://unetbootin.sourceforge.net/unetbootin-windows-latest.exe) the latest Windows (.exe) version of UNetbootin (http://unetbootin.sourceforge.net/)
2. Run the .exe file, select "Super Grub Disk" in the distribution selector box and press OK, wait as Super Grub Disk is downloaded and installed, then reboot:
http://ubuntuforums.org/attachment.php?attachmentid=59050&d=1202444316
3. Upon the next bootup, you'll see 2 boot menu entries: One for Windows, and below it, one labeled UNetbootin-supergrubdisk.
http://ubuntuforums.org/attachment.php?attachmentid=59051&d=1202444583
Select the UNetbootin-supergrubdisk boot option, press enter, and it will present you with the Super Grub Disk interface.
4. Select the default options ("Super Grub Disk with Help" and "English Super Grub Disk") on the first 2 prompts, press enter a few times after that to accept the license terms and see the instructions, then you'll get to a page titled "English Super Grub Disk (Help)":
http://ubuntuforums.org/attachment.php?attachmentid=59047&d=1202444109
Select the first option, "GNU/Linux".
Press enter a few times again to scroll through the instructions, and you'll see a menu titled "GNU/Linux (Help)":
http://ubuntuforums.org/attachment.php?attachmentid=59048&d=1202444109
Select the first option, "Fix Boot of GNU/Linux (GRUB)". Now it will ask you to specify which Ubuntu install's GRUB bootloader to restore. Given that you likely only have 1 install, select the first among the options; it should have an entry under "OS" titled either "Boot" or "Ubuntu":
http://ubuntuforums.org/attachment.php?attachmentid=59049&d=1202444109
5. Now, you'll be presented with a success screen, and can now reboot. Do so, and upon the next reboot, the GRUB menu should now show up and you should again be able to dual-boot between Windows and Ubuntu.
However, the next time you boot Windows, should you want to remove the second menu entry generated by UNetbootin for loading the Super Grub Disk, simply select yes when prompted "Are you sure you want to remove UNetbootin?" after logging in to remove UNetbootin, and that'll undo the Windows bootloader changes so you're left with only GRUB and a standard dual-boot setup.
Credits/More
The Super Grub Disk can also be used for various other purposes; for a description of its more advanced options and functionality see the documentation (http://supergrub.forjamari.linex.org/?section=documentation) on the site. UNetbootin (http://unetbootin.sourceforge.net/), which also supports liveUSB creation and no-CD installations of Ubuntu and various other distros, was created by me, the other tools used (Super Grub Disk, GRUB4DOS, Memdisk) were created by their respective authors. Feel free to post a question if you have issues with the loader (UNetbootin) itself, but if it's a general Super Grub Disk bug, make sure to report it on the Super Grub Disk site.
adrian15
February 22nd, 2008, 08:11 AM
First of all thank you TuxCantFly for this tool I have written a piece of news on my site about it.
I also want to say that memdisk in order to load the super grub disk floppy (or another floppy) uses an special BIOS interruption.
There are some BIOS that do not support this interruption (like the qemu BIOS) so this method will not work always.
Finally, this is optional, you can make your howto smaller if you say to select:
GRUB => MBR & !LINUX! (1) AUTO ;-)))
if you have only one linux
This option fixes GRUB without asking anything.
or
GRUB => MBR & !LINUX! (>2) MANUAL |8-)
if you have more than one linux.
This option is equivalent to SGD(With Help)->Linux ->Fix Boot of Linux
Thank you again TuxCantFly.
adrian15
adrian15
February 22nd, 2008, 10:33 AM
What this Does (technical details)
When you run the .exe file, it modifies your Windows bootloader to provide an option to load GRLDR from GRUB4DOS (https://gna.org/projects/grub4dos/). GRLDR, in turn, loads a floppy image containing the Super Grub Disk (http://supergrub.forjamari.linex.org/) bootloader repair utility via Memdisk (http://syslinux.zytor.com/memdisk.php). This way, it loads the floppy image into RAM and boots from it, allowing you to start up the GRUB recovery tool and repair/restore your GRUB install. Afterwards, upon the next Windows bootup, the utility uninstalls itself and removes the extra menu entry for loading the Super Grub Disk image from Windows, thus leaving you with only a standard dual-boot GRUB configuration between Windows and Ubuntu.
I download the unetbootin-supergrubdisk exe, save it to my pendrive and I run it in a computer that does not have an internet connection. Will it work?
Or if you prefer... does unetbootin-SuperGrubDisk need internet connection in order to download the super grub disk floppy image or not?
I've readLinux.com unebootin article (http://www.linux.com/feature/124684) and I have this doubt. ;)
Thank you.
adrian15
tuxcantfly
February 25th, 2008, 02:38 AM
I download the unetbootin-supergrubdisk exe, save it to my pendrive and I run it in a computer that does not have an internet connection. Will it work?
Or if you prefer... does unetbootin-SuperGrubDisk need internet connection in order to download the super grub disk floppy image or not?
I've readLinux.com unebootin article (http://www.linux.com/feature/124684) and I have this doubt. ;)
Thank you.
adrian15
No, this version doesn't need an internet connection to install; the initrd/kernel (floppy image and memdisk) is bundled in. So yes, it'll work fine without an internet connection.
Finally, this is optional, you can make your howto smaller if you say to select:
GRUB => MBR & !LINUX! (1) AUTO ;-)))
if you have only one linux
This option fixes GRUB without asking anything.
or
GRUB => MBR & !LINUX! (>2) MANUAL |8-)
if you have more than one linux.
True, though the current howto's screenshots also expose the option to boot directly into Ubuntu first, which some may prefer (so that the official grub-install from Ubuntu is used rather than SGD's grub-install), so I'll leave it as is.
peter b
March 30th, 2008, 03:06 PM
tuxcantfly,
for sure you're aware of easyBCD package of NeoSmart Tech. Basically it is a boot manager that's installed on the vista partition and configures a boot menu that allows booting of vista, xp and ubuntu in my case, via vista BCD.
I installed it some time back and it's doing what it says. However, at that time there was ONLY gutsy installed on a logical (/ on sda6 and swap on sda7) with grub on sda6. It picked up the bootsector and configured BCD with a new entry on the boot menu called Neo Linux. After just to make sure, I copied the PBR to a file with dd.
The other day I installed hardy beta to sda8 (/) and /home to sda9. And as usual, I've asked ubuntu to install grub to sda8. But..., after reboot Vista would not boot at all. I had to use vista dvd and the command prompt to recover. For some reason MBR was corrupted which did not happen with the gutsy install. Checking further, I said, fully knowing that in this case there is no more PBR, give it a try and copy with dd the PBR on sda8; indeed the file was 0 bytes no 512.
My question is, is there a way to get sda8 PBR recovered somehow? and then get it on file with dd under gutsy? this file is mandatory in order to configure BCD with bcdedit in vista and create a new boot option besides the 3 existing ones.
any help appreciated.
regards,
peter b
tuxcantfly
March 30th, 2008, 07:38 PM
tuxcantfly,
for sure you're aware of easyBCD package of NeoSmart Tech. Basically it is a boot manager that's installed on the vista partition and configures a boot menu that allows booting of vista, xp and ubuntu in my case, via vista BCD.
I installed it some time back and it's doing what it says. However, at that time there was ONLY gutsy installed on a logical (/ on sda6 and swap on sda7) with grub on sda6. It picked up the bootsector and configured BCD with a new entry on the boot menu called Neo Linux. After just to make sure, I copied the PBR to a file with dd.
The other day I installed hardy beta to sda8 (/) and /home to sda9. And as usual, I've asked ubuntu to install grub to sda8. But..., after reboot Vista would not boot at all. I had to use vista dvd and the command prompt to recover. For some reason MBR was corrupted which did not happen with the gutsy install. Checking further, I said, fully knowing that in this case there is no more PBR, give it a try and copy with dd the PBR on sda8; indeed the file was 0 bytes no 512.
My question is, is there a way to get sda8 PBR recovered somehow? and then get it on file with dd under gutsy? this file is mandatory in order to configure BCD with bcdedit in vista and create a new boot option besides the 3 existing ones.
any help appreciated.
regards,
peter b
Boot Gutsy, mount /dev/sda8 somewhere (ex: /media/sda8 ), then run the command:
sudo grub-install /dev/sda8 --root-directory=/media/sda8
Hopefully that'll install GRUB onto the Hardy partition, thereby allowing you to chainload it via Vista's bootloader.
peter b
March 30th, 2008, 09:28 PM
thank you tuxcantfly, I appreciate.
now, I used the hardy alternate CD and the rescue option --> i got the root shell of sda8 and with
grub-install /dev/sda8
I got an output of success --> so at this time I assume that sda8 has the PBR (I did not try copying it yet). Please be so kind and check dd command below that I intend to use via same root shell provided by the rescue option of hardy alternate CD to get the PBR to a file called hardypbr.bin in /media folder of sda8
dd if=/dev/sda8 of=/media/hardypbr.bin bs=512 count=1
the only thing I'm not sure is whether /media was mounted so hardypbr.bin can be copied to it or this command
dd if-/dev/sda9 of=mnt/sda6/home/peter/hardypbr.bin bs-512 count=1
to get it copied to gutsy /home/peter.
what's your opinion please?
tu, peter b
peter b
March 30th, 2008, 09:34 PM
sorry for typos
dd if-/dev/sda9 of=mnt/sda6/home/peter/hardypbr.bin bs-512 count=1
should be
dd if=/dev/sda8 of=/mnt/sda6/home/peter/hardypbr.bin bs=512 count=1
sarry again.
peter b
peter b
March 30th, 2008, 10:37 PM
tuxcantfly,
all is OK, file created with the first dd command in /media and already copied to C:\ vista for BCDEDIT edit and creation of new boot entry.
thanks a lot.
peter b
adrian15
March 31st, 2008, 11:05 AM
My question is, is there a way to get sda8 PBR recovered somehow? and then get it on file with dd under gutsy?
If you want to use Super Grub Disk. You can use Super Grub Disk version 0.9701 or later. Super Grub Disk (with Help) -> Windows -> Windows boots grub!.
This is the equivalent of grub-install /dev/whatever.
It even works if the linux is found on a second hard disk (usually with normal grub you cannot chainload grub from windows' boot.ini (or vista boot file) if Linux is on second hard disk).
adrian15
tuxcantfly
June 29th, 2008, 03:04 AM
Note that the following 2 utilities are also available, which may work better than the outdated build used in this guide:
UNetbootin (http://unetbootin.sourceforge.net/) (this will install Super Grub Disk by selecting it from the Distributions drop-down box)
Auto Super Grub Disk (http://www.supergrubdisk.org/)
wingryder
January 16th, 2010, 12:02 PM
Help newbe struggling to get Ubuntu back after Xp install. When I install the grub fix program and select Unetbootin I get "Windows cannot start..... cannot read from selected boot disk."
Xp boots ok if I select it.
here is my drive info
sda
sda1 boot ntfs
sda2 extended
sda5 Linux Swap/Solaris
sdb sdb1 boot ntfs
I do not see the Linux partition for Ubuntu. Maybe I lost it when I installed XP. So if I re-install Ubuntu will I still have XP or do I need to start over... installing each OS to its own drive with the other one disconnected?
wingryder
:(
ydeardorff
January 31st, 2010, 12:00 AM
hey I need some help.
I have had an error within vista that has caused my dvd rom to bonk out on me.
I have fully installed and updated windows vista on a separate partition using a flash drive.
I then ran unetbootin to fix the grub install, only to have it wipe out the vista boot ability all I get is a /boot/bcd error.
I have tried to find a way to fix the error within /media/boot/bcd from within ubuntu as thats all I have working now. But no luck.
Can anyone help here? with no DVD drive I have no way I can find to fix this within ubuntu.
And to make matters worse, booting with a USB drive wont run the repair feature. I dont know why.
NacIK
April 21st, 2010, 10:47 PM
I am using a Aspire One with Windows 7 and Ubuntu 9.10. I guess something happened to my grub menu file and now it wont boot. It just boots to the grub command prompt. I tried to use the above method to make a bootable SD card so that I can install Super Grub Disk and fix it, but no matter what I install on any card and boot from it on my computer it throws the prompt:
BOOTMGR is missing
Press Ctrl+Alt+Del to restart
What now? Anyone know why it is doing this? I installed 9.04 just fine with this program and same setup before with no problems
Note: I am using the Windows version of UNetbootin from my wife's Windows 7 Aspire One.
bocaccio
July 25th, 2010, 10:15 PM
Purpose
Let's say you've just reinstalled Windows, and are up and running fine, only you can't boot your Ubuntu install anymore because Windows has wiped out GRUB, the bootloader needed to boot Ubuntu. If you're a seasoned Linux guru, you'll instantly whip out your collection of recovery disks and hammer out a few commands to restore GRUB; however, if you're simply an average user who hasn't memorized the commands required to restore GRUB, don't have the necessary liveCDs or can't boot them, or simply want to avoid the command line, this guide will help you easily restore GRUB.
Requirements
A bootable Windows install; any version from 98 to Vista will work.
Note: An existing install of a modern Linux distro (Ubuntu, Fedora, etc) will also work (same instructions, just use the deb/rpm/sh package on the download page), though this guide focuses on Windows.
What this Does (technical details)
When you run the .exe file, it modifies your Windows bootloader to provide an option to load GRLDR from GRUB4DOS (https://gna.org/projects/grub4dos/). GRLDR, in turn, loads a floppy image containing the Super Grub Disk (http://supergrub.forjamari.linex.org/) bootloader repair utility via Memdisk (http://syslinux.zytor.com/memdisk.php). This way, it loads the floppy image into RAM and boots from it, allowing you to start up the GRUB recovery tool and repair/restore your GRUB install. Afterwards, upon the next Windows bootup, the utility uninstalls itself and removes the extra menu entry for loading the Super Grub Disk image from Windows, thus leaving you with only a standard dual-boot GRUB configuration between Windows and Ubuntu.
Instructions
1. Download (http://unetbootin.sourceforge.net/unetbootin-windows-latest.exe) the latest Windows (.exe) version of UNetbootin (http://unetbootin.sourceforge.net/)
2. Run the .exe file, select "Super Grub Disk" in the distribution selector box and press OK, wait as Super Grub Disk is downloaded and installed, then reboot:
http://ubuntuforums.org/attachment.php?attachmentid=59050&d=1202444316
3. Upon the next bootup, you'll see 2 boot menu entries: One for Windows, and below it, one labeled UNetbootin-supergrubdisk.
http://ubuntuforums.org/attachment.php?attachmentid=59051&d=1202444583
Select the UNetbootin-supergrubdisk boot option, press enter, and it will present you with the Super Grub Disk interface.
4. Select the default options ("Super Grub Disk with Help" and "English Super Grub Disk") on the first 2 prompts, press enter a few times after that to accept the license terms and see the instructions, then you'll get to a page titled "English Super Grub Disk (Help)":
http://ubuntuforums.org/attachment.php?attachmentid=59047&d=1202444109
Select the first option, "GNU/Linux".
Press enter a few times again to scroll through the instructions, and you'll see a menu titled "GNU/Linux (Help)":
http://ubuntuforums.org/attachment.php?attachmentid=59048&d=1202444109
Select the first option, "Fix Boot of GNU/Linux (GRUB)". Now it will ask you to specify which Ubuntu install's GRUB bootloader to restore. Given that you likely only have 1 install, select the first among the options; it should have an entry under "OS" titled either "Boot" or "Ubuntu":
http://ubuntuforums.org/attachment.php?attachmentid=59049&d=1202444109
5. Now, you'll be presented with a success screen, and can now reboot. Do so, and upon the next reboot, the GRUB menu should now show up and you should again be able to dual-boot between Windows and Ubuntu.
However, the next time you boot Windows, should you want to remove the second menu entry generated by UNetbootin for loading the Super Grub Disk, simply select yes when prompted "Are you sure you want to remove UNetbootin?" after logging in to remove UNetbootin, and that'll undo the Windows bootloader changes so you're left with only GRUB and a standard dual-boot setup.
Credits/More
The Super Grub Disk can also be used for various other purposes; for a description of its more advanced options and functionality see the documentation (http://supergrub.forjamari.linex.org/?section=documentation) on the site. UNetbootin (http://unetbootin.sourceforge.net/), which also supports liveUSB creation and no-CD installations of Ubuntu and various other distros, was created by me, the other tools used (Super Grub Disk, GRUB4DOS, Memdisk) were created by their respective authors. Feel free to post a question if you have issues with the loader (UNetbootin) itself, but if it's a general Super Grub Disk bug, make sure to report it on the Super Grub Disk site.
I found a sgd file that was an executable and was about 5mb in size. Do i just use UNetbootin to boot with this like i would with any linux distro? My use of this would be to fix the boot grub after i wipe win7 partition and install xp on it; so i would then be able to boot xp and ubuntu without wiping all and starting over again.
SGD will repair the grub?
tuxcantfly
July 26th, 2010, 01:17 AM
I found a sgd file that was an executable and was about 5mb in size. Do i just use UNetbootin to boot with this like i would with any linux distro? My use of this would be to fix the boot grub after i wipe win7 partition and install xp on it; so i would then be able to boot xp and ubuntu without wiping all and starting over again.
SGD will repair the grub?
I assume the 5MB executable you're referring to is Auto Super Grub Disk from http://supergrubdisk.org/ ? That's actually an older, customized build of UNetbootin I built, that has the Super Grub Disk floppy disk image embedded inside, so you don't have to separately download it. You should be able to simply run the executable and follow the instructions at http://www.supergrubdisk.org/wiki/AutoSuperGrubDisk
However, if you're simply following the instructions I have in my post, you will not need the Auto Super Grub Disk executable file; it will automatically download the latest Super Grub Disk floppy disk image file for you and use it.
bocaccio
July 26th, 2010, 03:05 AM
So I have 7 and ubuntu now. And once if i do...get rid of 7 and put xp on my netbook; I just need to follow your instructions and then i'll repair the boot menu and be able to boot xp and ubuntu once again? I have UNetbootin too; that's what i use to boot all my distros. It has only failed on stuff like baktrak and anonymos os. Other than that its a lifesaver!!
001aman
October 30th, 2010, 11:50 AM
Thanks for the step by step very nicely explained how to, was very helpful to me.
__________________
blog (http://www.shoppinginfo.biz)
umpirsky
June 12th, 2011, 04:09 PM
This saved me from reinstall, thanks!
smittyjones
July 7th, 2011, 04:00 PM
This saved me from reinstall, thanks!
you and me both :p (http://www.cheaptravelinsurances.org)
geazzy
July 7th, 2011, 06:24 PM
i think this is seved for reinstallation :)
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.