Reinstallation of GRUB

How to reinstall GRUB?

Note: before continuing read this post if you are not familiar with GNU/Linux
http://debian.sreenadh.in/mount-partitions-in-a-gnulinux-system/

Put the first DVD of Debian in DVD drive.  After booting from DVD you will be asked to choose language, country, keyboard layout. you need to press 3 enter keys for that process.

Press Ctrl Alt F2 then
Press enter key

If you are reinstalling grub of latest Ubuntu versions the partition type may be ext4 so instead of using Debian DVD use Ubuntu live CD otherwise mounting will fail.

mkdir temp_dir
mount /dev/hda6 temp_dir

(where hda6 is your GNU/Linux partition. if you don’t know where you have installed GNU/Linux mount partitions one by one and run the following command to see the contents of that partition.

ls temp_dir
Eg:

mount /dev/hda5 temp_dir
ls temp_dir

if you can see bin boot usr opt directories then it is your GNU/Linux partition. else

umount temp_dir and try other partitions
)
then run the following commands in order.

mount -o bind /dev temp_dir/dev
mount -o bind /proc temp_dir/proc

chroot temp_dir

grub-install –root-directory=/ –no-floppy –recheck /dev/hda

where hda is your hard disk where you have installed GNU/Linux

exit

umount temp_dir/dev
umount temp_dir/proc

umount temp_dir

reboot

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • FriendFeed
  • FSDaily
  • Identi.ca
  • LinkedIn
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks

Related posts:

  1. Grub 2 in Debian Etch
Nov 8th, 2009 | Posted in Troubleshooting
  1. mubarak
    Mar 10th, 2010 at 14:22 | #1

    thank you for your great reply.

  2. Codename62
    May 24th, 2010 at 00:59 | #2

    I was using my laptop by dual booting Ubuntu 10.04 and Windows XP. One day i had to format my Window partition and i was not able to boot into Ubuntu since the GRUB was overwritten by the windows bootloader. So i decided to use this method as said by Sreenadh.

    But while mounting my Ubuntu drive, it shows like this

    mount /dev/sda5 temp_dir
    mount: mounting /dev/sda5 on temp_dir failed: Invalid argument

    Any idea about what to do now?

  3. Codename62
    May 25th, 2010 at 11:31 | #3

    The problem is fixed. Ubuntu 10.04 partition is ext4. Debian Lenny
    installer does not support ext4. Used Ubuntu Live CD.

  4. Codename62
    Sep 30th, 2010 at 21:20 | #4
    • Sreenadh
      Sep 30th, 2010 at 21:27 | #5

      Since this how to make use of chroot any livecd can be used to reinstall grub regardless of the grub version in the livecd

  5. Jan 22nd, 2011 at 22:09 | #6

    I have successfully reinstalled grub in Ubuntu following this post.Thanks a lot.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>