Fixing / Reinstalling grub / grub2
Reinstalling GRUB 2
yep, I am the one that always keeps messing with my hard drive installs, last night I formated my windows xp partition and installed windows 7 on the empty space that belonged to windows xp, of course when I restarted, the only system to boot was windows 7, that did not worried me because I know my way around linux and windows, so here is what I did to get my grub menu back including windows 7, to me it does not make any difference if I install windows first or linux, I can go both ways as long as I have a live distro at hand it will be ok, well here is what I did, color coded words is what it needs to be typed into a terminal.
There may be times when a user needs to either move or reinstall a GRUB 2 installation. GRUB 2 needs to be reinstalled when a user is presented with a blank screen with only the word “GRUB”, no prompt, and no ability to enter commands. This often happens when the MBR of the booting device is altered and GRUB 2 is removed, such as when Windows is installed after Ubuntu or any other linux ditro. Additionally, if a user can not boot into an operating system at all, even using the rescue mode mode, a complete reinstallation of GRUB 2 may be necessary.
Reinstalling from LiveCD
If you cannot boot from GRUB 2 review the section Boot Problems & Rescue Mode. If a reinstall becomes necessary follow these instructions. Two methods are presented; both require booting from a LiveCD, any live cd will work for this matter, but I will recommend Ubuntu 9.10, or later version. If the first method does not work, follow the second method, which is more complex and contains more options and instructions.
SIMPLEST – Copy GRUB 2 Files from the LiveCD
This is a quick and simple method of restoring a broken system’s GRUB 2 files. The terminal is used for entering commands and the user must know the device name/partition of the installed system (sda1, sdb5, etc). The problem partition is located and mounted from the LiveCD. The files are then copied from the LiveCD libraries to the proper locations and MBR. It requires the least steps and fewer command line entries than the following methods.
1. Boot to the LiveCD Desktop (Ubuntu 9.10 or later).
2. Open a terminal by selecting Applications, Accessories, Terminal from the menu bar.
3. Determine the partition with the Ubuntu installation. The fdisk option “-l” is a lowercase “L”.
1. sudo fdisk -l
If the user isn’t sure of the partition, look for one of the appropriate size or formatting.
Running sudo blkid may provide more information to help locate the proper partition, especially if the partitions are labeled. The device/drive is designated by sdX, with X being the device designation. sda is the first device, sdb is the second, etc. For most users the MBR will be installed to sda, the first drive on their system. The partition is designated by the Y. The first partition is 1, the second is 2. Note the devices and partitions are counted differently.
4. Mount the partition containing the Ubuntu installation.
sudo mount /dev/sdXY /mnt
Example: sudo mount /dev/sda1 /mnt ( where sda1 is the linux partition containing the grub files )
Note: If the user has a separate /boot partition, this must be mounted to /mnt/boot
5. Run the grub-install command as described below. This will reinstall the GRUB 2 files on the mounted partition to the proper location and to the MBR of the designated device.
sudo grub-install –root-directory=/mnt/ /dev/sdx
Example: sudo grub-install –root-directory=/mnt/ /dev/sda ( where sda is the partition where grub will be installed )
this will reinstall the grub to the mbr giving you a grub menu
after rebooting you will have your grub menu
Updating grub2 or grub
now once you boot to your linux operating system open a terminal and issue this command
sudo update-grub2 ( for grub2 )
sudo update-grub ( for grub legacy )
that will check for any new / other operating systems and then if found then it will be added to the grub menu
now after that you will see on the terminal your new discovered operating systems, now restart your pc and voila you will have every single operating system entry on the grub menu ready for you to make your choice.
well I hope this is clear enough for anyone that may be in need of fixing his grub.