How to reinstall and recover grub for linux after a windows re-installation

Bump on this issue again, someone asked ” how to restore my grub after i did a re-installation of windows on my machine ?”
Linux has been there for quite some time, then come windows.. and as usual, windows tend to have it
re-format for various reason after some period of time…

Yes.. linux got “yum upgrade” thingy .. but that also seem to break sometime also ( big time!!) ..
but this time not discussing on linux part..
but the question is “how to restore grub again so that i can boot again to my linux partition which is still reside
somewhere inside the disk.. ”

( luckily windows still unable to read ext3 ) *up to time of writing.. xp & vista*
else .. it would have been another messed up like “Ubuntu 9.10” … hehehe

Oh.. this is how we gonna do it..

Get a CentOS 5.4 DVD ..
or boot.iso which is smaller and can be burned into CD or
just USB if your machine support USB boot..
(apparently D630 does support USB boot.)

while loading up.. press F12.. choose to boot from DVD or USB ..


linux rescue


[ad#postad] answer few question regarding language.. keyboard..

it will boot to rescue prompt..
whenever asked to enable networking or not .. select “No”.. (not needed for just this task)
it shall asked whether or not to mount existing linux partitition into “/mnt/sysimage”
press “yes”

.. then it shall shows a (single user) prompt.. like this

[ad#postad] sh
ok.. now get the current disk config with

fdisk -l

it shall spit something like this..

sh-3.2# fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1242     9976333+  83  Linux

so that you know the disk is at “/dev/sda”

.. now let’s change to our target rootfs.
by issuing this ..

chroot /mnt/sysimage

then.. re-install grub with the following command.

grub-install --recheck --no-floppy /dev/sda

because my machine got no floppy… hehe..

sh-3.2# grub-install --recheck --no-floppy /dev/sda
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map /boot/grub/
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(hd0)   /dev/sda

and.. that’s it.. “exit” and it shall rebooted and can see you grub again..

p/s : somehow not publishing the series of event log for today (only known to me and few others near me.. ) …
as someone had said this to me before i press publish button :
“Oh.. blog is reachable from other countries also..
so .. if you plan to write something like ‘Welcome to Malaysia‘…
then it must be kinda a wonderful thing .. hahahaha..”
( Google will somehow pick up that ..i believe.. ~ hehe )

Get Free Email Updates!

Signup now and receive an email once I publish new content.

I will never give away, trade or sell your email address. You can unsubscribe at any time.


Related Post

5 Responses

  1. ahstod says:

    yum install -y mythtv-suites –enablerepo atrpms –enablerepo atrpms-testing

    should be

    yum install -y mythtv-suite –enablerepo atrpms –enablerepo atrpms-testing

  2. ahstod says:

    also after yum installing all the mythtv packages:

    yum install perl-DBD-MySQL php-mysql mysql mysql-server
    chkconfig mysqld on
    service mysqld start
    mysql -u root mysql
    mysql> UPDATE user SET Password=PASSWORD(‘mythtv’) WHERE user=’root’;
    mysql> quit
    mysql -u root mysql -p < /usr/share/doc/mythtv-docs-0.21/database/mc.sql

  3. namran says:

    if happened to messed with the frontend..
    despite the update..

    can just..

    “yum install -y mythtv-frontend-0.21-213.el5 –enablerepo atrpms ”


    mythTV is back..!

  4. google says:

    Hey There. I found your blog using msn. This is a really well written article.
    I will be sure to bookmark it and return to read more of your
    useful info. Thanks for the post. I’ll definitely return.

  5. ???? says:

    Victorious one CSN Coyotes basketball group.. alot more energy.


Anything to add?