Tech Support Forum banner
Status
Not open for further replies.
1 - 2 of 2 Posts

· Premium Member
Joined
·
2,755 Posts
Discussion Starter · #1 · (Edited)
This guide will cover both Grub Legacy and Grub 2
If I refer to grub (then this means both grub legacy and grub2) otherwise I will implicity refer to either grub2 or grub-legacy.

Linux Bootloaders
When you install your linux distribution you will be asked if you want to install a
bootloader. The usual choices are grub (also called grub legacy) or grub2.
Grub stands for GRand Unified Bootloader and once installed will allow your new distro to boot and any other operating systems, Windows, FreeBSD, etc

Grub will usually be paced in the master boot record (MBR) of the first hard drive to be booted. The boot order is set by your motherboard BIOS, so if you have more than one hard drive, you have to know which drive is the boot drive.
The MBR is the first 512 bytes and starts at sector 63 of your hard disk on systems using Intel Partition tables. The MBR contains 446 bytes which contain the bootstrap followed by 64 bytes for a partition table. The last two bytes are a boot signiture which must be set to AA55. It is the first 446 bytes that contain either the windows or linux bootloader.



Which version of Grub Do I have ?
When you installed your distribution it will tell you the version, either 0.97 for grub legacy or 1.8 or higher for grub2. If unsure, which version you are running open a terminal and type grub --version. Example below shows typical output:

grub --version
grub (GNU GRUB 0.97)

If you still dont know browse to DistroWatch.com: Put the fun back into computing. Use Linux, BSD. click on your distribution on the left hand side and scroll down to grub in the packages selection. Beware that many distributions are now using grub2 as it supports larger disks and GUID partition tables.


Install and Reinstall Grub legacy
To install grub legacy use the package manager that comes with your distribution

To Re-install Grub Legacy
Sometimes you may encounter a problem or want to revert back to grub legacy. To
re-install first boot from a live linux CD. Most distribution CD's will run in live mode.
In live mode the system will boot without touching your hard drive. Re-installing grub
legacy will make the necessary changes to your hard drive.
First boot from your live CD then start the terminal. You need root access.

At the terminal type grub this will give you a grub prompt and shell that looks like

Code:
grub>
After the grub> type, find /boot/grub/stage1

Code:
grub> find /boot/grub/stage1
The output will show one or more places where a grub legacy installation
has been installed. A sample output is below:

(hd0,9)
(hd1,0)

Grub Legacy Naming Conventions. Grub legacy starts counting both drives and partitions at 0 (zero). Therefore (hd0,0) is the first partition on the first hard drive,
(hd1,0) is the first partition on the second hard drive, and (hd0,9) is the tenth partition
on the first hard drive, etc.

In my example my root partition is (hd0,9) so I use the root command to tell grub where root is:

Code:
grub> root (hd0,9)/CODE]

After entering this command you will get a confirmation message similar to below.
The partition type will vary according to which filesystem you installed, ext3, reiser, etc.
[B]Filesystem is type ext2fs, partition type 0x83[/B]

You MUST use the correct partition from the find command. Now you install grub legacy to the MBR:


[CODE]grub> setup (hd0)/CODE]

If all went well type [B]quit [/B] to exit the grub legacy shell and reboot.



Install and Reinstall Grub2
To install grub2 use the package manager that comes with your distribution 

[U]To Reinstall Grub2[/U]
Sometimes you may encounter a problem or want to revert back to grub2. To
re-install first boot from a live linux CD. Most distribution CD's will run in live mode.
In live mode the system will boot without touching your hard drive. Re-installing grub2
will make the necessary changes to your hard drive.

Boot with your installation CD in live mode. You need to mount the root partition where grub2 is installed. With most live CD's there are icons for each partition,
click on the appropriate partition to mount the filesystem.

To update grub2 open a terminal and as root type:

[CODE]update-grub
This will update the grub2 scripts and rewrite /boot/grub/menu.cfg
To re-install grub 2 type:

Code:
grub-setup /dev/sda
You must replace /dev/sda with the appropriate disk drive where you installed your original distribution.


Grub 2 Naming Conventions. Grub2 starts counting the hard drive from 0 but partitions from 1. This is a change to previous version. In grub2 (hd0,1) is the first partition on the first hard drive, (hd1,1) is the first partition on the second hard drive, and (hd0,10) is the tenth partition on the first hard drive, etc.


Remove Grub Legacy or Grub2
If you want to remove grub and return to a windows bootloader, there are several
methods available. Try method A if you can boot into windows. Try method B if windows XP or Windows 7 wont boot and you have installation CD. Try method C if windows wont boot and you dont have install disks.

Method A ( If you can boot windows )
1 - boot into windows
2 - download and install EasyBCD NeoSmart Technologies (it is free for non-commercial use)
3 - run EasyBCD and go to the section <BCD deployment>
4 - go to <MBR Configuration options> and choose <Install windows Vista/7 bootloader into MBR> (or windows XP bootloader - depending on your windows em version)
5 - press button <Write MBR> exit EasyBCD and reboot.


Method B ( If you can not boot windows but have install disks )
From the Windows XP installation CD
Boot your computer from a Windows XP installation CD and choose R for restore or repair. You will see a terminal with a menu. Choose the number of the Windows partition, typically windows always has the first partition, so this will be 1 . Type
your administrator password )if you used one).

Install the windows NTLoader with the following commands:
fixboot C:
fixmbr


From the Windows 7 installation DVD
Windows 7 is slightly different from Windows XP. Follow these steps::

1. Put the Windows 7 installation disc in the DVD drive set BIOS to boot from CD/DVD drive.
2. Press a key when asked to (spacebar is always safe)
3. Choose your language and keyboard, and press Next.
4. Click Repair your computer.
5. Click on the operating system that you would like to "repair" and then click Next.
6. In the System Restore Options, click Command Prompt.
7. Type: Bootrec.exe /FixBoot and then press Enter. (Note: there is a space between Bootrec. exe and / )
8. Type afterwards: Bootrec.exe /FixMbr and press Enter (Note: there is a space between Bootrec.exe and / )


Method C ( If you can not boot windows and have no install disks )
Boot from a live CD of knoppix 7.02 or later. Install-mbr is not available on some other live CD's.
Open a terminal and become root.
Type:

Code:
install-mbr /dev/sda

Important!

If booting from an alternate live distro like Linux Mint or Ubuntu use the
following commands:
Code:
sudo apt-get install linux-mbr

sudo install-mbr /dev/sda

You MUST replace sda with the correct drive if you have more than one drive.
Note also that sda is the whole hard drive not a partition.

Edit You can also use testdisk to replace grub with a standard XP/Vista/Win7
bootloader and ms-sys from linux. Will provide instructions shortly

More Guides
There are many more ways to re-install the grub bootloader on linux. Some more links
are below:


https://wiki.archlinux.org/index.php/Grub_legacy

https://wiki.archlinux.org/index.php/GRUB2

https://help.ubuntu.com/community/Grub2
 
1 - 2 of 2 Posts
Status
Not open for further replies.
Top