[hllug] How to restore GRUB

  • From: Lee Parmeter <geek@xxxxxxxxxxxxxx>
  • To: hllug@xxxxxxxxxxxxx
  • Date: Thu, 14 Jan 2010 11:55:31 -0600

A need to restore GRUB will most likely cross your path on your travels
with the penguin and this weeks "Questions and Answers" section in
Distrowatch Weekly could keep your feathers from going perpendicular!

source: <http://distrowatch.com/weekly.php?issue=20100111#qa>


Restoring GRUB

Can't-boot-any-more asks: Distro hopping wiped out my GRUB. How can I
reconstruct it?

DistroWatch answers: Sometimes when making changes to a hard drive, such as
installing a new operating system, the disk's master boot record (MBR) will
get wiped or corrupted. When that happens, GRUB will no longer function.
This has the unfortunate side effect of preventing the user from being able
to boot their operating system and, in those cases, it's important to be
able to get the system up and running again, preferably without
re-installing the operating system(s) from scratch.

The easiest way to get GRUB back on-line is with a live CD. It doesn't
really matter which live CD, so long as it comes with a copy of GRUB. Place
the live CD into the computer and boot from it. We're then going to venture
into command-line territory. The next thing to do is run the "grub" command
as root or, if you are running a live CD that uses sudo, run "sudo grub".
This will start GRUB and provide us with a prompt.

     grub>

We'll then find out where the GRUB files are located:

     grub> find /boot/grub/stage1

The find command will return a disk location for us. Probably "(hd0,0)" or
"(hd0,1)". We now know where the GRUB files are stored. Next, we'll tell
GRUB to use this location in the future. In the following step, type
"root", followed by the location we were given above. In my case:

     grub> root (hd0,1)

GRUB now knows where its files are located and we need to re-setup GRUB in
the master boot record. To do this, we type:

     grub> setup (hd0)

The above step should work for most people, who have GRUB installed in the
MBR. For folks who have installed GRUB onto a partition, the "setup"
command can be modified to include the partition number. The catch is, you
need to know where you originally installed GRUB. In these cases, remember
that GRUB starts counting partitions from zero, not one. So, for example,
if GRUB was installed on the third partition of the first hard drive, the
"setup" command will look like this:

     grub> setup (hd0,2)

When we get back to the prompt again, we can quit GRUB:

     grub> quit

And then reboot the computer. Remove the live CD from the drive and we
should be back to normal.


-- 
Lee Parmeter
http://www.bubbasgeek.com

"When it comes to Vista: just say NO! If you're not ready for Linux, buy a
MAC!" - Lee Parmeter
"God is not a republican or a democrat nor is His government a democracy!"
- Lee Parmeter
______________________________________________________________________________
Highland Lakes Linux User Group (HLLUG): http://www.hllug.org
HLLUG mailing list: //www.freelists.org/list/hllug

Other related posts:

  • » [hllug] How to restore GRUB - Lee Parmeter