GRUB_2_SHELL

GRUB_2_SHELL

GRUB 2 Command Shell

The GRUB 2 command shell is just as powerful as the shell in legacy GRUB. You can use it to discover boot images, kernels, and root filesystems. In fact, it gives you complete access to all file systems on the local machine regardless of permissions or other protections. Which some might consider a security hole, but you know the old Unix dictum: whoever has physical access to the machine owns it.

When you're at the grub> prompt, you have a lot of functionality similar to any command shell such as history and tab-completion. The grub rescue> mode is more limited, with no history and no tab-completion.

The first command you should run invokes the pager, for paging long command outputs:

grub> set pager=1

With ls command we can see available hard disk. In given output “hd0” is hard drive and “msdos1 to 3” are three partition.

Using ls command we can see content of particular partition. In given example we can see content of “msdos1” partition which is look like output of “/boot” partition because in the list we can see “grub2” directory and kernel images. Also initrd images.   

In this output “hd0,msdos3” is “root” partition and “hd0,msdos2” is most probe swap.

We can also use cat command to see any file content.

 

Booting From grub>

This is how to set the boot files and boot the system from the grub> prompt. We know from running the ls command that there is a Linux root filesystem on (hd0,1), and you can keep searching until you verify where /boot/grub is. Then run these commands, using your own root partition, kernel, and initrd image:

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

Booting From grub-rescue>

If you're in the GRUB rescue shell the commands are different, and you have to load the normal.mod andlinux.mod modules:

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

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *