# How do i restore the bootloader after nuking the mbr using fdisk /mbr ??



## twisted_mind (Feb 24, 2003)

OK.. this has happened for the fourth time in a week now... i boot up my computer ( win98 + Red hat 9) and the bootloader just appears half.... like Li-
and it hangs there.
So i put in my windows98 bootable floppy and fdisk /mbr. Now the last three times it happened, i just booted into win98 and using PartitionMagic 8 formatted the Linux partition. 
I'm tired of formatting the linux partition and having to set up linux all over again...  Is there any way i could restore the bootloader or perhaps boot into linux and install the bootloader or something??? I haven't created a linux bootable floppy.
Please keep in mind that i'm a real noob at linux... so try keeping the answer really simple.
With Regards,
Umesh


----------



## Grinler (Mar 10, 2004)

What version/distribution of linux are you using? Also do you know if you were using Grub or Lilo as your boot loader?

The process is to generally boot in with a boot/repair disk and rererun the bootloader installation.

For grub enter something like:
/sbin/grub-install /dev/hda

For lilo enter:

/sbin/lilo

And it should set up lilo as it was set up originally from the settings in /etc/lilo.conf


----------



## lynch (Aug 3, 2002)

That or make a RH bootdisk and keep it handy.
HTH
lynch


----------



## Grinler (Mar 10, 2004)

lynch said:


> That or make a RH bootdisk and keep it handy.
> HTH
> lynch


I do not remember, does the redhat bootdisk fix lilo on its own or do you still need to actually run the configuration commands?


----------



## Whiteskin (Nov 16, 2002)

Well, its Lilo. I doubt it rewrites it itself. More likely is that you will need to do it manually.


----------



## lynch (Aug 3, 2002)

I meant to just boot from the floppy.
I think you would have to do it manually with the bootdisk; probably not if you use the CD to boot with.
lynch


----------



## twisted_mind (Feb 24, 2003)

guys.... i am able to now boot into linux. This is what i did last night..
I popped in the cd 1 of red hat 9 and booted off the cd.... then i went ahead with an upgrade of the red hat installation but didnt select any packages to be upgraded.At the end of the upgrade? process, i was asked if i wanted to create a boot diskette... i put a floppy in... and a bootable floppy was created.
 Now i am able to boot into linux if i have the floppy in the drive. But how do i install a bootloader as well?


----------



## Whiteskin (Nov 16, 2002)

Well, since it is lilo, check your lilo configuration (man lilo.conf) and then just rerun lilo (as root "lilo").


----------



## twisted_mind (Feb 24, 2003)

hey.. when i type lilo as a root user... i get a command not found error.
By the way, i did as Grinler said above,
# /sbin/grub-install /dev/hda 
So now grub is installed..  Problem solved! Thanks to all of u !
With Regards,
Umesh


----------



## Whiteskin (Nov 16, 2002)

Cool. the "li" message indicated that it was trying to start lilo. Perhaps Accidentally the install made a mistake, and did not install lilo. Anyhow. People seem to like grub.


----------



## twisted_mind (Feb 24, 2003)

yeah.. grub it is now what i have. Incase it gets corrupted again i have the bootable floppy and now i know the command to install grub again! 
By the way, Anyone got an idea why i get the error "command not found" when i type pico ?? Pico loads up at my classes where i learn linux ( its red hat 6 there) but at home on my rh9 system, its not there.i did a custom install n didnt see pico anywhere...correct me if i'm wrong.
With Regards,
Umesh


----------



## lynch (Aug 3, 2002)

I think you need to have pine installed, as pico is part of the pine package.
HTH
lynch


----------



## Whiteskin (Nov 16, 2002)

It might be best to also learn another more standard editor (emacs or vi). Lets try not to get into a little editor war here though.


----------



## lynch (Aug 3, 2002)

Whiteskin said:


> It might be best to also learn another more standard editor (emacs or vi). Lets try not to get into a little editor war here though.


I agree.
I use vi.  
lynch


----------



## Whiteskin (Nov 16, 2002)

As do i. I dunno. I just like it. Though, gvim gave me a headache the other day. It duplicated very paragraph i wrote, two or three times.


----------



## tsunam (Sep 14, 2003)

I use nano ^.^


----------



## Whiteskin (Nov 16, 2002)

Only problem there is that nano isnt on everything.


----------



## rAz0r69 (Apr 25, 2004)

