X

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

type

linux rescue

enter..


answer few question regarding language.. keyboard..


and..
it will boot to rescue prompt..
whenever asked to enable networking or not .. select “No”.. (not needed for just this task)

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

sh-3.2#



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/device.map.
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 )

Namran Hussin: a soft spoken guy... with exceptional interest in computers and technology. I love to learn new thing and also love to break thing for the sake of learning.. but I do abide to the self-imposed limitation or certain thing such as social thing in life, thing can be done and thing that must be avoided at whatever cost such as drug,illegal tracking, smoke,illicit activity..etc.muahahaha let's share what we had in this short term of the life.! make it worth of the living.~
Related Post
Leave a Comment