Originally Posted by kage_wing
I returned to my first pc turned it on and GRUB gives me and Error 21. I don't get this error when my second hard disk was in placed.
The reason this happened, is the MBR contains the first stage of the bootloader only. The MBR is 512 bytes (including parition table!), which does not allow much code. So the first stage in the MBR calls the second stage of the boot loader, which is (was) on your second drive. The second drive also contained the menu info (/boot/grub/menu.lst
I know I can repair this by fixing the MBR, but what about my second hard disk? how can I let it work on the second PC, will I have to reinstall Ubuntu again? or is there a way to fix the GRUB so that it can load it from there.
If you really haven't done any customization or have an user files, the simplest thing might be just to reinstall. However, with probably minimal work you can probably get this working w/o reinstalling. You would need to install the bootloader (MBR), edit /boot/grub/menu.lst
and possibly edit /etc/fstab
. Editing fstab
is not necessary if all the refernces to partitions are by UUIDs, which I believe is the case. I am not sure if I am forgetting something else you would need to edit
I am assuming in what follows that this disk is the primary hard drive (/dev/hda or /dev/sda). With the hard drive in the system, boot the system from your Ubuntu live CD, and bring up a terminal.
Type the following (what you type is in bold):
user@box~$ sudo grub
grub> root (hd0,0)
grub> setup (hd0)
That should install GRUB on your MBR.
To edit the configuration files, you need to first mount your installation partition, which I am assuming is /dev/sda1
sudo mkdir /mtn/sda1
sudo mount /dev/sda1 /mnt/sda1
You now have access to all of the files on your Ubuntu installation. All paths must have /mnt/sda1
prefixed to them. For example /boot/grub/menu.lst
will now be accessed as /mnt/sda1/boot/grub/menu.lst
You need to edit menu.lst
. Type sudo
followed by the name of your favorite editor followed by /mnt/sda1/grub/menu.lst
and change the line that currently reads
Save your edit, exit the editor and type:
sudo chroot /mnt/sda1 update-grub
Unless I have forgotten something :-/ , you should now be able to boot into your Ubuntu instalation.
I need alternative ways on how to fix the MBR. I don't have XP installer cd and a floppy on my computer.
There is a Linux program called install-mbr
(I have not used it) that is supposed to be able to handle this. In Ubuntu, this is in the mbr
package which you can install:
sudo apt-get install mbr
It also exists on the KNOPPIX live CD if you want to get a copy, or you might check to see if it exists on the Ubuntu live CD. Read its man page
EDIT: You will probably also want to remove the lines from menu.lst
which refer to the XP installation. But you can wait until you are able to boot into your regular Ubuntu installtion, if you wish.