*Hey Everyone.. I'm new Here.. But anyway.. I have about the same problem as he did.. so i figured i wouldnt waste a new thread.. I had pretty bad luck with redhat linux9.. i recently installed it using the lilo boot loader first.. but i was new to partitions and bootloaders.. so i didnt install it right... and couldnt load windows.. but i could still use linux.. after i decided to remove linux.. i still had the bootloader.. but hadnt made a bootdisk for redhat.. my computer is getting old and i havent upgraded much of the hardware in a while.. so i had no A drive on it.. But i got an A Drive for it and with my luck... i had my plug n play cd rom on top of my box.. (my cd burner wont load autorun files) and guess what happened.. the cd rom fell and the first redhat cd got caught up.. and it scratched the hell out of the cd around the edge.. so now the cd wont even install anything.. much less let me make a bootdisk.. right now im using my cousins really terrible small hard drive as a substitute until i fix this... i just get a li- command on startup... and i cant reinstall linux.. which i dont have on their anymore.. so if anyone could send me the contents of the boot disk.. (if thatd work with a corrupt bootloader) or if you know any other fix.. plleeasse reply to this thread or contact me @ [email protected] Regards.. Rich*


----------



## liviu (Mar 23, 2004)

For rAz0r69:
Contact these guys:
http://www.osdisc.com/cgi-bin/view.cgi/index.html?ad=google_suse_linux_cd

They have really cheap Linux distros.


----------



## rAz0r69 (Apr 25, 2004)

No thanks.. id rather by a new hard drive if thats the case.. anyone have any better solutions?


----------



## Whiteskin (Nov 16, 2002)

Just download http://www.toms.net/rb/ tomsrtbt

From there you can fix most any problem.


----------



## rAz0r69 (Apr 25, 2004)

Thanks Whiteskin.. Exactly what I Needed!! Thanks to Liviu too..


----------



## I Fix 4 U (Jul 19, 2004)

LOL nuked mbr. Not good, best thing I can say is to reinstall bootloader on the MBR where you have linux, UNLESS IT IS THE SAME HD AS WINDOWS. If W!ndows is on the same HD as linux don't even mess with the mbr.


----------



## Whiteskin (Nov 16, 2002)

Why not? most decent distros are going to find your windows partition, and add it to your boot menu wherever your put the boot loader. Besides, it's a blessing not having to deal with the windows boot loader at all.


----------



## I Fix 4 U (Jul 19, 2004)

Not what I mean, if your bootloader is set to chainloader like its supposed to be, and the windows bootloader (boot.ini) is set to timeout=0, you don't even need to mess with or see the windows bootloader, but if you install grub on the mbr it will erase the windows bootloader. bad bad idea, i put grub on other harddrive, set my pc to boot from that harddrive, and added a grub entry for windows xp and it would boot xp without messing with xp's bootloader.


----------



## Whiteskin (Nov 16, 2002)

If you want to keep windows boot loader, yes. But you don't need it.


----------



## I Fix 4 U (Jul 19, 2004)

Ooh it seems that way doesnt it, but many distros add windows by what's called a chainloader command to (usually grub) which is used to boot the windows bootloader. They can't directly boot windows. Then you'd have to use a bootdisk or find some hard way to tweak it. You definetly need the windows bootloader for ez use. Like i said you won't even notice it if timeout=0, it will just go directly to loading windows.


----------



## saikee (Jun 11, 2004)

Any Linux can boot Windows by chainloading it. It is a matter of editing the boot menu by 2 to 3 lines. In Grub the command that does it is "Chainloader +1" and in Lilo it is "other=/dev/hda1", assuming it sits at the first primary partition. The bootmenu is a text file called /boot/grub/menu.lst or /etc/lilo.conf as the case may be.

The Linux chainloader doesn't just do Windows it can do any other Linux, as many as you want (got 9 in mine and each can boot Windows too within its own menu).

There is no need to touch Windows MBR if one put Linux bootloader into the Extended partition, make it active and thereby deactivate Windows partition. The BIOS will go straight to load whatever in the extended parition making MBR completely redundant. Any time one wants Windows back as before just make its partition active again. There is nothing to mess around.

The extended partition has nothing in it except a collection of logical partitions each can be used to store a distro and its bootloader for chainloading.

If the Windows partition is not active the MBR title actually goes straight to this extended partition and that is how the other Linux systems see it.

At any one time after the installation one can instruct any Linux distro to occupy the extended partition which is always hda4 or hde4, as no hard disk has more than 4 primary partitions. In Grub it is done with the command "grub-install /dev/hda4" while in Lilo it is by "lilo -b /dev/hda4" while logged as the root user.

Every Linux will include Windows as a boot choice during installation and so Windows is always available as a booting alternative.

-----------------------------------------

I am sorry if I make people unhappy here by saying it so easy . I marked myself illiterate in Linux in my signature when I joined the Forum in 11 June and started my Linux adventure as a absolute beginner. This post started Mid April or 6 weeks earlier.

In the first 2 to 3 weeks I had 4 Linux systems booting with XP in the same drive. I don't seem to pick up the booting problems but I have restored the MBR a few times whenever I wanted.

The 9 Linux systems that haven't given me booting troubles are Knoppix 3.3/3.4, Fedora Core 2, Red Hat 9, Suse 9.1, Mandrake 9.2, Libranet 2.8, Debian 3 and Lycoris. I am still a Linux newbie of less than two months old.


----------



