Jump to content



Photo

[HOW TO] Get Your *nix Bootloader Back


  • Please log in to reply
19 replies to this topic

#1 Hurmoth

Hurmoth

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 09-March 03
  • Location: Virginia

Posted 26 May 2005 - 19:26

I saw where Aaron had written the HOWTO Guide for getting the Windows bootloader back, but what if you're someone who needs their GRUB or LILO back? What then? Well, I found the answer for anyone who might need it :D

GRUB
  • Boot into the first CD
  • Type linux rescue when asked what to boot.
  • After you have chosen Language and Keyboard layout, you are asked if you want to mount your harddisk system. Say yes to this.
  • Now you system is mounted as /mnt/sysimage. Say 'OK'. Now type: chroot /mnt/sysimage. This will make you run on your already installed system, instead of the CD-ROM
  • Type /sbin/grub-install /dev/hda (change hda to sda if you're using an SATA hard drive)
LILO
  • Boot into the first CD
  • Type linux rescue when asked what to boot.
  • After you have chosen Language and Keyboard layout, you are asked if you want to mount your harddisk system. Say yes to this.
  • Now you system is mounted as /mnt/sysimage. Say 'OK'. Now type: chroot /mnt/sysimage. This will make you run on your already installed system, instead of the CD-ROM. Now you can edit /etc/lilo.conf if something was wrong (vi /etc/lilo.conf and run lilo), or if you need to reinstall LILO just type lilo. The LILO installation process should now run.
This may be different for different distros and how you may have your system setup. I do not issue any guarantees with this HOWTO. Neowin, nor myself, is responsible if you bork your system. If you have any problems post them here ;)

Edited by Hurmoth, 16 June 2006 - 20:53.



#2 vetmarkjensen

markjensen

    Linux noob since Red Hat 5.1

  • Joined: 02-October 03
  • Location: Middle Tennessee
  • OS: GNU/Linux
  • Phone: Android and iPhone

Posted 26 May 2005 - 19:56

Good idea to have this posted (Y) I have never had to do this, but many others have had to and have posted questions on it.

Anyone have an addition for doing this for LILO users?

#3 MrA

MrA

    b47d2b5288e3c77

  • Joined: 09-November 03
  • Location: Oz.

Posted 26 May 2005 - 20:14

Just an addendeum. You can install GRUB from within GRUB (this is how I like to do it).
1. Boot from a floppy or CD which uses GRUB as it's bootloader.
2. When you see GRUB's boot-menu, hit 'c'. You should see a "grub>" prompt
3. Type the following commands:
grub> root (hd0, 0)
grub> setup (hd0)

Commands explained:
"root (hd0, 0)" - This tells grub where it can find grub's files which are normally located in "/boot/grub/". The sample command tells grub that the files are located on the first hard drive, on partition 0 (first partition). If you don't know which drive/partition hold grub's files, you can do a:
grub> find /boot/grub/stage1
"setup (hd0)" - Tells grub to install itself on the Master Boot Record (MBR) of the first hard drive. You can also tell grub to install onto a partition by doing a "setup (hd0, 1)". This will tell grub to install to the second partition of the first hard drive.

