Reinstall Ubuntu Grub Bootloader After Windows Wipes it Out
If you run a dual-boot system with Linux and Windows, this has happened to you. You had to do your monthly reinstall of Windows, and now you don’t see the linux bootloader anymore, so you can’t boot into Ubuntu or whatever flavor of linux you prefer.
Here’s the quick and easy way to re-enable Grub.
1) Boot off the LiveCD
2) Open a Terminal and type in the following commands, noting that the first command will put you into the grub “prompt”, and the next 3 commands will be executed there. Also note that hd0,0 implies the first hard drive and the first partition on that drive, which is where you probably installed grub to during installation. If not, then adjust accordingly.
sudo grub
> root (hd0,0)
> setup (hd0)
> exit
Reboot (removing the livecd), and your boot menu should be back.
Only read below if Windows is now missing from the boot menu
If you installed Ubuntu before you installed Windows, then Ubuntu will not have anything in the grub configuration for Windows. This is where you’ll have to do a bit of manual editing to the grub boot menu file.
If you open the file /boot/grub/menu.lst with the following command:
sudo gedit /boot/grub/menu.lst
You’ll see a sample section for Windows, which you’ll want to uncomment and add to the boot menu list in whatever position you want it in. (uncomment by removing the #’s)
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
Note that you should also verify that hd0,0 is the correct location for Windows. If you had installed Windows on the 4th partition on the drive, then you should change it to (hd0,3)


Well, it didn’t work for me, I mounted /boot to separate partition (hd0, 4) and grub failed to find the stage1 files..
I’ve to run windows repair to rewrite the boot sector in MBR.
Thanks for this solution, however it did not help my situation as windows was kind enough to rewrite the mbr on my laptop when it went into hibernate. This laptop does not have a working cd drive, thus is unable boot from a livecd.
Another solution I found is to use ntldr and load a version of grub from there (grub4dos). I think it would be a good idea to provide instructions for people on how to achieve this using ntldr and grldr.
The only caveat with having a setup like this is that you will need to copy menu.lst that grub uses to the default windows partition everytime you perform an system update (otherwise it wont load the latest kernel).
I have setup my laptop to use this method. First I added the line:
C:\grldr=”GRUB Bootloader” to windows’s boot.ini
I copied the file grldr from grub4dos to C:\
Using ext2ifs on windows I copied the menu.lst from /boot/grub to C:\ on my windows install.
After rebooting, I had a working install of GRUB. This didn’t require me to rewrite the mbr of my hard drive.
What you need to do before entering root (hd0,0) is the folowing:
find /boot/grub/stage1
This wil give you the root you have to use. In my case it wasn’t hd0,0 but hd0,1.
Once I’d used “find /boot/grub/stage1″ on hd2, I found I had to change the original command as such:
sudo grub
> root (hd2,0)
> setup (hd0)
> quit
it works on mine
sudo grub
> root (hd0,2) # this is sort of related to your partition ubuntu installed
> setup (hd0)
> exit
It worked for me. The only thing I had to do different is that I had to type
quit
instead of exit. exit doesn’t seem to be a known command.
I use a program called “Super Grub Boot Disk” that allows repair of both Windows and Grub boot loaders…google it, download it and burn it to cd…works great and has loads of optins for Windows or Linux…it’ll be worth the effort,believe me….Proximo
I use a program called “Super Grub Boot Disk” that allows repair of both Windows and Grub boot loaders…google it, download it and burn it to cd…works great and has loads of options for Windows or Linux…it’ll be worth the effort,believe me….Proximo
is there a way to do the opposite? Restore the windows boot loader? When I bought my computer I was only supplied with the factory restore disks. I tried the wubi installer but it booted to ubuntu grub then pressed enter to boot into windows xp…it brought up a windows boat loader with windows and ubuntu. I am also looking to fix my partition table, and increase ubuntu disk space also.
The first step should be find /boot/grub/stage2 and whatever it returns should be used instead (hd0,0) in your examples.
I’m passing back and forth between having ubuntu running and having Vista running. I used to have them both, though. After I re-installed Vista, it over-wrote my MBR. So I re-installed the grubloader (on hd0,0, my Vista partition…maybe that’s the problem?) but now even though Vista is listed on the boot menu, when I hit enter to boot into it, it returns me to the boot menu.
Ok guys I have a question for you. I have tried a lot of stuff on this one. Im running 2 Hard drives on my computer. My main Harddrive has windows vista on it (120gb hard drive). My second hard drive (30gb) has my linux installed on it. I cant get grub to boot. when it does boot i get a boot error. error 17. I cant even get to my second harddrive at all. I want to be able to boot into either of them when i please. What can i do to fix this guys ?!?!?!?! Thanks in advan.
To use the Windows boot loader, you can do one of two things:
In Win98/Me, type from a command line: fdisk /mbr
In Win2000/XP, go to the Recovery Console and type: fixmbr
Hope this helps.
I think VISTA would prefer to do its own thing and lead you to believe you have allowed GRUB to manage a dual-boot scenario. I see many symptoms of sneaky virtualization. You might as well run VMware.
Thank you because of you my computer have been save..
Worked for me. I used the Fiesty LiveCD since that’s what I had installed. I originally had Vista and put Fiesty on hd0,1. Then today I installed XP in the same partition as Vista and just had to run through the recommended directions with hd0,1 for the root line. At this point I can’t boot to Vista but well, that’s no real loss.
Thanks for the great guide. It really helped me.
I’ve got a case.My computer runs Windows XP, then I installed Ubuntu Fiesty 7.04. Two days ago, I ran Update Manager, it required restart, After restarting, I couldn’t get into Ubuntu ( I remember I got error when updating). I reinstalled Ubuntu but it’s stayed the same.
I guess the first time I installed Ubuntu, grub manager know where to boot Ubuntu. But in the second time, It can’t find because root disk is mouted differently.
The problems are I can’t boot Ubuntu, I can’t reinstall Ubuntu again.
Do I need install Win again that means format my primary disk to remove grub manager?
Thanks,
PS: My English is not good
with the Live CD Ubuntu
sudo grub –batch
grub>
grub> find /boot/grub/stage1
grub> root (hd0,1)
grub> setup (hd0)
grub> quit
Thank you so much! This worked perfectly after I had tried about everything else recommend by many other sites that did not work! I had installed Vista first and then after installing Ubuntu 7.10 I was unable to see Vista listed after I rebooted.
Also, after I did the procedure above and was able to see Vista listed in the grub menu, I got an error message about the MBR and wasn’t able to startup Vista. So, I booted from the Vista install DVD and, instead of choosing Install, I chose Repair. It found the Vista installation, recognized that it had a problem, and asked me if I wanted it to fix it. So, I of course said yes – repair it! It took less than a minute to fix. I rebooted, saw the grub menu, selected Vista, and it started up perfectly. I then restarted to make sure that I could still start up Ubuntu, and it worked perfectly as well!
Hope this might help someone else! The Vista Recovery is awesome compared to the old XP method!
Thanks for the great help!!!
Ok, so I had Vista installed on here once long ago, I have like 5 partitions on this workstation (hardware R5 4x 300gb) I want to nuke anything even related to vista, where to find? I see that vista stuff on the import settings menu, I imagine its causing some problems here. how can I kill the beast forever?
Thanks for the information.
I think “exit” should be “quit”, at least in Ubuntu 6.04, but that’s a minor detail
This page worked for me, but I had to first repair the partitions that Windows messed up on my MaxBlast altered hard drive. The only thing that could find my Linux partitions from my searches was Partition Table Doctor (ptdd.com). It cost me $50, but I was able to fix the partition table and MBR. Then I used this page (my partition was at hd0,2) to recreate the grub bootloader and VOILA! I am back to normal.
(Interestingly, MaxBlast, Acronis Disk Manager, and the Ultimate Boot CD could not properly read the partition table and did not work. I am especially disappointed in MaxBlast as it was the cause to begin with.)
Thank you so much. After Windows finally died completely forcing a re-install the last thing I had to worry about was how to get Ubuntu back. This worked flawlessy, though I had no idea where Linux was in the disk map before I started.
My solution was to boot the live CD then explore the local drives until I found it. Had a quick look at menu.lst and there was all the info I needed.
You saved my day
I suggest you add the following command into your procedure to insure the correct HD and partition is selected. e.g. my is on HD 0,5
find /boot/grub/stage1
Thus, making procedure
sudo grub
find /boot/grub/stage1
root (hd?,??)
setup (hd?)
quit
where hd?,?? is returned from find command.
hello friends. my ram is 256mb so i cant install ubuntu of latest version which is live cd. so i have go to the older version of ubuntu so i installed edubuntu in my computer which is not a live cd. due to some problems in my windows xp i had removed xp and reinstalled it in my computer by this my grub has lost. i want to log in into edubuntu so i should install grub. so please help me in installing grub through edubuntu.
or else i should completely remove the edubuntu and reinstall it again in my computer
thanks “Jim Murray” your explanation really help cheers
unfornately i have failed to boot OS (XP) on my laptop which came with pre-installed Windows xp. when i boot my laptop using Windows XP CD it copies the required files but when i press ENTER to install Windows XP the message appears that ” Setup did not find any hard disk drives installed in your computer. Make sure any hard disk drives are powered on and properly connected to your computer and that any disk related hardware configuration is correct. This may involve running a manufacture supplied diagnostic or setup program.
Setup cannot continue. To quit setup, press F3.” Please note I have C: drive installed windows xp on it, i have drive D: files are available for recovery disk pre-installed by the windows manufacturer. My laptop is HP dv5000. Please advise how to install boot laoder on this laptop.
with the Live CD Ubuntu
grub> find /boot/grub/stage1
(hd0,5)
grub> root (hd0,5)
grub> setup (hd0)
Checking if “/boot/grub/stage1″ exists… yes
Checking if “/boot/grub/stage2″ exists… yes
Checking if “/boot/grub/e2fs_stage1_5″ exists… yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0)”… 17 sectors are embedded.
succeeded
Running “install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,5)/boot/grub/stage2
/boot/grub/menu.lst”… failed
Error 22: No such partition
Other:
sudo mount -t ext3 /dev/sda2 /mnt
sudo grub-install –root-directory=/mnt /dev/sda
(change sda2 and sda to your linux system and drive, could be hdaX and hda)
it worked for me perfectly…
booted into livecd, and then:
sudo grub
> root (hd0,0)
> setup (hd0)
> exit
sudo gedit /boot/grub/menu.lst
and then uncommented, these: #
# title Windows 95/98/NT/2000
# root (hd0,1)
The following worked for me=>
Restore GRUB menu after Windows installation:
Use the following in the terminal -
To re-enable the GRUB
sudo grub
root (hd0,0)
setup (hd0)
exit
To identify the name of the boot drive,
cat /boot/grub/device.map
To find which drives are bootable,
sudo fdisk -l
gksudo gedit /boot/grub/menu.lst
Append the following lines at the end of file:-
title Microsoft Windows
rootnoverify (hd0,0)
savedefault
makeactive
chainloader +1
Changed few things – Added # to hiddenmenu (Menu appears on startup to choose the operating system), changed time to 5 seconds.
Save the edited file
I recovered Grub successfully. But when I select the Ubuntu options on the boot menu, it says “Can not mount selected partition”.
Hi,
Another way is by using the alternate CD, and going in to rescue mode. Use the GUI to mount your original linux installation partition i.e. the root partition. After that, start a shell on that partition, then run ’sudo grub-install’. It should fine your original grub setup and re-install it.
Just myu $0.02
I recovered Grub successfully. I can boot XP from the menu. But when I select the Ubuntu options on the boot menu, it says “Error 17 : Can not mount selected partition”. In addition, when ı try to open menu.lst from live cd, it seems empty. I need your help.
thank you!!!!
that was great!
I can boot my computer through DVD but i have got the error GRUB 17 during installation time , and after that computer cnat boot please give me better solution for the same .
Okay – I messed up my mbr and tried to use Testdisk to fix it. It was visible when I ran gparted, but there appeared to be some problem. After finishing with testdisk, I tried the grub again, and eventually managed to boot Windows, which fixed up the NTFS partitions. Then I stuck in the new HDD (now have two – first is 320GB Barracuda, and the second is a 500GB – same model, but now 500GB is the cheapest size! the extra 145gb of useable space cost half as much as the first 320 but if you go to 750GB it’s too much.
After that, windows was the only visible option, so I ran the liveCD once again, feeling very bored, and it found my boot
sudo grub
This is rather short – there should be another option, after ’sudo grub’ in ubuntu I used
grub> find /boot/grub/menu.lst
(hd0,5)
grub> root (hd0,0)
grub> setup (hd0)
grub> exit
sudo gedit /boot/grub/menu.lst
I took ‘quiet’ out so I can see how it’s loading up.
My first drive is the 320GB, and I have WindowsXP in the first (30GB) followed by swap of 3.4GB, I was hoping the hibernate would work – or the sleep. Hi hopes? and then linux ext3
I will use the second drive to house two large partitions for all documents/personal stuff, and for backups. Anyone know a one click solution to making a complete image of your linux system – as they managed to do with Vista? Vista got that right, why can’t we?
# title Windows 95/98/NT/2000
# root (hd0,1)
Yes, this did the trick for me on my laptop… but sadly, i couldn’t boot into WinXP although it was available as an option in the Grub list. ERROR12 was what I got. I’m trying out what the commenter named HEATHER to get my MBR back working…. wish me luck. I’ll post back the results, so here goes…
mine says cannot mount selected partition when in comes to setup (hd0) .
It is the correct partition tho…. anybody know whats wrong?
Me again, this is my second post. I did what Heather did, hoping to get my XP back working after restoring my Grub… but there wasn’t a fix-MBR option in my XP installation disk. Probably my ignorance to not know where to find it, but I did go thru the installation of XP to see where it is, to no avail. So I just went with another install of XP on the same disk without touching the filesystem. That worked for my XP, but lost the grub once again. Perhaps because they’re one the same disc (hd0,0), just a guess. Anyone know?
@Karuna: do this first
find /boot/grub/stage1
just for you to be sure which one it is on. Don’t forget to add the comma and the second digit. Hope this helps. I’ll post again after my grub decides to come back.
I have this problem
First disk is Windows XP
Second disk Ubuntu 8.04 Lts
I’ve formatted only first disk
and after an installation of windows I’ve installed “auto super grub disk 1.0″ for windows
reboot selet super grub
and I see
grub> findf /boot/grub/stage1
root (hd1,0)
Filesystem type is ext2fs, partition type 0×83
setup (hd0)
Checking if “/boot/grub/stage1″ exists yes
Checking if “/boot/grub/stage2″ exists yes
Checking if “/boot/grub/e2fs_stage1_5″ exists yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0)” (the cursor is here)
and the program make nothing
When I reboot manually, I see only windows bootloader and not grub
Wow, this seriously saved my ass. I can’t thank you enough!
start with a ubuntu live cd
open the console
sudo su
grub
find /boot/grub/stage1
(hd 1,0)
root (hd 1,0)
setup (hd 0)
quit
restart your pc
Okay guys, I’m stumped. I had Ubuntu 7.10 and Vista running on seperate disks using grub to switch between them no problerm. I replaced Vista with XP SP3. Don’t laugh. lol. I had my reasons. Anyway, Windows is working fine, but Linux (or at least grub, or something I don’t know about) has gone for a burton.
I tried booting from the Live CD, loading a terminal, sudo gedit /media/disk/boot/grub/menu.lst, fixing the entries, restart, select whichever kernel from grub: Error 17: Cannot load the selected partition.
Then I tried sudo grub, root (hd1,0), setup (hd1)… Error 17: Cannot load the selected partition.
As I said, I can boot a Live CD and view all my files. There is nothing wrong with the file system then, and I have grub loading with what appears to be a perfectly sound menu.lst file. But it seems no matter what I do, grub gives me error code 17.
I can of course back up all my files no problem, but I really would prefer not to have to reinstall. I made many adjustments to Ubuntu to make it work the way I want, and it would take a lot of time to get it back that way.
Please help!
the correct command is setup (hd 0) and not (hd 1)
Thanks guys (geeks), I have a similar problem thought not yet fixed, I now have an assurence that I will be able to solve it using the ubuntu liveCD. “The blue screen of death winXP”
no doubt it recover my my linux grub boot loader but when i press ubuntu 7.10, kernel… on the second screen it gives
“Error 17; cannot mount selected partition
press any key to continue….”
when i press any key it return to previous menue.
Took me ages Googling for this forum again, as I forgot the site. A few minutes after I made my last post I read the one above mine and tried that. It worked. Thank you very much ivo.
I am about to reinstall Windows (again), and am going to print this off.
My hero! Due to some weird error (possibly my hard drive on its last legs) I couldnt start any live cds with 8.10 kernel, but managed to get an old live cd working. I couldnt get it to “setup (hd0)” for some reason but eventually after lots of fiddling it gave a positive respone and everything worked! My hero!
i tried the set of commands to be written to menu.lst file but the system is unable to save it. can anybody site a reason?
Dear can anyone help me i have dual boot windows xp and ubuntu 7.01 gusty gibbon. I was installing aMSN messenger and i downloaded and make install several missing libraries farsight2 etc. but still it was giving error that no farsight etc. anyway now b/c of these attempts of installing new libs. my ubuntu has stopped booting while i can still boot xp with no problem. Can anyone help me how to solve this issue i have tried Live CD but was insatlling a fresh ubuntu. it means that i will loose my ubuntu and may be my xp will not boot. please suggest what to do.
Thanks!! Very helpful.
After installing windows ,Grub is showing options for windows and linux.But linux loads fine ,windows just comes to grub>. Please suggest me
Dear can anyone help me i have dual boot windows xp and ubuntu 7.01 gusty gibbon. I was installing aMSN messenger and i downloaded and make install several missing libraries farsight2 etc. but still it was giving error that no farsight etc. anyway now b/c of these attempts of installing new libs. my ubuntu has stopped booting while i can still boot xp with no problem. Can anyone help me how to solve this issue i have tried Live CD but was insatlling a fresh ubuntu. it means that i will loose my ubuntu and may be my xp will not boot. please suggest what to do.
Can anyone help me out there???????????????????
If you install a new release of Ubunti ie 8.10, you don’t loose Windovs xp and old configuration of gutsy 7.01
I use aMSN and i have installed with synaptic, I haven’t download the tarball or .deb
try to enable all repository …
Dear ivo
you have not mentioned that do i have to fresh install. the new version 8.10. one more thing please read my post again and see if new install will fix the problem. I am unable to boot into ubuntu anymore. it shows the boot menu and and i can boot into xp and works fine but when i select ubuntu the black screen appears and nothing happens even after 5 to 10 minutes. how can i boot into ubuntu again.
waiting for you reply
also see https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
Exellent!, pretty easy and works as describe with M$ Crappy XP and Ubuntu 8.10
if you want there’s a program called SuperGrub
You start superGrub in Windows and reboot your pc
during the first start up you see a dos screen and SuperGrug make for you a configuration of dual-boot
may be the this software make for you a correct configuration
good luck
but IMHO you must reinstall ubuntu: you have problems with start up, not in the boot menù …..
As others have said, totally saved my butt. Was reinstalling XP and it would go through all the steps and then have a bad partition setup. It was actually repeatedly installing install files before I realized it was taking too long even for Windows.
Also, I ended up needing the find /boot/grub/stage1 which gave me hd(0,5) so I ran root from there, and did hd(0).
Again, huge help, since some other solutions out there are insane.
I’m da new new kid to linux… was a “POBG” (Prisoner of Bill Gates). First off…..WOW! Linux is KING. Burnt 10 Ubuntu 8.10 cd’s and gave them all away. Next I found out some of my programs on Win-Poo won’t work on Linux. After fighting the Grub thing I wiped out the hard drive, reloaded WinPoo and shut off all the internet stuff, removed almost everything from Xpee and only use WinPoo for making CD Covers….for more Intrepid Ibex Live CD’s. Hope this makes bill’s day.
There ain’t no good reason to Keep WinPoo stuff on the HD anymore…..
I’ve come across this article because I reinstalled winxp after I had a working dualboot (Ubuntu/XP) config that the new win install screwed up. I did everything as indicated here, but it didn’t work for me. What I did instead was going to https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows and I did the following:
1. Boot the Desktop/Live CD. (Use Ubuntu 8.04 or later)
2. Open a terminal (Applications -> Accessories -> Terminal)
3. Start grub as root with the following command :
sudo grub
on the grub prompt, I typed ” find /grub/stage1 ” (without the quotes, of course
) and the result was the correct place of my grub menu. (hd0,5 in my case). Then I did
root (hd0,5)
, then
setup (hd0) then TO EXIT GRUB I did
quit
And now I got my GRUB MENU like it was before!
Hope it could be useful to you!
“find /boot/grub/stage1″
Thanks for that i highly suggest the editor of the blog adds that line !
Hi everyone
i had the same problem after reinstalling the windows
i tried the following, but it didnt work …
grub> find /boot/grub/stage1
(hd0,5)
grub> root (hd0,5)
grub> setup (hd0)
Checking if “/boot/grub/stage1″ exists… yes
Checking if “/boot/grub/stage2″ exists… yes
Checking if “/boot/grub/e2fs_stage1_5″ exists… yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0)”… 17 sectors are embedded.
succeeded
Running “install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,5)/boot/grub/stage2
/boot/grub/menu.lst”… failed
Error 12: Invalid device requested
grub>
how can i solve this?
(not i had ubuntu 6 installed & i entered the live CD of ubuntu 9.4)
Then install ubuntu 9.04 – you can’t use Ubuntu 9.04 to fix ubuntu 6! That’s funny!
Thanks for help. You could also try this: Run ubuntu from LiveCD. When its ready go to System>Administration>Partition Editor and set flag “boot” for partition with ubuntu. It worked for me.
Hi
I have installed first fedora and next windows xp. after that i deleted the linux partition from my hard dist using control panel disk management. after i restart the system is didn’t boot in windows.
its showing the command promt grub>..
How to make my system to boot in windows..
hey thanks guys. it worked for me… and to quote “You had to do your monthly reinstall of Windows”
i like the phrase monthly install of windows… heh heh
i see other way >>>
sudo fdisk -l
sudo mount /dev/hda2 /mnt
sudo grub-install –root-directory=/mnt /hda
hint: hda2 mean where linux install
thank you
This work perfectly. I had Ubuntu 9.05 and Windows XP Pro working in dual boot when I decided to complicate things by installing the Windows 7 Release Candidate. Of course Windows assumed it was the only OS on the drive and schwanked grub.
I read the entire thread including helpful comments, found the windows partitions on my drive and was up and running in a few minutes. I was unable to find /boot/grub/menu.lst to make sure windows was in it. So I took a chance and rebooted without this step. Grub showed windows 7 as XP, but that is a minor detail I can fix easily.
Thanks for the help!
Thanks Mr.”Jonathan vz”…Mine was “hd(0,5)”..i did never expected it’ll be upto 5..And i struck for about 20 minutes by just a small mistake, i didn’t give space after the “find” !!!…
ok my situation here is i have ubuntu 9.04 installed (no partition) and i want to reinstall XP so i can run cubase
but my xp backup disk is not being accepted by the computer
i think full ubuntu install precludes that
any suggestions?
ta shan
Here’s a link to Ubuntu community discussion which may help you out.
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
Yah it works but if you are sure what number of (hd) “heard disk” you installed windows Xp or Vista.
type in this command:
first – sudo grub
second – root (hd0,0) # the number of your heard disk #
third – setup (hd0,1) # frot he boot start up #
The *best* solution for restoring the MBR after a Windows install
is to backup the MBR *before* the Windows install. The tried and
true method is to use the “dd” command on the Linux side. I’ve
been doing this for years – saving the binary file to my gmail acct.
To backup the MBR, jump to a CLI and:
# dd if=/dev/hda of=mbr.bin bs=512 count=1
The result is a file (in this example), “mbr.bin” – save that off to
a safe place …. its size is 512 bytes. Ensure you have a Live CD
or original Linux install CD at hand. Also, the device name path
for the hard drive will need to be adjusted – for example, you might
have to specify “if=/dev/sda” instead of “hda”.
Do the Windows install – then to restore your saved binary image,
simply boot your Live CD or Linux install CD, jump to a CLI and:
# dd of=/dev/hda if=mbr.bin bs=512 count=1
Be sure you specify the fully-qualified path to “mbr.bin”
mjt – author, “Inside Linux”.
I failed to mention that if you ONLY want to restore the MBR itself,
then the “dd” command should be:
# dd of=/dev/hda if=mbr.bin bs=446 count=1
If you execute “dd” as I explained in my previous post, the
partition table will be restored, in addition to the MBR. So,
if you’ve done any partitioning during the Windows install,
you’ll *not* want to execute “dd” as in:
# dd of=/dev/hda if=mbr.bin bs=512 count=1
I always recommend doing the partitioning in Linux BEFORE
you install Windows.
mjt – author, “Inside Linux”.
Works like a charm. i’m with opensuse and windows kept overwriting my MBR. thanks a lot
Hi.
I have installed Ubuntu 9.04 as windows application long back using wubi.
Now when i restart my PC its giving the menu to select either windows or ubuntu.But when i cliked on ubuntu its giving the following error “Cannot find GRLDR”. Please tell me how to get out of this issue.Atleast how to get the ubuntu data backup.
when i tried
sudo grub
find /boot/grub/stage1 its saying no file found.
Since Ubuntu is not installed in separate external partition i am unable to get the backup..
Hi all,
I earlier installed ubuntu 9.04. I am trying to install grub after XP.But i get following error
grub> find /boot/grub/stage1
(hd0,5)
grub> root (hd0,5)
grub> setup (hd0)
Checking if “/boot/grub/stage1″ exists… yes
Checking if “/boot/grub/stage2″ exists… yes
Checking if “/boot/grub/e2fs_stage1_5″ exists… yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0)”… 17 sectors are embedded.
succeeded
Running “install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,5)/boot/grub/stage2
/boot/grub/menu.lst”… failed
Error 12: Invalid device requested
I get this error.
I am using live cd of Ubuntu 9.04 same version dat i have installed
Please help
Thanks
When i insert the livecd and run sudo grub it says no grub installed.what should i do?
If you look @ the latest Ubuntu help, you will find that as of KK, GRUB has been changed considerably. These instructions only apply now to JJ or earlier!
when I used the command fdisk -l it said it cannot open /dev/sda, and when I tried find /boot/grub/stage1 it said No such file or directory. I’m using ubuntu 8.1 boot cd if it matters.
Thanks a bunch!
I’ve had to deal with GRUB errors several times, and this is a perfect explanation. Your simple fix kept me from panicking when my computer suddenly wouldn’t boot!
Another disaster avoided…
Help!
I have Ubuntu 9.05 in Toshiba netbook with 160GB HD. Repartition to 60GB and then install Windows 7 starter to second partition. I can’t mount sda1 that has Ubuntu, wrong FS, Gparted listed sda1 as ext4. Using find /boot/grub/stage1 and got an error 15: file not found. Since It can’t find where is stage1, I can’t reinstall grub.
Anyone knows where is it located or how to fix this problem? Thanks in advance.
Reinstall Ubuntu Grub Bootloader After Windows Wipes it Out
Hi i am using Ubuntu 9.10 which was installed on a partition of the main c drive and i formatted my windows partition which conatined the the grub loader for ubuntu 9.10 how can i fix this using a ubuntu 9.10 live cd? :
I have booted from the ubuntu 9.10 cd opened a terminal and typed and tried using sudo grub and the result was : ubuntu@ubuntu:~$ sudo grub
sudo: grub: command not found
I have encountered for the second time now that the Windows XP has gone missing from the boot menu.
The first time I formatted the Ubuntu partition and reinstalled Ubuntu 9.1 and windows was back in the boot menu. Is there a better way than reinstalling Ubuntu? Ubuntu is booting normal but I still need XP to run a few aps that will not run in Ubuntu. I need a simple way to restore Windows XP Pro to the boot menu.
Thanks
Thanks a lot! This has been of great help several times. However, the EXIT command doesn’t work for me, I have to use QUIT instead.
I really hate how windows wipes out my grub loader every now and then. Today, for example, I was cleaning (i.e., formatting) the virus-filled HD of an acquaintance of mine, and I had it plugged along with my main hard drive. I put in the windows install CD, and it didn’t even have to LOOK at my main drive, just format and install on the other one, yet IT STILL BUSTED MY GRUB! WTF, Gates, do you really hate Linux THAT much that you murder its loader on sight? XD
the trouble is that the default configuration of grub does not have the menu.lst anymore…
so if ubuntu was first, then came windows xp that installed its own boot loader to mbr,
then we are stuck. grub is not able to load windows after it gets back to mbr…
Thank you so much. Your advice just works. I wonder if my Ubuntu was not 8.04 but the later versions, it may not work however.
I had a strange experience with loaders on a dual boot machine (Fedora 13 / WinXP). Fedora is installed as primary OS (first two partitions on laptop hard drive) and WinXP as a secondary (third partition). I had some unallocated space at the end of the disk so I decided to create a partition with FAT32 file system to make file transfer between Fedora and XP easier. So, I did it from WinXP, since I was working with it at the moment. After I restarted the system – BOOM! Grub Error. Tried to reinstall grub, no success. After a day of work, I finally found the answer: WinXP disk manager changed the partition distribution in such a way that it inserted some unallocated space at the beginning of the disk (approximately 1MB of space ?!) and changed the MBR accordingly. However, grub recognized it but it treated it as a partition (hd0,0) and changed the root partition to (hd0,1). Since there was no system there (it was a second Linux partition, for OS), I received another GRUB error. After I manually changed it back to (hd0,0), Fedora booted as usual. On the other hand, WinXP could not boot up because in its boot.ini file the loader was directed to the wrong partition – it treated the unallocated space at the beginning of the disk as non-partition. After I increased the partition number in boot.ini, WinXP can boot normally.
Obviously, the problem arose after creating an unallocated space at the beginning of the disk drive. Could it be your problem too? Because it is, then there is something really bad with boot loaders – either WinXp or GRUB. Fixing manually partition numbers solved the problem, but the problem should’t have been there at all. I still can’t understand why reinstalled grub didn’t recognize correctly the partition table or how WinXP could change the disk space without distroying the data (or maybe it did, and caused all other problems).
Hello, thanks for the help who ever wrote the original article and Jonathan van Zuijlekom
together this is what worked for me
sudo grub
>find /boot/grub/stage1
> root (hd0,0)
> setup (hd0)
> exit
after i typed >find /boot/grub/stage1 I got (hd0,4) put that in to the root and it worked great. now the exit did not work but that’s minor terminal is not really my field… so thanks again
I more often have problems with linux overwriting my windows boot loader and completely borking my Windows install.
When will linux devs put on the big boy pants and lose the command line crap?
I’ve managed to fix this problem with the steps from bastr.
I have both Ubuntu 10.04 and Windows 7 on my laptop.
Here are the steps:
#1 – Boot off the Live CD
#2 – Open a terminal
#3 – Mount the partition where you’ve installed Ubuntu. You can check it with sudo fdisk -l
sudo mkdir /mnt/linux
sudo mount /dev/hdXY /mnt/linux
#4 – Run grub-install
sudo grub-install –root-directory=/mnt/linux /dev/hdX
Thats it!
Thanks
Hi y’all
Please HELP, Recently I downloaded a file a keygen generator and after that my internet browser started to cut out and shutting down so I decided to restart my PC, when it came back up it went into grub4dos 0.4.4 2009.09.09
Everything I do it shows Error 17 and so on, if I press the esc key a red screen appears with a Menu and there’s one saying Windows without Loader.
My OS is Windows 7 but original OS for the machine is XP.
Please how do I exit this grub4dos 0.4.4 without losing my data. Please HELP
Thanks in advance.