/home/shakir

Recover lost / corrupted GRUB (MBR) entry

Posted on 04 Jan, 2008, categorized under Information Insemination



Often time the Master Boot Record (MBR) is also lost / corrupted when the we’re having problem with the partition table, and so here I extend my previous post on recovering lost partition table using the Ubuntu Live CD.

First of all, let’s mount the related stuff;

ubuntu@ubuntu:~$ sudo mount -o ro /dev/sda1 /media/
ubuntu@ubuntu:~$ sudo mount -o bind /dev/ /media/dev/
ubuntu@ubuntu:~$ sudo mount -o bind /proc/ /media/proc/

and then chroot

ubuntu@ubuntu:~$ sudo chroot /media/

Once we are in the chroot environment, run grub

bash:~# grub

Assuming you are installing grub on your first harddisk, and your root filesystem in the first partition of your first harddisk, your journey should be something like this;

    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]

grub> root (hd0,0)
 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)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2
/boot/grub/grub.conf"... succeeded
Done.

grub> quit

Once you’re done with that, you might want to unmount whatever you have mounted before. Don’t forget to exit from the mount directory first;

ubuntu@ubuntu:~$ cd ..
ubuntu@ubuntu:~$ sudo umount /media/proc/
ubuntu@ubuntu:~$ sudo umount /media/dev/
ubuntu@ubuntu:~$ sudo umount /media

and then reboot to see if your problem is really fixed..





Looking for something else? Search Google.

4 Responses to "Recover lost / corrupted GRUB (MBR) entry"

1 | luke

January 28th, 2008 at 8:43 am

Avatar

Your post just saved my a$$. Thanks!

2 | Kevin

September 11th, 2008 at 10:08 am

Avatar

Thanks! Fixed the mess WinXP made with my system.

3 | Chris

October 26th, 2008 at 12:01 am

Avatar

Thanks man, this really helped, one thing is you don’t specifically say to exit out of the chroot before you do the umount but i got it anyway

4 | shakir

November 3rd, 2008 at 2:52 pm

Avatar

Chris:
Thanks, I’ve updated the post.

Comment Form


  • si perda: wah.. boleh kasi need for speed test power skali... boleh layan network race ni...
  • Faiz: wah....harganya berapa?
  • shakir: Hmm, I have no lab and that actually was my living room :D Sure I'll move them to one of my available rooms at home and make it a lab, but that'll be
  • peja: whoaaa..at least u have ur own lab...look interesting!
  • Qing Ru: He looks really cute! Fatherhood must have been quite rewarding :)
  • shakir: Chris: Thanks, I've updated the post.
  • shakir: tak cukup banyak guinea pig yang dah try and comment on the wimax service, and so I'll just wait :D
  • shakir: Vadim: Yup, but I prefer to just install dosbox and play the game rather than re-installing my system with 32 bit Linux :D
  • Vadim: 2shakir: wine doesn't support 64-bit linux. You have to use 32-bit linux if you want to use wine.
  • kevler: yerp ...dalam 2 hari nih jer ..aku dah kesan 2 BMW X6 , kat puchong dan jalan ampang ..giler laa lawa



Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. Inappropriate comments will be deleted at the authors discretion. All code samples (if any, ever) are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Personal (Blogs) - TOP.ORG