I have Ubuntu on one physical disk, Windows XP with Grub on another physical disk, and a couple of external HDs for data, and the new XP install on a 3rd HHD.
I have searched the questions and every one refers to Boot-Repair as the answer. So I downloaded the boot-repair-disk, and using the directed terminal commands doesn't work for me. It says it can't find Grub to remove it or some such. I also tried to download boot-repair from a live CD, but can't seem to find the program, and it is no longer downloadable from Source Forge or the developer's website--at least that I can find.
Are there any other ways to restore Grub when all I have access to is the Ubuntu Live CD, the boot-repair-disk, and Windows XP. I can't even access Grub Rescue and wouldn't know what to do with it if I could.
As a last resort, is a non-destructive re-install of Ubuntu possible, and, if so, how would I go about doing it? If not, should I just bite the bullet, reformat the Ubuntu disk and reinstall Ubuntu.
I'm going through computer hell because the Windows C drive is failing, and replacing it with a clone didn't allow me to boot into XP from the Grub on the clone.
41 Answer
When you install Windows, Windows assumes it is the only operating system (OS) on the machine, or at least it does not account for Linux. So it replaces GRUB with its own boot loader. What you have to do is replace the Windows boot loader with GRUB. I've seen various instructions for replacing GRUB by mucking around with GRUB commands or some such, but to me the easiest way is to simply chroot into your install and run update-grub. chroot is great because it allows you to work on your actual install, instead of trying to redirect things here and there. It is really clean.
Here's how:
- Boot from the live CD or live USB, in "Try Ubuntu" mode.
- Determine the partition number of your main partition. GParted
(which should already be installed, by default, on the live session)
can help you here. I'm going to assume in this answer that it's
/dev/sda2, but make sure you use the correct partition number for your system! Mount your partition:
sudo mount /dev/sda2 /mnt #Replace sda2 with your partition numberBind mount some other necessary stuff:
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; doneIf Ubuntu is installed in EFI mode (see this answer if you're unsure), use GParted to find your EFI partition. It will have a label of EFI. Mount this partition, replacing sdXY with the actual partition number for your system:
sudo mount /dev/sdXY /mnt/boot/efichroot into your Ubuntu install:
sudo chroot /mntAt this point, you're in your install, not the live session, and running as root. Update grub:
update-grub
If you get errors or if going up to step 7 didn't fix your problem, go to step 8. (Otherwise, it is optional.)
Depending on your situation, you might have to reinstall grub:
grub-install /dev/sda update-grub # In order to find and add windows to grub menu.If everything worked without errors, then you're all set:
exit sudo rebootAt this point, you should be able to boot normally. If you cannot boot normally, and didn't do step 8 because there were no error messages, try again with step 8.
Sometimes giving GRUB2 the correct configuration for your partitions is not enough, and you must actually install it (or reinstall it) to the Master Boot Record, which step 8 does. Experience helping users in chat has shown that step 8 is sometimes necessary even when no error messages are shown.
2