Posts Tagged ‘recovery’

Recover lost / corrupted GRUB (MBR) entry

Written on January 4th, 2008 by shakir
Categories: 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..

Recover lost partition table using Ubuntu Live CD + gpart

Written on January 3rd, 2008 by shakir
Categories: Information Insemination

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..

p/s: I am now maintaining this entry in my wiki site