2017-12-13 11:45:40 +00:00
= Using the GRUB2 boot prompt
[[using-the-grub-2-boot-prompt]]
If improperly configured, *GRUB2* may fail to load and subsequently drop
2023-01-14 10:35:47 +00:00
to a boot prompt. To boot into the system, follow the steps below.
.Procedure
2017-12-13 11:45:40 +00:00
. List the drives which *GRUB2* sees:
+
----
2023-01-14 10:35:47 +00:00
grub> ls
2017-12-13 11:45:40 +00:00
----
2017-12-13 13:33:56 +00:00
. Examine the output to understand the partition table of the `/dev/sda` device. The following example shows a DOS partition table with three partitions:
2017-12-13 11:45:40 +00:00
+
----
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)
----
+
2017-12-13 13:33:56 +00:00
A GPT partition table of the `/dev/sda` device with four partitions could look like this:
2017-12-13 11:45:40 +00:00
+
----
(hd0) (hd0,gpt4) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1)
----
. Probe each partition of the drive and locate your `vmlinuz` and `initramfs` files.
+
----
2023-01-14 10:35:47 +00:00
grub> ls (hd0,1)/
2017-12-13 11:45:40 +00:00
----
+
2017-12-13 13:33:56 +00:00
The outcome of the previous command will list the files on `/dev/sda1`. The partition that contains the `/boot` directory is the correct one. There you will search for the full names of the `vmlinuz` and `initramfs` files.
2017-12-13 11:45:40 +00:00
2023-01-14 10:35:47 +00:00
. Follow the <<btrfs-boot-setup, Pre-boot setup for BTRFS>> (Fedora 33 or newer) or the <<lvm-boot-setup, Pre-boot setup for LVM>> (older than Fedora 33) to recover your system.
. After the pre-boot setup, boot the system.
2023-01-07 13:55:33 +00:00
+
2023-01-14 10:35:47 +00:00
----
grub> boot
----
. To restore the bootloader's functionality, regenerate the *GRUB2* configuration file and reinstall the bootloader into the MBR, as described in xref:adding-other-operating-systems-grub2[Adding other operating systems to the *GRUB2* menu].
[[btrfs-boot-setup]]
== Pre-boot setup for BTRFS filesystems.
2023-01-07 13:55:33 +00:00
* On BIOS systems:
+
2023-01-14 10:35:47 +00:00
Set *GRUB2* root to your `/boot` partition. If your `/boot` partition is `(hd0,msdos1)`, the command will be:
2023-01-07 13:55:33 +00:00
+
----
2023-01-14 10:35:47 +00:00
grub> set root=(hd0,msdos1)
2023-01-07 13:55:33 +00:00
----
2023-01-14 10:35:47 +00:00
Next, select the desired kernel. Set the `/root` partition (e.g. `/dev/sda2`):
2023-01-07 13:55:33 +00:00
+
----
2023-01-14 10:35:47 +00:00
grub> linux /vmlinuz-5.14.10-300.fc35.x86_64 root=/dev/sda2 ro rootflags=subvol=root
2023-01-07 13:55:33 +00:00
----
+
* On UEFI systems:
+
2023-01-14 10:35:47 +00:00
Set *GRUB2* root to your EFI system partition. If your EFI system partition is `(hd0,gpt1)`, the command will be:
2023-01-07 13:55:33 +00:00
+
----
2023-01-14 10:35:47 +00:00
grub> set root=(hd0,gpt1)
2023-01-07 13:55:33 +00:00
----
2023-01-14 10:35:47 +00:00
Next, select the desired kernel. Find the path to `vmlinuz` and set the `/root` partition (e.g. `/dev/sda3`):
2023-01-07 13:55:33 +00:00
+
----
2023-01-14 10:35:47 +00:00
grub> linux (hd0,gpt2)/vmlinuz-5.14.10-300.fc35.x86_64 root=/dev/sda3 ro rootflags=subvol=root
2023-01-07 13:55:33 +00:00
----
+
Select the RAM filesystem that will be loaded:
+
----
2023-01-14 10:35:47 +00:00
grub> initrd (hd0,gpt2)/initramfs-5.14.10-300.fc35.x86_64.img
2023-01-07 13:55:33 +00:00
----
2023-01-14 10:35:47 +00:00
[[lvm-boot-setup]]
== Pre-boot setup for LVM filesystems.
2023-01-07 13:55:33 +00:00
Load the `xfs` and `lvm` modules if they are not already loaded (check this with `lsmod`):
2017-12-13 11:45:40 +00:00
----
2023-01-14 10:35:47 +00:00
grub> insmod xfs
grub> insmod lvm
2017-12-13 11:45:40 +00:00
----
2023-01-07 13:55:33 +00:00
* On BIOS systems:
+
2023-01-14 10:35:47 +00:00
Set *GRUB2* root to your `/boot` partition. If your `/boot` partition is `(hd0,msdos1)`, the command will be:
2023-01-07 13:55:33 +00:00
+
----
2023-01-14 10:35:47 +00:00
grub> set root=(hd0,msdos1)
2023-01-07 13:55:33 +00:00
----
2023-01-14 10:35:47 +00:00
Next, select the desired kernel. Set `root` to the logical volume that corresponds to the `/root` directory:
2017-12-13 11:45:40 +00:00
+
----
2023-01-14 10:35:47 +00:00
grub> linux /vmlinuz-3.0.0-1.fc16.i686 root=/dev/mapper/fedora_localhost--live-root
2017-12-13 11:45:40 +00:00
----
2023-01-07 13:55:33 +00:00
+
Select the RAM filesystem that will be loaded:
+
----
2023-01-14 10:35:47 +00:00
grub> initrd /initramfs-3.0.0-1.fc16.i686.img
2023-01-07 13:55:33 +00:00
----
+
2017-12-13 11:45:40 +00:00
2023-01-07 13:55:33 +00:00
* On UEFI systems:
+
2023-01-14 10:35:47 +00:00
Set *GRUB2* root to your EFI system partition. If your EFI system partition is `(hd0,gpt1)`, the command will be:
2023-01-07 13:55:33 +00:00
+
----
set root=(hd0,gpt1)
----
2023-01-14 10:35:47 +00:00
Next, select the desired kernel. Find the path to `vmlinuz` and set `root` to the logical volume that corresponds to the `/root` directory:
2023-01-07 13:55:33 +00:00
+
----
linux (hd0,gpt2)/vmlinuz-3.0.0-1.fc16.i686 root=/dev/mapper/fedora_localhost--live-root
----
+
Select the RAM filesystem that will be loaded:
2017-12-13 11:45:40 +00:00
+
----
2023-01-07 13:55:33 +00:00
initrd (hd0,gpt2)/initramfs-3.0.0-1.fc16.i686.img
2017-12-13 11:45:40 +00:00
----