Tips:
- Grub has a "help" command. Use it.
- Grub supports "bash-like" auto-completing. Say you don't quite know the partition number of your linux partition, but you know it's on the first hard drive and you know it's an ext2 partition. You can type:
grub> root (hd0,
and hit [tab]
This gives me:
Possible partitions are:
   Partition num: 0,  Filesystem type is reiserfs, partition type 0x83
   Partition num: 1,  Filesystem type is ext2fs, partition type 0x83
   Partition num: 2,  Filesystem type is reiserfs, partition type 0x83
Voila! It's partition number 1. Auto-completeing also works for other grub commands.

#4 OP Hurmoth

Hurmoth

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 09-March 03
  • Location: Virginia

Posted 26 May 2005 - 20:44

Anyone have an addition for doing this for LILO users?

View Post

If anyone adds it, I'll change the title and add it to my first post (giving the person credit of course) ;)

Good idea to have this posted (Y)  I have never had to do this, but many others have had to and have posted questions on it.

My boss' GRUB got messed up and wouldn't boot so I had to research how to fix it. The first place I looked was here and all I saw was Armeck's guide to getting the Windows bootloader back.

#5 Kreuger

Kreuger

    Neowin's Local Grouch

  • Joined: 29-December 03
  • Location: Ontario, Canada

Posted 27 May 2005 - 10:48

Yes this is a good post. My grub was messed too (error 18) and I couldn't fix it because Linspire Live couldn't detect my damn hard drive for some reason so I couldn't fix it. Also, when I attempted to go into linuxrecovery of the Debian cd, it wouldn't let me reinstall grub from there.

#6 OP Hurmoth

Hurmoth

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 09-March 03
  • Location: Virginia

Posted 27 May 2005 - 11:29

I added a way to reinstall LILO using the first installation disc, this can also be done with a Rescue Disc or Floppy Disk. I have never used LILO, so early this morning I installed a fresh copy of FC3 and used LILO instead of GRUB and messed it up on purpose to try and find out how to reinstall LILO... and that is what I came up with. Let me know if I have any typos :D

#7 invalidbuffalo

invalidbuffalo

    Neowin Audiophile

  • Joined: 15-May 05

Posted 18 January 2006 - 21:24

I get the error:
/dev/hda: Not found or not a block device.
when I try to reinstall GRUB.

#8 vetmarkjensen

markjensen

    Linux noob since Red Hat 5.1

  • Joined: 02-October 03
  • Location: Middle Tennessee
  • OS: GNU/Linux
  • Phone: Android and iPhone

Posted 18 January 2006 - 21:52

I get the error:
/dev/hda: Not found or not a block device.
when I try to reinstall GRUB.

If you do an fdisk -l (that is a lowercase letter "L", not the number one), what do you get for drives listed? Do you have SATA drives?

#9 invalidbuffalo

invalidbuffalo

    Neowin Audiophile

  • Joined: 15-May 05

Posted 18 January 2006 - 22:10

If you do an fdisk -l (that is a lowercase letter "L", not the number one), what do you get for drives listed? Do you have SATA drives?


Fixed- I guess for SATA drives replace 'hda' with 'sda.' And now I have linux again! w00t!

#10 wildworld_ammsa

wildworld_ammsa

    Persian Mage

  • Joined: 11-August 02

Posted 16 June 2006 - 10:03

hi every one,

i think this topic needs to be a Sticky. if some admin agrees, can he/she plz add it?

Thanx,

Ammsa

#11 Barney T.

Barney T.

    Debian Linux: I'm Loving It!

  • Tech Issues Solved: 3
  • Joined: 30-August 03
  • Location: Williamsburg, Virginia

Posted 16 June 2006 - 14:33

i think this topic needs to be a Sticky. if some admin agrees, can he/she plz add it?


[Pinned]

This may not stay, but we'll see. There is a limit as to how many topics we can "pin". This is a good topic to have handy. :woot:

Barney

#12 wildworld_ammsa

wildworld_ammsa

    Persian Mage

  • Joined: 11-August 02

Posted 16 June 2006 - 19:51

from time to time i had to search this topic to link for other ppl so i thought maybe it's a good idea to pin it.

thanx barney,

#13 OP Hurmoth

Hurmoth

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 09-March 03
  • Location: Virginia

Posted 16 June 2006 - 20:54

Fixed- I guess for SATA drives replace 'hda' with 'sda.' And now I have linux again! w00t!

I updated the first post to reflect that. Thanks for pointing that out (Y)

#14 gary4gar

gary4gar

    Neowinian

  • Joined: 21-March 06

Posted 09 July 2006 - 11:07

i got a error that

/boot/grub/stage1 couls not be read

also when i do

chroot /mnt/sysimage

it says Not found.i have a sata hdd & ubuntu 5.10.

#15 Rob2687

Rob2687

    ?

  • Joined: 27-April 03
  • Location: Ontario, Canada

Posted 30 September 2006 - 20:34

Which cd are you booting from? I've tried the ubuntu installers and none of them have the linux rescue thing.