tux-debianwww.palmix.orgtux-debian


  HOME  TUTORIALS  ARTICLES  DOWNLOADS  LINKS ITALIANO

 
HOW TO RESTORE THE BOOT-LOADER GRUB IN THE MBR
by Francesco Palmisano

grub

Unfortunatly could happen that something delate your hard drive's MBR (Master Boot Record).
Tipically when you install Windows AFETR a Linux installation.
Don't worry, there is a way to restor it.

We will use this disk structure as example:

hda1 -> windows ntfs (tipically the windows C:\)
hda2 -> windows fat32 (windows 98 partition D:\)
hda3 -> linux ext3 (/ the linux root)
hda4 -> linx swap

as i said this is an example, so you could have a different situation, for example your PC could use SATA disk or SCSI disk and the devices names change:

sda instead of hda

What we need:

A Linux distro Live! like Debian, Ubuntu/Kubuntu, Knoppix, etc...

IMPORTANT:  If you use a 64 bit distro, you need a 64 bit Live! distro

1) boot your computer with CD-live and use a root terminal
2) create a new folder to mount the partiton:

mkdir /media/disck

3)mount the linux partition on the hard drive:

mount /dev/hda3  /media/disck  (i use the above example device, use yours!!)

4)mount /dev for chroot use:

mount -o bind /dev  /media/disco/dev

5)login in chroot:

chroot /media/disco

6)restore GRUB (the boot-loader):

cd /boot/grub
grub
root (hd0,2)
setup (hd0)
exit

IMPORTANT:  The value (hd0,2) is usually right, but it's dipend from your partition's table; it could be (hd0,1) o something else.
                            Verify your partition's tabelle before proceeding.

To check your partition's table give this command:

fdisk -l /dev/hda  (fdisk -l /dev/sda , se avete dischi Serial ATA o SCSI)

Enjoy!


back on topback to tutorials