LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   OS boot loader (https://www.linuxquestions.org/questions/linux-general-1/os-boot-loader-562035/)

cyb3rdawn 06-15-2007 09:51 AM

OS boot loader
 
Hi. i run ubuntu 7.04 and xp on the same machine, and i need to reinstall the windows. the problem is that if i reinstall it the windows os loader will pop up and there is no way that i can choose to run linux.
i've tried several different os loaders(a long time ago, so i don't remember exactly which), and they seemed to be fine with loading windows, but they could not load linux (i ran warty warthog then). should i somehow disable lilo? can you recommend me an os loader that works, or is there any other way?

bigrigdriver 06-15-2007 10:50 AM

Windows will take over the MBR when you re-install xp. It should be easy to fix.

After installing xp, boot the Ubuntu install cd. You may see an option to boot from cd or hard drive. Choose one. When Ubuntu is up an running, just run grub-install again to put it back on the MBR and have dual boot.

I haven't done it in quite a while, but I beleive the sequence goes like this:
Open a terminal, and go to the grub prompt: grub <enter>
Then: grub-install /dev/hd0
Exit and re-boot to verify that it worked.

You will probably have to do a sudo to get root authority. Something like 'sudo grub'.

saikee 06-15-2007 03:59 PM

Actually the grub-install command is a terminal command to be issued inside the installed Linux and will not work without prior connection with the installed version. As such Grub need to know where the Grub comes from by the use of the "root" statement.

If the Ubuntu has been installed in say (hd0,1) or the 2nd partition of the 1st disk (or sda2 to Ubuntu Linux) then the commands in a Grub shell are
Code:

sudo grub
root (hd0,1)
setup (hd0)

will instruct Grub to "source" the Grub files from (hd0,1) and install itself in the MBR or the whole of the disk sda.

Alternatively without a Grub shell but grub-install one needs to mount the partition first like
Code:

sudo mkdir /mnt/sda2
sudo mount /dev/sda2 /mnt/sda2
sudo chroot /mnt/sda2
grub-install /dev/sda
exit

The red commands above change root from the boot-up CD Linux into the unbootable Ubuntu inside partition sda2. Therefore grub-install is issued "inside" the unbootable Linux.

Both methods work satisfactorily. The latter does not need the original Ubuntu installation CD but any Live CD will do because one boots up the kernel of the Live CD but is actually using the Bash shell of the unbottable Linux. Therefore the same method of using any Live CD can be used to rescue a Lilo whose equivalent command to "grub-install /dev/sda" is just "lilo -b /dev/sda" at the terminal.


All times are GMT -5. The time now is 06:39 PM.