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

2 Responses

  1. HawkEYE says:

    the step to remove old plesk before can start install a new
    but it is preferable to have a complete system restore..
    *** somehow . to wait for sys-admin to do thing to you.. ah.. a lil’ bit fu*ked thing.. why not ***..

    as root..
    1. yum remove psa-*
    2. yum remove httpd
    3. rm -rf /var/httpd -R
    4. rm -rf /usr/local/psa -R
    5. rm -rf /var/www/vhosts -R
    6. service mysqld stop
    7. If don’t know the root pass for myql .try this as root :
    mysqld_safe –skip-grant-table

    6. mysql -uroot
    i. drop database psa
    ii. drop database phpmyadmin_14813SHFF < -- some serial here can see using show databases; iii. drop database horde; iv. drop database sitebuilder; v. and any other thing .. except test and mysql; vi. may have to reset pass for root to blank ... if u want to delete other user than root in mysql use mysql; delete * from user where User!='root'; update user set Password=PASSWORD('') where User='root'; may be need to add the admin user with pass setup. and with all priv here. insert into user (Host,User,Password) values ('localhost',admin,PASSWORD('something-default-here')); then have to grant.. all the privilege. to the admin then remove mysqld. yum remove mysql. ***.. after that may proceed with re-installation process. note i did'nt remove any other user created before.. such as qmail.. bla..bla.. because we are going to re-install .. then.. ./psa_installer_v3.1.2_build070321.17_os_CentOS_4_i386 answer all question.. wait.. till finished.. hopefully no problem.. may be need to flush the firewall services iptables restart.. then can access to https://server.name.com:8443/

    you should see the login screen..
    wahaha..

    Reply
  2. HawkEYE says:

    the step to remove old plesk before can start install a new
    but it is preferable to have a complete system restore..
    *** somehow . to wait for sys-admin to do thing to you.. ah.. a lil’ bit fu*ked thing.. why not ***..

    as root..
    1. yum remove psa-*
    2. yum remove httpd
    3. rm -rf /var/httpd -R
    4. rm -rf /usr/local/psa -R
    5. rm -rf /var/www/vhosts -R
    6. service mysqld stop
    7. If don’t know the root pass for myql .try this as root :
    mysqld_safe –skip-grant-table

    6. mysql -uroot
    i. drop database psa
    ii. drop database phpmyadmin_14813SHFF < -- some serial here can see using show databases; iii. drop database horde; iv. drop database sitebuilder; v. and any other thing .. except test and mysql; vi. may have to reset pass for root to blank ... if u want to delete other user than root in mysql use mysql; delete * from user where User!='root'; update user set Password=PASSWORD('') where User='root'; may be need to add the admin user with pass setup. and with all priv here. insert into user (Host,User,Password) values ('localhost',admin,PASSWORD('something-default-here')); then have to grant.. all the privilege. to the admin then remove mysqld. yum remove mysql. ***.. after that may proceed with re-installation process. note i did'nt remove any other user created before.. such as qmail.. bla..bla.. because we are going to re-install .. then.. ./psa_installer_v3.1.2_build070321.17_os_CentOS_4_i386 answer all question.. wait.. till finished.. hopefully no problem.. may be need to flush the firewall services iptables restart.. then can access to https://server.name.com:8443/

    you should see the login screen..
    wahaha..

    Reply

Anything to add?

X