Tag: grub error
Fixing the grub error in Ubuntu
by admin on May.27, 2010, under Ubuntu, Ubuntu 9.10, ubuntu 10.04
Installing Windows After Ubuntu
Normally when Windows is installed after Ubuntu the master boot record will be overwritten. This means that you would have to boot off a LiveCD and re-install grub. The steps are
#sudo grub
From the grub
Type
grub> find /boot/grub/stage1 (If you installed separate /boot partition, then find /grub/stage1 )
(hd0,1)
(hd0,5)
It dispay partition which contains your grub files. I have two linux OS installed.
Then run the following command
>root (hd0,1)
>setup (hd0)
(hd0) = the MBR for the hard disk which is where grub needs to install itself too for it to load on bootup.
Another Method
fdisk -l
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 8 64228+ 83 Linux
/dev/sda2 9 1224 9767520 83 Linux
/dev/sda3 * 1225 2440 9767520 a5 FreeBSD
/dev/sda4 2441 14593 97618972+ 5 Extended
/dev/sda5 14532 14593 498015 82 Linux swap / Solaris
/dev/sda6 2441 14530 97112862 83 Linux
Partition table entries are not in disk order
Here are listed three Linux partitions. /dev/sda2 is the root partition, /dev/sda1 is the /boot partition and /dev/sda6 is the /home partition. If you only have one partition, this means that your entire Ubuntu system is installed on that one.
Later there will be a section on how to determine which partition your Ubuntu installation is on if you have several different partitions.
First, create a mountpoint for your partition, for example:
mkdir /media/root
Then mount your partition in it. If you don’t know which one it is, then mount any of them, we will determine if it is the correct one.
mount /dev/sda2 /media/root
Replace /dev/sda2 with the correct name of your partition. To check if it is the correct one, run ls /media/root which should output something like this:
bin dev home lib mnt root srv usr
boot etc initrd lib64 opt sbin sys var
cdrom initrd.img media proc selinux tmp vmlinuz
If what you have looks nothing like this, the drive you have selected is incorrect. Run umount /media/root in the Terminal to unmount it then mount and try another one. Should you have made a /boot partition you can mount it like so:
mount /dev/sda1 /media/root/boot
To make sure this is indeed the /boot partition, run ls /media/root/boot, which should output something like this :
config-2.6.18-3-686 initrd.img-2.6.18-3-686.bak System.map-2.6.18-3-686
grub lost+found vmlinuz-2.6.18-3-686
initrd.img-2.6.18-3-686 memtest86+.bin
Once again, if what you have is not similar, unmount it and try another partition.
Now that everything is mounted, we just need to reinstall GRUB:
sudo grub-install –root-directory=/media/root /dev/sda
If you get BIOS warnings try:
sudo grub-install –root-directory=/media/root /dev/sda –recheck
Note: Replace /dev/sda with the location you want to install GRUB on. If all went well, you should see something like this:
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
Reboot, making sure to boot to your hard drive and not to the live CD. Grub should be installed and both Ubuntu and Windows should have been automatically detected.