Click to See Complete Forum and Search --> : Boot loader questions


kaptainkal1
07-23-2004, 03:42 PM
I INstalled Fedora Core2 on my laptop a long time ago, whihc has Windows XP on a differnet partition. If i reinstall Windows (which I htink I need to do), is there a way where I can get the boot loader for linux to install after i reinstall windows so that i dont have to reinstall linux? Basically, i dont wanna redo my fedora install. I've been using it for a long time and I'm happy with it. Is there a way to just install the boot loader and have it recognize everything?

Icarus
07-23-2004, 03:48 PM
Best thing to do is make a boot floppy disk, then reload Windows and boot off the floppy to get to Linux.

Then you can run "grub-install /dev/hda1" to set Grub back up

kaptainkal1
07-23-2004, 04:43 PM
My laptop doesnt have a floppy drive...

DMR
07-23-2004, 06:09 PM
You should be able to boot into rescue mode from the Fedora CD and issue the following 2 commands:

chroot /mnt/sysimage
grub-install /dev/hda

saikee
07-23-2004, 06:52 PM
OK, here is the deal

You will first install grub into the partition of FC2. Since you got Windows and it likes the first primary partition so I assume Windows in hda1 and your FC2 in hda2. Change them to suit your circumstances. The command is like Icarus said but I change it for your hda2

grub-install /dev/hda2

Make sure Grub reports a success of this operation or no error reported.

The next step is get hold of a live Linux CD (like Knoppix or SLAX) that has cfdisk (as I am not familar with FC2's own sfdisk and parted to make a partition bootable) and use its cfdisk to make the FC2 partition bootable and Windows unbootable. You can test that FC2 is working perfectly before doing anything to Windows. (Note: you will not find any difference from before but the fact is you now are not relying on the MBR to boot FC2).

Switch the Windows partition to active again and go ahead reinstall your Windows.

When you new Windows has been installed you will have no access to FC2. Make sure it work alright and then use the Live CD's cfdisk to switch the FC2 partition active again.

You will have the new Windows available for booting with the existing FC2.

Have fun!

kaptainkal1
07-28-2004, 10:00 AM
I'm not understading you properly. I reinstalled windows xp. The first thing I'm supposed to do is go to the rescue mode and issue those 2 commands right? then what? Linux is hda3 on my comp btw...

saikee
07-28-2004, 10:49 AM
In order to load a Linux you need its bootloader which can be placed in MBR or inside its own partition.

My first suggestion is to have it installed inside the partition if you haven’t done it already. If your FC2 is in hda3 then “grub-install /dev/hda3” will put the Grub bootloader in the first track of hda3 reserved exclusively for a bootloader.

Your PC will boot to the active partition. Since everybody uses the first primary partition to store Windows it is made active too. So after your re-installation you boot only to Windows and cannot see FC2 because there is no connection between the two.

However, by switching the partition hda3 active and deactivate hda1 the PC has no choice but to boot up FC2 as the bootloader is ready there.

If your FC2 has been installed correctly it will be able chainload Windows automatically by these 3 lines (should already in /boot/grub/menu.lst but can be added if you want)

Title Windows
Rootnoverify (hd0,0)
Chainloader +1

The reinstallation of Windows does not alter its original position of being at the first partition of the first hard disk (in Grub (hd0,0)=Linux hda1 as Grub counts from zero). Thus inside FC2 boot menu you should have access to the reinstalled Windows again.

The only challenge you have is to have a tool to do the switching of active partition. cfdisk is ideal and available in a Live CD. An old DOS bootable floppy with Fdisk would have been able to do the same job but you haven't got a floppy drive, right?

My suggestion requires no interference with the MBR and you can always get Windows back to its original condition by switching its partition active again.

If you haven't place FC2 bootloader into its own partition then it can be tricky to bring FC2 back to life without the use of a floppy but it can be done.

DMR
07-28-2004, 10:52 AM
After you've reinstalled Windows:

When you boot into rescue mode from the CD, the entire filesystem on your hard drive is mounted under the special /mnt/sysimage directory. The "chroot /mnt/sysimage" command essentially switches you over to that system (as opposed to running off the CD) so that you can browse directories and files and run commands from the hard drive installation just as you would if you booted from the hard drive. This is necessary because when you boot from the system on the CD, it creates and uses its own filesystem hierarchy (/, /boot, /mnt, /dev, etc. directories); if you do not do chroot, issuing a command such as "cd /boot" would take you to the /boot directory created by the CD, not the one on your hard drive.

Assuming that you now use Grub as the primary loader for Linux and Win (and want to keep it that way):

"grub-install /dev/hda" will make grub the primary bootloader for both operating systems. .If you do it this way, you won't have to jump through all of hoops that saikee describes because your Grub configuration file, which was already configured to dual-boot, still exists in your /boot/grub directory.

If you did "grub-install /dev/hda3", that would install grub to the boot sector of the partition on which you've installed Linux. This will not make Grub the primary bootloader, so you will have to either do what saikee described (or configure XP's bootloader to handle the dual-booting).

As far as the issue of "messing" with the MBR by installing a Linux bootloader goes, some people prefer to do as saikee outlines, but I myself have never had a problem with installing Grub's first stage to the MBR of the primary drive. Even in the unlikely event that something does go wrong, the MBR can be reset with Windows' FIXMBR command, and Linux can be accessed by booting from the install CD- no big deal...

kaptainkal1
07-28-2004, 11:04 AM
I put the following:

chroot /mnt/sysimage
grub-install /dev/hda

and it worked perfectly, thanks.

saikee
07-28-2004, 11:07 AM
DMR method of using a resue CD is different to my suggestion but his description of it is accurate. The only bit I wish to added is that switching a active partition around is using the hard disk characteristic. It is independent of any operating system and is simply what a hard disk behaves in a PC.

DMR
07-28-2004, 11:53 AM
Originally posted by kaptainkal1
I put the following:

chroot /mnt/sysimage
grub-install /dev/hda

and it worked perfectly, thanks. Glad it worked for you- a happy penguin is a Good Thing. :D