![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Mar 2006
Location: Boston, MA
Beans: 1,862
Ubuntu 6.10 Edgy
|
How to restore Grub from a live Ubuntu cd.
This will restore grub if you already had grub installed but lost it to a windows install or some other occurence that erased/changed your MBR so that grub no longer appears at start up or it returns an error.
(This how to is written for Ubuntu but should work on other systems. The only thing to take note of, when you see "sudo" that will mean to you that the following command should be entered at a root terminal.) Boot into the live Ubuntu cd. This can be the live installer cd or the older live session Ubuntu cds. When you get to the desktop open a terminal and enter. (I am going to give you the commands and then I will explain them later) Code:
sudo grub Code:
find /boot/grub/stage1 Next, THIS IS IMPORTANT, whatever was returned for the find command use it in the next line (you are still at grub>. when you enter the next 3 commands) Code:
root (hd?,?) Next enter the command to install grub to the mbr Code:
setup (hd0) Code:
quit When you reboot, you will have the grub menu at startup. Now the explanation. Sudo grub gets you the grub shell. Find /boot/grub/stage1 has grub locate the file stage1. What this does is tell us where grub's files are. Only a small part of grub is located on the mbr, the rest of grub is in your boot folder. Grub needs those files to run the setup. So you find the files and then you tell grub where to locate the files it will need for setup. So root (hd?,?) tells grub it's files are on that partition. Finally setup (hd0) tells grub to setup on hd0. When you give grub the parameter hd0 with no following value for a partition, grub will use the mbr. hd0 is the grub label for the first drive's mbr. Quit will exit you from the grub shell. THIS IS AN EDIT. 5-HT MADE A GOOD POINT AND I AM JUST GOING TO COPY/PASTE IT HERE Quote:
ALL KNOWLEDGE IS WELCOME! Quote:
**This set of instruction is a combination of 2 guides I saw before. One was a Mepis grub how to but I never found it again. The other is the grub manual. It's section explained the find, root, setup process but never mentioned it could be done from a live session. This is the grub link http://www.gnu.org/software/grub/man...-GRUB-natively Post script; Just to post as much information as possible, this is an older how to for resoring grub to the mbr. The original post is directions for using the install cd and then there are replies that mention the method I posted here, as well as the chroot method mlind mentioned. If this method fails, you may want to try this http://ubuntuforums.org/showthread.php?t=24113
__________________
EDGY GUIDE >Edgy Live CD install > Dapper alternate install cd >Ext2 driver>Aysiu's great ubuntu tutorials>XP to ubuntu transition guide Last edited by catlett; September 20th, 2006 at 08:46 PM.. |
||
|
|
|
|
|
#2 |
|
Skinny Extra Sweet Ubuntu
![]() Join Date: Nov 2005
Beans: 2,325
Ubuntu Intrepid Ibex (testing)
|
Re: How to install Grub from a live Ubuntu cd.
This looks very useful info. Is the result same as running grub-install /dev/xxx ?
__________________
Building on Ubuntu using [pbuilder] Other resources [Upgrading from CVS, Gaim2, Anjuta, Rhythmbox] |
|
|
|
|
|
#3 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Mar 2006
Location: Boston, MA
Beans: 1,862
Ubuntu 6.10 Edgy
|
Re: How to install Grub from a live Ubuntu cd.
The end result is the same but grub-install /dev/hd? doesn't work with a live cd. When I run grub-install from a live cd, I get an error about grub not being able to read the bios.
When I first installed ubuntu there was a grub re-install guide. It said something about mounting the ubuntu partition. Then cd to the directory and chroot. At the time it was over my head and I didn't pay much attention to it. Now I can't find it. The other guide was the Breezy guide where you trick the install cd into re-installing grub.I gues it worked for people but I thought there had to be a simpler way to do it. I finally found the grub manual entry on native installs and tried it from a live cd and it worked. Hopefully reinstalling grub will now be a simple thing to do from a live cd. |
|
|
|
|
|
#4 |
|
Skinny Extra Sweet Ubuntu
![]() Join Date: Nov 2005
Beans: 2,325
Ubuntu Intrepid Ibex (testing)
|
Re: How to install Grub from a live Ubuntu cd.
You probably mean something like this as root
Code:
mkdir /mnt/root mount /dev/xxx? /mnt/root chroot /mnt/root /bin/bash grub-install /dev/xxx
__________________
Building on Ubuntu using [pbuilder] Other resources [Upgrading from CVS, Gaim2, Anjuta, Rhythmbox] |
|
|
|
|
|
#5 | |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Mar 2006
Location: Boston, MA
Beans: 1,862
Ubuntu 6.10 Edgy
|
Re: How to install Grub from a live Ubuntu cd.
Quote:
Just for FYI, this is the error I get with grub-install from the live session. Code:
ubuntu@ubuntu:~$ sudo grub-install /dev/hda Probing devices to guess BIOS drives. This may take a long time. Could not find device for /boot: Not found or not a block device. Code:
grub> find /boot/grub/stage1 (hd0,1) (hd0,10) grub> root (hd0,10) Filesystem type is ext2fs, partition type 0x83 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)"... failed (this is not fatal) Running "embed /boot/grub/e2fs_stage1_5 (hd0,10)"... failed (this is not fatal ) Running "install /boot/grub/stage1 d (hd0) /boot/grub/stage2 p /boot/grub/menu .lst "... succeeded Done. |
|
|
|
|
|
|
#6 |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Mar 2006
Location: Boston, MA
Beans: 1,862
Ubuntu 6.10 Edgy
|
Re: How to install Grub from a live Ubuntu cd.
Just wanted to post with more concrete proof. I knew it was right from the documentation and I got feedback from one success story plus I ran it but it was just replacing the same list so it was hard to tell.
BUT NOW, I have absolute proof. I just installed Fedora Core 5 yesterday. I allowed Fedora to install grub. Fedora's grub didn't recognise Ubuntu's installation. I thought to myself, Perfect! Lets put the guide to work. This is just the scenario I was hoping to help people with. You had grub but lost it to another install (or another issue that caused grub to return an error or what not. The main thing is that grub is already installed somewhere. The issue is you can't access it) This is actually how anyone could handle this. I copied down Fedora's grub entry , then I rebooted and put the Ubuntu Live installation cd. When I got to the desktop I opened the terminal and did the 4 commands. One from the regular ubuntu terminal and 3 at the grub shell. Code:
sudo grub Code:
find /boot/grub/stage1 Now that I know Ubuntu's grub is on hd0,6 I let the grub shell know what grub files I wanted to use Still at grub> Code:
root (hd0,6) Code:
setup (hd0) grub> Code:
quit Gone was Fedora's grub and in it's place was my Ubuntu grub menu. Success. (As for accessing Fedora, I just inserted the Fedora entries I copied from Fedora's grub before I booted the live cd. Now I have Ubuntu's grub back and it is booting to fedora.) To sum up, hd0,6's grub installed flawlessly on the mbr. It took all of 2 minutes from putting the cd in to restarting. Here it is again just to put it to bed. Code:
sudo grub Code:
find /boot/grub/stage1 Code:
root (hd?,?) Code:
setup (hd0) Code:
quit
__________________
EDGY GUIDE >Edgy Live CD install > Dapper alternate install cd >Ext2 driver>Aysiu's great ubuntu tutorials>XP to ubuntu transition guide Last edited by catlett; August 2nd, 2006 at 08:29 PM.. |
|
|
|
|
|
#7 |
|
Dark Roasted Ubuntu
![]() Join Date: Aug 2005
Location: Canada
Beans: 1,082
|
Re: How to install Grub from a live Ubuntu cd.
Thanks for the HowTo!
Just have recommendation to add that may be irrelevant: it might be of benefit to give an explicit warning (though it is mentioned) that this guide will write GRUB to the MBR (just in case someone is using a different boot loader on their MBR and would like to reinstall GRUB to a partition). If someone wants GRUB on a partition, the 'setup (hd0)' step can be modified to 'setup (hdX,Y)'. Where X is the hard disk, and Y the partition using GRUB's nomenclature of starting from 0 (first partition=0, second=1,...). |
|
|
|
|
|
#8 | |
|
Chocolate Ubuntu Mocha Blend
![]() Join Date: Mar 2006
Location: Boston, MA
Beans: 1,862
Ubuntu 6.10 Edgy
|
Re: How to install Grub from a live Ubuntu cd.
Quote:
|
|
|
|
|
|
|
#9 |
|
Quad Shot of Ubuntu
![]() |
Re: How to install Grub from a live Ubuntu cd.
find /boot/grub/stag1
this command is resulting can not find the file what i do for this???????? |
|
|
|
|
|
#10 |
|
Quad Shot of Ubuntu
![]() |
Re: How to install Grub from a live Ubuntu cd.
file is there. i saw it after mounting the partition having linux installed on it.
i tried to give /B/boot/grub/stag1 command while /B is the mount folder but it did the same error. i am sick of this reinstallation process. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|