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..
linux-rescue-centos5

type

linux rescue

enter..

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

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

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

sh-3.2#
[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/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 )

Related Post

24 Responses

  1. ahstod says:

    … how long did you manage to get away without installing this one? 😎

    Reply
  2. namran says:

    approximately within 48hours.. hahaha.. (very slow-pace mode) as the file exist since..

    Mon Mar 9 15:28:31 2009 UTC (32 hours, 49 minutes ago) by ..

    quite weird when most of the item are just disappeared..
    .. at first thought some config problem.. removing the whole project directory and re-checkout.. still the same..
    then only figured one by one.. lol..

    Reply
  3. Andre says:

    Worked for me. Many thanks!

    Reply
    • HawkEYE says:

      @Andre : you’re welcome.. hopefully it help those in need.

      Reply
  4. Spyder461 says:

    I’m still having this problem. If done the yum install php-xml, but I still get the error about missing DomDocument class. I have read some posts that talk about executing a enable lib-xml extension command, but when I do this command, I get a error that lib-xml and extension is not a builtin command. Any suggestions would be appreciated.

    Reply
  5. danyal says:

    really very helpful it works

    Reply
  6. sachin says:

    Good, It worked

    Reply
  7. nszumowski says:

    Awesome! Everywhere else I was looking referenced libxml2 which I had already installed. This fixed my issue!

    Reply
  8. nico says:

    Awesome! thanks so much.

    Reply
  9. battisti says:

    Thx, after a lot of hours spend in the source the problem was in the server! 🙁

    Reply
  10. dungkal says:

    Updating the php-xml (note: it had already been installed long before the problem cropped up) on my CentOS server did the trick.

    Thanks for the help.

    Reply
  11. wika says:

    Thanks, it worked !!

    Reply
  12. rc says:

    Just a note, if you’re on centos and you had to do a custom install of php 5.3, yum install php53-xml will do the trick

    Reply
  13. elliot says:

    @rc – thank you!

    Reply
  14. Andrea says:

    Woooow, thank you!
    U save my ass…

    Reply
  15. littleguy says:

    This worked great, thanks!

    Reply
  16. mark says:

    Thank you , was baffled with this error, your post saved the day

    Reply
  17. Smoker says:

    It worked for me like a charm. Thank you verry much.

    Reply
  18. Thanga says:

    ANSWER IS HANDY :)THANKS A LOT

    Reply
  19. axlotl says:

    Thank you, sir.

    Reply
  20. dduane says:

    I also had to add the line:
    extension=dom.so
    to my php.ini file and restart apache. I’m using Fedora 16.

    Reply
  21. vb says:

    Thanks. saved a lot of time. Had that issue with owncloud

    Reply
  22. khyox says:

    Thank you very much indeed! It solved my issue viewing the internal wiki syntax page with dokuwiki running over lighttpd in Scientific Linux.

    Reply
  23. Andre says:

    Muito obrigado valeu muito o bizu de instalar esta yum install php-xml, excelente ajuda, estava precisando muito

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *