Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Grub rescue/Grub on boot? no problem filter_list
Author
Message
Grub rescue/Grub on boot? no problem #1
So all of you who use any type of linux know what Grub is. Sometimes it breaks or lose it modules,so you get on boot command line like "Grub:>" or "Grub rescue:>".



A) When you'll see this command line on boot?
- when you delete or format any OS partition
- when you delete grub module or partition

B) What should you do first?
- You can try to boot windows,ubuntu,backtrack or kali live cd and fix it
- If you're for some reason unable to boot from live CD or USB continue to read this thread

C) How to fix grub by booting one of mentioned OS with live CD or USB

First of all if you dont know how to boot Live CD,you have to get in your BIOS, every machine manufacturer has it own keys,usually it's F2,ESC,ESC,DELETE,F12 key (usually you can read it on a very first screen which appears when you power on your machine) if it's not in your BIOS settings,fast boot is ON,you can change it latter. Also if one of mentioned keys aren't working you can check on google which key is for your PC.

1) Using WINDOWS

1]a) Windows 7 / 8

Boot your windows live CD and wait for this screen

[Image: screenshot2hvo.jpg]
[Image: screenshot1wv.jpg]

- Click on Repair your computer and then you gotta chose on which partition your windows installation is
-Click next and wait for next screen, now chose Command prompt

[Image: screenshot3axi.jpg]

type in:
Code:
bootrec.exe fixboot
          bootrec.exe fixmbr

-reboot and your windows are going to boot,now continue read how to fix your grub if you want, this step is made for people which want to delete their linux and grub parition and keep only windows

1]b) WINDOWS XP
once you reached GUI hit shift-f10 and type fixmbr..thats all....if that isn't working repair windows atuomatically..


2] UBUNTU/BACKTRACK

TIPS:

a)You need to boot the CD with same version of grub which you want to repair...

b)Running "update-grub" from the Live CD will NOT update the grub.cfg file of the normal installation. If the grub.cfg file is damaged or missing, the user should use the chroot procedure to update the grub.cfg file.

c)Include "sudo" in each command line in this process


keep those tips in mind!
Let's get started!

1) Open terminal in your booted Live CD

2)
Code:
sudo fdisk -l

[Image: screenshot4re.jpg]

- This command is going to show you all partitions on your HDD

3) In last picture you've seen what is going to be your output. In line where is only Linux typed in last column is the position of your Ubuntu/backtrack on your hard drive...in my screenshot its dev/sda1

Now lets mount that partition where the linux is installed

Code:
sudo mount /dev/sdXX /mnt /   (don't miss spaces...in my example its /dev/sd1

4) This step is for all of you which have separate boot partition

Code:
sudo mount /dev/sdYY /mnt

5) Mount the virtual file systems

Code:
sudo mount --bind /dev /mnt/dev
            sudo mount --bind /proc /mnt/proc
            sudo mount --bind /sys /mnt/sys

6) This step is important cuz it will make you sure only grub modules and packages are going to get executed from live CD

Code:
sudo mount --bind /usr/ /mnt/usr
     sudo chroot /mnt

if there is no grub.cfg file just run update-grub or grub2 depending which one you have

7) Now we've done all to prepare reinstallation,now you can run these commands

Code:
grub-install /dev/sdX


DO NOT TYPE PARTITION NUMBER ONLY THE LATTER (EX. sdA or sdB etc)

8)Verify the install by typing these commands

Code:
sudo grub-install --recheck /dev/sdX

9) Before this step exit chroot by pressing ctrl-d

Unmount all virtual filesystems you used for this fix

Code:
sudo umount /mnt/dev
           sudo umount /mnt/proc
           sudo umount /mnt/sys

ONLY IF YOU USED SEPARATE PARTITIONS you need to type and "sudo umount /mnt/boot"

10)Unmount live cd and last device and reboot

Code:
sudo umount /mnt/usr
           sudo umount /mnt
           reboot


and that would be all about fixing Live CD or USB.



D) How to fix GRUB from a grub rescue prompt or grub prompt (ONLY IF YOU'RE UNABLE TO BOOT LIVE CD)

1) Why would you be unable to boot from live CD or USB?

People say "Shit happens" yea and thats true,i had a case when my laptop hibernated exactly when i deleted grub partition so i get stucked in here, my case was the worst one...

1)a) extra informations which are good to know

When your PC hibernate you cant get in your BIOS by pressing anything, cuz hibernate state, S4, does not fully turn off power to the machine. Yes, the computer looks completely off, no lights or sounds, and even a firmware loading screen is presented on “power on”, but it is sucking tiny bit of energy (see ACPI spec v5 16.1.4). Somewhere, maybe in some modified ACPI tables but I’m not sure, windows hibernate tells the firmware to just boot directly to the device window hibernated to.

2) How to fix directly from grub rescue prompt or grub prompt

What is grub rescue prompt?
So grub rescue promp is very very limited part of grub,it usually appears when you delete grub partition or ubuntu/backtrack partition...if you delete grub partition it wont even recognize basic commands.

[Image: screenshot5ke.jpg]

Now lets get started:

First of all type

Code:
ls

as output you'l get something like (hd0,1)(hd0)(hd0,2)...
these are the partitions on your PC, in this fixing tutorial you need to find on which one your linux is
i'm going to use X,Y instead of 0,1 etc cuz everyone has a different numbers to type

Let me explain you all the commands we're going to use before we start just to inform you what exactly are we going to do.

ls - This will display the known drives/partitions. (your ubuntu/backtrack partition will be formated with (hdX,Y)

[Image: screenshot6az.jpg]

ls (hdX,Y)/boot/grub - This step is going to show you where your grub partition is on your linux partition.So it's used to search all over partition,you can type what ever folder you want.Try each partition (hd0,1), etc. until you find your grub folder.

set root - its going to set where your ubuntu is
set prefix .-its going to set where your grub folder is
unset root/prefix -if you made mistake
set- check options which you typed

Now lets use those commands:

Code:
ls
        ls (hdX,Y)/boot/grub
        set root=(hdX,Y)
        set prefix=(hdX,Y)/boot/grub
        insmod linux/normal/fat/ntfs/ntfscomp/minicmd (type one of those /./././, thats module which you want to load (for ubuntu use any except minicmd)



if you get any error try with

Code:
insmod /boot/grub/linux.mod

now lets load kernel and initrd immage

Code:
linux /vmlinuz root=/dev/sdXY ro
          nitrd /boot/initrd.img-<kernel version>

instead of XY type for example sda1 or whatever partition you've found with ls these modules

for example:
linux /boot/vmlinuz-1.9.21-12-generic root=/dev/sda1 ro
initrd /boot/initrd-1.9.21-12-generic

now boot your system
Code:
boot

[Image: screenshot7aw.jpg]

now fix the grub like i explained before...

E) If you can't fix your problem with those options i mentioned before you have to do one of the following:

a) Disassemble your PC/laptop and find CMOS batter,put it out for 10 seconds (to reset your BIOS settings),and then turn on your PC
b) Put your hard drive in another PC and fix the problem with one of the steps i mentioned before


Thank for your time reading this Smile
Grades doesn't measure intelligence and age doesn't define maturity

Reply

RE: Grub rescue/Grub on boot? no problem #2
Nice detailed thread but I think you forgot to mention the most helpful and time saving tool that is Boot Repair (If you can with CD or USB ) Smile
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Grub rescue/Grub on boot? no problem #3
That tool you can use in windows or linux, this thread is made for people who cant access to their OS ^^
You mentioned that tool in the first comment so people will see that and easly google for tut how to use it...if you really want i can add it to thread Smile

Update: maybe i'm wrong with that boot repair program cuz never used it ^^
Grades doesn't measure intelligence and age doesn't define maturity

Reply







Users browsing this thread: 1 Guest(s)