Recover lost / corrupted GRUB (MBR) entry
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..
Recover lost partition table using Ubuntu Live CD + gpart
My friend suddenly ask me for a Ubuntu Live CD and upon being asked he told me that he has not been able to boot his machine for getting the Operating System not found error. I’m posting here on how did I helped him out with the problem for documentation.
The program I used was gpart, and to use it in Ubuntu (Live CD) is to add Universe repository to /etc/apt/sources.list as this;
deb http://archive.ubuntu.com/ubuntu gutsy main restricted universe
and run this commands to install it.
ubuntu@ubuntu:~$ sudo apt-get update ubuntu@ubuntu:~$ sudo apt-get install gpart
By running the next command, gpart will search the whole disk for possible partitions and write it’s findings to the partition table:
ubuntu@ubuntu:~$ sudo gpart /dev/sda -W /dev/sda
That’s it. Just reboot and see if your system is now bootable…
p/s: Other than gpart, testdisk can also be used for partition recovery, but i’m not covering it here..
Connect with me
What I'm Doing (via twitter)...
- is applying for US visa. The website is not helping at all http://twitpic.com/16hvxp 1 week ago
- @abumuaaz want to focus on my wireless project (yes, I get paid for that) and some development work. Ada job to pass ka? :) in reply to abumuaaz 1 week ago
- is running 'sudo dd if=/dev/zero of=/dev/sda' on his laptop. Will it work, my computer forensic friends? 1 week ago
- is on his first day of being jobless, hahaha. 1 week ago
- finished reading Crowdsourcing: Why the Power of the Crowd Is Driving the Future of Business, in 32 hours. Next, Wikinomics. 1 week ago
- is on his way to island hopping. Woohoo! 1 week ago
- is leaving on a jetplane, don't know when he'll be back again... 2 weeks ago
- missed his flight to KK. Will need to take the first flight tomorrow and pray he'll make it for his 9am meeting. 2 weeks ago
- More updates...











