Jump to content



Photo

[HOW TO] Get Your *nix Bootloader Back


  • Please log in to reply
19 replies to this topic

#16 stylemessiah

stylemessiah

    Neowinian

  • Joined: 07-February 05

Posted 14 November 2006 - 05:25

Why lose it in the first place?

Its easy to avoid the entire unpleasantness when installing Linux onto a PC thats already hosts Windows, you just have to think about not upsetting precious windows, after all, its more finicky about its bootsector than Linux is.

Here's what i do:

Install linux.....wait until bootloader setup

Then

* Modify setting if needed to put bootloader on root partition (the partition that hosts \)

Then AFTER bootloader is written and anytime BEFORE you complete installation reboot:

* Switch to a terminal window form the setup GUI, on SuSE 10.1 for example i use CRTL ALT + F5.

* Put a floppy disk in your floppy drive

* Make a folder under /mnt, e.g. md /mnt/floppy (on some linuces, you may need to make an entirely different folder than floppy, as one may already exist and not be able to be written to - dont ask why, ive seen it, in this case try md /mnt/fdtemp etc.)

* Mount your floppy disk, e.g. mount -t vfat /dev/fd0 /mnt/floppy

* Type: dd if=/dev/hdaX of=/mnt/floppy/bootsec.lnx bs=512 count=1

Where X = the root partition number (e.g. /dev/hda11 as it is on mine)

* Browse to the floppy and make sure the bootsec.lnx file is there.

* Complete linux install and reboot into Windows

* Copy bootsec.lnx to c:\

* Keep floppy in a safe place, or copy the bootsec.lnx to a safe place.

* Open boot.ini in notepad

* Add "XXXX Linux" = c:\bootsec.lnx in the OS list under windows.

Where XXXX is the name of the linux or something witty and anti MS

* Save the file.

* Enjoy.

A few seconds work and thinking intelligently means you can avoid the whole bootsector drama completely and not upset either. I havent met a linux yet this isnt possible to use on.

As i said ive been using this since my first forays into Red Hat and Windows 2000, hasnt failed me yet.


Why lose it in the first place?

Its easy to avoid the entire unpleasantness when installing Linux onto a PC thats already hosts Windows, you just have to think about not upsetting precious windows, after all, its more finicky about its bootsector than Linux is.

Here's what i do:

Install linux.....wait until bootloader setup

Then

* Modify setting if needed to put bootloader on root partition (the partition that hosts \)

Then AFTER bootloader is written and anytime BEFORE you complete installation reboot:

* Switch to a terminal window form the setup GUI, on SuSE 10.1 for example i use CRTL ALT + F5.

* Put a floppy disk in your floppy drive

* Make a folder under /mnt, e.g. md /mnt/floppy (on some linuces, you may need to make an entirely different folder than floppy, as one may already exist and not be able to be written to - dont ask why, ive seen it, in this case try md /mnt/fdtemp etc.)

* Mount your floppy disk, e.g. mount -t vfat /dev/fd0 /mnt/floppy

* Type: dd if=/dev/hdaX of=/mnt/floppy/bootsec.lnx bs=512 count=1

Where X = the root partition number (e.g. /dev/hda11 as it is on mine)

* Browse to the floppy and make sure the bootsec.lnx file is there.

* Reboot into Windows

* Copy bootsec.lnx to c:\

* Keep floppy in a safe place, or copy the bootsec.lnx to a safe place.

* Open boot.ini in notepad

* Add "XXXX Linux" = c:\bootsec.lnx in the OS list under windows.

Where XXXX is the name of the linux or something witty and anti MS

* Save the file.

* Enjoy.

A few seconds work and thinking intelligently means you can avoid the whole bootsector drama completely and not upset either. I havent met a linux yet this isnt possible to use on.

As i said ive been using this since my first forays into Red Hat and Windows 2000, hasnt failed me yet.


#17 Omegatron

Omegatron

    Neowinian

  • Joined: 26-February 07

Posted 03 March 2007 - 15:44

You can also use a LIVECD distro like Knoppix and install GRUB.. grub-install

#18 HT2791

HT2791

    Neowinian

  • Joined: 27-July 05

Posted 07 March 2007 - 22:17

i really didn't understand the first post (i'm new to linux).
i had to reinstall winxp because dual booting Ubuntu corrupted winxp files.
I got it back by:


Boot the livecd.
Start a terminal.

sudo -i
grub
find /boot/grub/stage1 // Will print something like (hd0,1)
root (hd0,1)
setup (hd0)
quit

was easy for me :)

#19 Biffa001

Biffa001

    Neowinian

  • Joined: 28-April 07

Posted 28 April 2007 - 09:44

Hi,

Boot the livecd.
Start a terminal.

sudo -i
grub
find /boot/grub/stage1 // Will print something like (hd0,1)
root (hd0,1)
setup (hd0)
quit


I already had winxp installed on my PC and have just installed the latest Ubuntu 7.04, immediately upon reboot I received a grub error 22 and nothing booted! Thanks to my PDA net access and this forum I got my windows bootloader back and then have just followed the above info to try and get a boot screen back to be able to choose either winxp or ubuntu but with no joy.

I just tried the above and it all seemed to go ok (no errors within the terminal window), but when I rebooted my PC it just started up straight into windows xp again....!

Help!

#20 DjmUK

DjmUK

    TheDon

  • Joined: 08-September 01
  • Location: UK

Posted 11 November 2009 - 00:10

For GRUB2 under Ubuntu 9.10 I had to do the following after I broke my bootloader. It kept loading up the memtest after I played around with startupmanager and GRUB2 provided NO menu to choose the kernel :\
  • Boot via LiveCD
  • sudo fdisk -l (list hard drives)
  • sudo mount /dev/sda1 /mnt (mount the hard drive)
  • sudo mount --bind /dev /mnt/dev (mount other devices)
  • sudo chroot /mnt (great power comes great responsibility)
  • gedit /etc/default/grub (this loads up the GRUB2 options)
  • Change GRUB_DEFAULT=3 to GRUB_DEFAULT=0 (aka first kernel in grub.cfg, mine was 3 pointing at memtest)
  • update-grub (this updates that read-only /boot/grub/grub.cfg file)
  • shutdown -r now (reboots your baby)
That's the procedure that worked for me, I have a single hdd with no special partitioning (just default installed).

All the above is broken down from the Wiki Grub2 page.



Click here to login or here to register to remove this ad, it's free!