Sunday, March 29, 2015

Grub Rescue



 In grub you will see a prompt like this.

grub and grub rescue has slight variations in commands.If you have grub-rescue shell,skip to the end.

grub>

grub> set pager=1

no space between = and 1;it invokes pager for large command outputs.

grub> ls
(hd0) (hd0,msdos2) (hd0,msdos1)

The ls commands shows all partitions.This may vary from computer to computer.
But you will see similar listing of partitions

grub> ls (hd0,1)/


lost+found/ bin/ boot/ cdrom/ dev/ etc/ home/  lib/
lib64/ media/ mnt/ opt/ proc/ root/ run/ sbin/
srv/ sys/ tmp/ usr/ var/ vmlinuz vmlinuz.old
initrd.img initrd.img.old

ls on every partition till you find an output like this.This is the root file system.

grub> cat (hd0,1)/etc/issue
Ubuntu 14.04 LTS \n \l

Use cat to read etc file to dermine the linux if you have multiple linuxes.


Booting From grub>

if root file system is on (hd0,1) and vmlinuz-3.13.0-29-generic(The third line sets the initrd file, which must be the same version number as the kernel.).
And if you have (hd0,1) then root=/dev/sda1;
If you have hd0,1 = /dev/sda1. hd1,1 = /dev/sdb1. hd3,2 = /dev/sdd2.


grub> set root=(hd0,1)
grub> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
grub> initrd /boot/initrd.img-3.13.0-29-generic
grub> boot


If this didn't work then,try these.

grub> set root=(hd0,1)
grub> linux /vmlinuz root=/dev/sda1
grub> initrd /initrd.img
grub> boot


But if you are on grub rescue then commands vary

grub rescue> set prefix=(hd0,1)/boot/grub
grub rescue> set root=(hd0,1)
grub rescue> insmod normal
grub rescue> normal
grub rescue> insmod linux
grub rescue> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
grub rescue> initrd /boot/initrd.img-3.13.0-29-generic
grub rescue> boot



Making Permanent Repairs

When you have successfully booted your system, run these commands to fix GRUB permanently:

Caution: Third Line from bottom grub-install /dev/sda.Don't use sda1 or anyother number after it.you
may use sdb but don't include any number


# update-grub
Generating grub configuration file ...
Found background: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
Found background image: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
Found linux image: /boot/vmlinuz-3.13.0-29-generic
Found initrd image: /boot/initrd.img-3.13.0-29-generic
Found linux image: /boot/vmlinuz-3.13.0-27-generic
Found initrd image: /boot/initrd.img-3.13.0-27-generic
Found linux image: /boot/vmlinuz-3.13.0-24-generic
Found initrd image: /boot/initrd.img-3.13.0-24-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.










Learn python for fun.The popular blog with questions and answers to the python.Solutions to facebookhackercup,codejam,codechef.The fun way to learn python with me.Building some cool apps.

No comments:

Post a Comment