## Whiteskin (Nov 16, 2002)

Not every linux... gentoo won't, and I don't believe slack will. Every "user-friendly" distro will, really.


----------



## saikee (Jun 11, 2004)

I missed out Slackware 10 in my list. The Gentoo iso I got only does terminal mode or I haven't find a way to get into the X-Windows yet.

I still have display problems with my Lycoris and Debian and have to do termal mode but since I preserve and expand their boot menu I could chainload them just like the rest.

There is no problem to chainload to Slackware from any other distro or from Slackware to the outside, however this distro seems to stop at the command mode for the password. I could only get the X-Windows up by type startx.

-------------------------------------------

Only 2 to 3 lines are needed to do chainloading in both cases, say for a distro storing in hda9 with its bootloader inside its partition;-

In Grub's /boot/grub/menu.lst

label = Distro ABS
root (hd0,8)
chainloader +1

(in later version of Grub the last two lines can be combined to "chainloader=(hd0,7)+1". Also Grub counts from zero)

In Lilo's /etc/lilo.conf

other=/dev/hda9
label="Distro ABC"

Thus it is almost a child's play to multi-boot in Linux.


----------



## Whiteskin (Nov 16, 2002)

I just mean the installer won't automagically setup windows on the boot menu on those distros.

In order to boot into X on all distros you will need a display manager. (GDM, KDM, XDM et. al.)


----------



## I Fix 4 U (Jul 19, 2004)

Listen to saikee, he knows his stuff. Yah, i deactivated windoze partition, installed grub on the partition with linux and I used it to boot Linux at first. I was just tired of making the windoze partition active every time i wanted to use it so i did a chainloader in grub so i can boot both without changing the active partitions. Any problems and BLAM! I make the windoze partition active again and It'll just boot windoze.

P.S. Why would you worry about windows being in the bootloader by default, you can always modify the grub.conf any time you like.
O and yes, lets say grub is your default and starting bootloader, and you have some other distro on your second harddrive in partition 6 you'd say chainloader +1 also with (hd1,5) (always can be changed to suit your needs) and viola, lilo will be loaded by grub which will then load that distro.  Great when bootin Solaris.


----------



## saikee (Jun 11, 2004)

The best trick is to assign the swap partition as the first logical partition as it hasn't got a bootloader.

Putting the Linux bootlaoder into the extended partition is physically putting it in hda4. This way every Linux distro is fully preserved and protected withit ints own partition, including its original boot menu and bootloader. Hda4 is a neutral ground.

Using the extended partition for booting one can kiss all the Windows booting good bye. Also if one is really crafty he would let the last Linux bootloader to occupy the extended partition, by that time it should have included every bootable system in the drive for you.

The extended partition can be made active simply by a DOS's command Fdisk in a floppy. The bugger won't do it for a DOS extended partition but has no second thought for a non-DOS (Linux) extended partition.

In Linux cfdisk you can't even see, create or mess the extended partition which is fully visible by fdisk -l.

Grub is superior to Lilo in many ways but I haven't found out if it can make a partition active for me yet. In Lilo the command is "lilo -A /dev/hda 4". The 4 is separate from hda saying let all partitions in inactive except the 4th partition.


----------



## I Fix 4 U (Jul 19, 2004)

*Good job again saikee.* :up: 
You are thinking about installing windows and than many (or few) linux distros all on the _same _ harddrive. Yup best idea is to have windows installed first, have an extended partition, put your first distro on it, then your second, while ignoring the bootloader and not installing one. Then on your final linux distro you want installed, choose grub and it should make entrees for every OS you have on your system.

Then with some windows boot floppy, run fdisk and make the extended partition active instead of windows. That will make windows unbootable but wait i'm not done yet. Remember saikee, to make the windows partition active just add "makeactive" to your grub.conf under windows part. 
For correctly tweaking grub ask me I had alotta fun making grub do things it normally doesnt.


----------



## saikee (Jun 11, 2004)

I am not thinking about it I have already 9 Linux systems with XP. 

I think you get the idea. I just repeat a few items.

(1) Best way is to use the first logical partition for the swap because it has no bootloader. The extended partition physically is the first logical partition. Since a swap partition's first track is never used it is the ideal place for the boot manager once the extended partition has been made active.

(2) Apart from not letting a Linux to format the whole hard drive you can let its bootloader go anywhere without a consequence but keep it inside it partition has one advantage - You get its boot menu after chainloading and can use it to jump to another Linux. In fact you can jump around in circles between Linux without getting into anyone and try to satisfy that each one boot Windows successfully.

(3) When you make Windows inactive it is still available from every Linux's boot menu. You don't have to do anything to make it active. 

(4) You can instruct any of the Linux bootloader into the Extended partition by just one line of command, using either Lilo or in Grub as the case may be.


----------



## I Fix 4 U (Jul 19, 2004)

whatever i guess that will also work but atleast my way works too so i dont have to change anything ...


----------

