Next, find kernel and, for Linux, an initramfs image. Let's see if
search
will work:
grub> search --file /vmlinuz
grub> echo $root
hd0,gpt2
By default, search will write its result to
root variable, but this behaviour can be changed with
--set option if needed.
If you got a result, you can proceed to step 3. If you instead ended
up with an error or an empty variable:
grub> search --file /vmlinuz
error: no such device: vmlinuz
grub> echo $root
grub>
You can retry with a different file paths, for example:
grub> search --file /boot/vmlinuz-linux
This one is used by my Arch Linux installation. For Linux, if
everything from [/boot]/vmlinuz[-linux][.old] fails, switch
to manual search. Find available disks with ls:
grub> ls
(proc) (lvm/root) (lvm/swap) (hd0) (hd0,gpt2) (hd0,gpt1)
Now, for each listed device, execute ls (disk)/.
Note the trailing slash. You are looking for any kernel-like and
boot-like entries, check subdirectories if needed. When found, set
root=:
grub> ls (lvm/root)/
bin boot/ dev/ efi/ etc/ home/ lib lib64 lost+found/ media/ mnt/ opt/
proc/ root/ run/ sbin srv/ sys/ tmp/ usr/ var/
grub> ls (lvm/root)/boot
amd-ucode.img grub/ initramfs-linux-fallback.img initramfs-linux.img
vmlinuz-linux
grub> set root=(lvm/root)
Next step is to run appropriate loader commands. For Linux, use
linux and initrd, in this order. For BSD,
see one of k{free,net,open}bsd together with accompanying
commands.
First, use linux to select kernel image; path is relative
to root. Provide
command-line parameters,
too. The simplest version is:
grub> linux root=/dev/mapper/root ro
This time root= is for the kernel. If you don't know
this path, you can proceed without providing anything. In this case,
startup will fail and drop to a shell. Here, you can proceed with the
boot manually or find the path to the root disk under /dev tree, write
it down, reboot, and provide it to the kernel.
Second, use initrd to select initramfs image. You don't
need to provide any special arguments this time. Path that is relative
to GRUB's root is enough:
grub> initrd /boot/initramfs-linux.img
Let me repeat, these two commands must be run in this order.
Executing linux will reset initrd state.