The general idea is to:
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:
(hd0,1)/vmlinuz
- for Debian-like distros that place the kernel in the root(hd0,1)/boot/vmlinuz-4.4-xen
- for Xen that places the kernel under /boot/
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:
(hd0,1)/initrd.img
- for Debian, or perhaps,(hd0,1)/boot/initrd-4.4-xen.img
- for XenWhen you locate the files, let's assume you picked:
(hd0,1)/boot/vmlinuz-4.4-xen
for the kernel, and(hd0,1)/boot/initrd-4.4-xen.img
for the initrd imagethen 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.
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.
To boot from a grub rescue shell, you have to load two modules before any command:
normal
linux
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.
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.