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 )

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.

Like

Related Post

8 Responses

  1. Lonnie says:

    HawkEye,
    I have followed your directions, but I get an error at the end start of the build: “ValueError: Could not find an installable distribution at ‘/data/iso/WinXP_SP2_EN.iso'”
    I have tried various ways to create a WinXP iso, your directions were the last I used. All other attempts also failed…Not sure what to try next. When I check the file, it seems to be OK…

    file /data/iso/WinXP_SP2_EN.iso
    /data/iso/WinXP_SP2_EN.iso: ISO 9660 CD-ROM filesystem data ‘VRMPOEM_EN ‘ (bootable)

    Any Ideas?

    Reply
    • HawkEYE says:

      Perhaps would verify the WinXP CD is actually not corrupted.. and if the CD-Drive is working fine..

      then .. check if the iso files actually accessible by the xen lib..

      else should check the xen lib is properly installed and also verify the current running kernel is xen enabled..

      then might be a reinstall the virtualization group would be the next thing to try ..

      btw: what host are u using ? .. my experience was based on CentOS 5.2 host.. so far it went smooth as above..

      Reply
  2. Lonnie says:

    I have built the iso several times, once from Windows CD burner app and twice with “dd” command like you showed…no reported issues…only assuming it is OK.

    How would I verify it is accessible by “xen lib”?
    How would I check to see if xen lib is properly installed?

    I am installing on IBM x345 dual Xeon 2.4GHz cpu with 4GB ram (single cores). I did the install of “Virtualization” group per some earlier notes I saw on the subject…I cannot do the “Fully Virtualized” install because the hardware I have doesn’t support it…so I did the Paravirtualized option.

    Any suggestions I could try tonight would be greatly appreciated.

    Reply
    • HawkEYE says:

      check the xen kernel by running this at terminal

      uname -a

      shall be ended with -xen at the end..

      mine is something like this..

      [[email protected] ~]# uname -a
      Linux fedora.namran.net 2.6.18-92.1.22.el5xen #1 SMP Tue Dec 16 13:08:49 EST 2008 i686 i686 i386 GNU/Linux

      and the file


      [[email protected] ~]# ll /data/iso/XP3_3282_V2_EN.iso
      -rwxr-xr-x 1 root root 670576640 Feb 21 00:07 /data/iso/XP3_3282_V2_EN.iso

      mine also a para-virtualization as unable to become utilize full-virtualization

      [[email protected] ~]# cat /proc/cpuinfo
      processor : 0
      vendor_id : GenuineIntel
      cpu family : 15
      model : 2
      model name : Intel(R) Pentium(R) 4 CPU 3.00GHz
      stepping : 9
      cpu MHz : 2992.718
      cache size : 512 KB
      fdiv_bug : no
      hlt_bug : no
      f00f_bug : no
      coma_bug : no
      fpu : yes
      fpu_exception : yes
      cpuid level : 2
      wp : yes
      flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe up cid xtpr
      bogomips : 7487.18

      if all fail, shall consider to seek help from bugs.centos.org or forum http://www.centos.org/modules/newbb/viewforum.php?forum=37

      Reply
  3. Lonnie says:

    # uname -ra
    Linux homer 2.6.18-92.1.22.el5xen #1 SMP Tue Dec 16 13:08:49 EST 2008 i686 i686 i386 GNU/Linux

    # ls -l /data/iso/WinXP_SP2_EN.iso
    -rw-r–r– 1 root root 607559680 Mar 22 11:30 /data/iso/WinXP_SP2_EN.iso

    # cat /proc/cpuinfo
    processor : 0
    vendor_id : GenuineIntel
    cpu family : 15
    model : 2
    model name : Intel(R) XEON(TM) CPU 2.40GHz
    stepping : 4
    cpu MHz : 2672.992
    cache size : 512 KB
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 2
    wp : yes
    flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
    bogomips : 6689.88

    processor : 1
    vendor_id : GenuineIntel
    cpu family : 15
    model : 2
    model name : Intel(R) XEON(TM) CPU 2.40GHz
    stepping : 4
    cpu MHz : 2672.992
    cache size : 512 KB
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 2
    wp : yes
    flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm up
    bogomips : 6689.88

    processor : 2
    vendor_id : GenuineIntel
    cpu family : 15
    model : 2
    model name : Intel(R) XEON(TM) CPU 2.40GHz
    stepping : 4
    cpu MHz : 2672.992
    cache size : 512 KB
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 2
    wp : yes
    flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm up
    bogomips : 6689.88

    processor : 3
    vendor_id : GenuineIntel
    cpu family : 15
    model : 2
    model name : Intel(R) XEON(TM) CPU 2.40GHz
    stepping : 4
    cpu MHz : 2672.992
    cache size : 512 KB
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 2
    wp : yes
    flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm up
    bogomips : 6689.88

    Reply
  4. automated forex robots says:

    How do you look for information for your blog content?

    Reply
  5. V Tweet US says:

    Thanks HawkEYE for guiding me how to install windows XP on XEN virtualization in CentOS 5. The way you have enplane it make pretty easy to do it.

    Reply
  6. http://www.lcplunderground.com says:

    Actually no matter if someone doesn’t understand after that its up to other visitors that they will help, so here it happens.

    Reply

Anything to add?

X