Table of Contents

Boot from Grub Console

The general idea is to:

  1. locate the boot partition
  2. local the grub module for the boot partition filesystem
  3. load the kernel and specify the root partition
  4. load initrd
  5. boot

From the grub command prompt, you would issue:

ls 

which should list something like:

(hd0) (hd0,msdos2) (hd0,msdos1)

where (hd0) is a drive and (hd0,msdos2) and (hd0,msdos1) means that (hd0) has the old style MBR partition table - output will be similar for GPT partition tables.

Next would be to load the filesystem module:

insmod ext2

in this case, the ext module is loaded but his may differ depending on (hd0).

Now with the module loaded, the filesystem can be probed:

ls (hd0,1)/

The purpose is to locate:

this can usually be in, like:

You will have to search for the image using ls - especially if you have no clue where the kernel is placed. The same applies to the initrd image:

When you locate the files, let's assume you picked:

then you would issue:

set root=(hd0,1)

to instruct grub to change the root into the first partition of drive (hd0).

Now you specify the kernel image and the initrd image:

linux /boot/vmlinuz-4.4-xen root=/dev/sda1
initrd /boot/initrd-4.4-xen.img

where /dev/sda1 is the device where the filesystem is located. Note that some installs can have a separate boot partition and that the general guideline for mappings is: /dev/sda1 for (hd0,1), /dev/sda2 for (hd0,2), etc… However, this is kernel-dependent so there will be some amount of guesswork involved.

Finally, issue:

boot

and grub should boot.

Boot in Single User Mode

To boot in single user mode, you would just have to change the line:

linux /boot/vmlinuz-4.4-xen root=/dev/sda1

and append the run-level number to that line, as in:

linux /boot/vmlinuz-4.4-xen root=/dev/sda1 1

where 1 stands for run-level 1, meaning single-user mode.

In single user mode you can reset the root password if need be. If that does not work, you can try:

linux /boot/vmlinuz-4.4-xen root=/dev/sda1 init=/bin/bash

which should load up /bin/bash instead so you can type passwd and reset the root password.

Boot from Grub Rescue

To boot from a grub rescue shell, you have to load two modules before any command:

For instance, the example above would be transformed into:

set prefix=(hd0,1)/boot/grub
insmod ext2
set root=(hd0,1)

to set the prefix to the grub image and switch the root to (hd0,1), followed by:

insmod normal
normal
insmod linux

and then specify the path to the the kernel and initrd image:

linux /boot/vmlinuz-4.4-xen root=/dev/sda1
initrd /boot/initrd-4.4-xen.img

Then to boot, finally issue:

boot

Note that tab completion should work after loading normal and linux modules.