LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Grub rescue (https://www.linuxquestions.org/questions/linux-general-1/grub-rescue-815634/)

muckybucket 06-22-2010 06:15 AM

Grub rescue
 
I stupidly repartioned a triple-boot laptop, with the intention of creating two partitions...

However, after rebooting realised I hade inadvertently removed grub. Now the system just boots into 'Grub Rescue'.

Is there anything I can do to get it booted? It won't boot from either CD or USB, but seems to see these when it starts. What commands can I use for grub rescue? Failing this might have to pull the drive and hook it up to something else and re-partition and recreate GRUB.

gasdim 06-22-2010 06:18 AM

Hello
If you want to boot from CD you should change the boot priority from bios of your laptop.
Usually when you install win the bios option to boot from CD changes and boot from Hard-disk is the first option.

Kostas

muckybucket 06-22-2010 06:23 AM

Thanks for the advice, but I already know that. Whatever settings I make to the boot menu, this laptop will not boot from CD. I have used PLop in the past but I cannot access that at the moment either.

saikee 06-22-2010 07:45 AM

Grubrescue is 1/3 of Grub2. It can't be used for booting but typing "help" will show you the commands available.

You can use the "ls" command to find out what the partitions are and what files available. Grub2 can read ntfs partitions too. Grub2's ls command is similar to Linux's ls.

The cure is to restore Grub2 and this can be done by any Linux Live CD with Grub or booted up Linux from your PC.

The steps are

(1) Identify the partition that has Grub2, say this is sda3
(2) Mount /dev/sda3 on /mnt/sda3
(3) Bind the /dev of the current boot up Linux with the mounted /mnt/sda3/dev
(4) Do a Grub-install with the root directory pointed to the mounted partition and the destination of the MBR.

Typical Commands are
Code:

sudo su
mkdir /mnt/sda3
mount /dev/sda3 /mnt/sda3
bind /dev /mnt/sda3/dev
grub-install --root-directory=/dev/mnt/sda3 /dev/sda

use "su" instead of "sudo su" for non-Ubuntu and non-Debian family distros.

The reason of binding is inside /mnt/sda3/dev the deivice names will be empty as they only get populated on booting when each device can be detected.

Grub-install will work if /mnt/sda3 is "empty" because it will fill it up with the needed system files but you won't get the grub.cfg.

You can make a Grub2 or Grub1 (doctored version for Ext4 partition) floppy to fire up the Linux or any OS. A Linux is bootable even the Linux has no boot loader installed!

muckybucket 06-22-2010 07:53 AM

What can be done without booting from disk? 'Help' just brings up 'unknown command' so it looks like there might not be much available.

'ls' produces the following (with USB stick in):

(hd0) (hd0,2) (hd0,1) (hd1) (hd1,2) (hd1,1)

Think hd1 is the stick as it doesn't appear when it is not connected.

Like I said a normal boot from USB or CD is not an option. I can either find a way to boot one or other from grub rescue or pull the disk and repartition by hooking it up to another machine...

saikee 06-22-2010 08:02 AM

To boot a system you need Grub2 (or Grub1) to have the ability to hand over the control to a Linux or a MS Windows.

With the former Grub2 needs the command "linux" and Grub1 needs "kernel".

To do the latter you need "chainloader" command from either Grub.

Grubrescue is the bit that left behind in the MBR after to nuked the partition that hold its inteeligence which is a file called "core.img".

core.img can be fired up by Grub1 with the "kernel" command.

If you have no bootable means of floppy, CD and USB and rely exclusively booting from a hard disk then the only way out would be to remove the disk and add a Grub partition to it to make it bootable.

The ls command confirms that there are two disks; one with 1 partition and the other with 2. You can ls the content of say partition (hd1,2) by command
Code:

ls (hd1,2)/
and so on

If (hd1,2) has Grub2 inside you can fire it up with
Code:

set root=(hd1,2)
configfile /boot/grub/grub.cfg


muckybucket 06-22-2010 08:34 AM

Sounds like I'll have to pull the disk. :(

The grub was on a partition that was removed...

saikee 06-22-2010 10:51 AM

Ever consider a USB floppy drive?

muckybucket 06-22-2010 11:10 AM

I haven't got one, but surely if it can't see a USB drive or CD this wouldn't work either?

Anyway, I have pulled the drive and hooked it up to another machine, hopefully I can get it sorted this way.

BewilderedStranger 01-04-2011 07:24 PM

http://www.makeuseof.com/tag/how-to-...t-environment/
This will save you i hope. It saved me haha. I did the same thing got aggrivated with ubuntu after trying for months to install and I deleted the partitions obviously killing my mbr.


All times are GMT -5. The time now is 12:20 PM.