mirror of
https://pagure.io/fedora-docs/quick-docs.git
synced 2024-11-28 14:56:35 +00:00
Updated merged GRUB articles for style guidelines
This commit is contained in:
parent
b7fcdc170b
commit
30cb9fa5db
2 changed files with 104 additions and 105 deletions
|
@ -22,69 +22,72 @@ bootable by *GRUB2*.
|
|||
|
||||
. Open the terminal.
|
||||
|
||||
. Examine the partition layout and identify the `boot` and the `root` partition.
|
||||
. Examine the partition layout and identify the `/boot` and the `/root` partition.
|
||||
+
|
||||
----
|
||||
sudo fdisk -l
|
||||
# fdisk -l
|
||||
----
|
||||
|
||||
== BTRFS filesystem
|
||||
. Follow the <<btrfs-steps, BTRFS steps>> (Fedora 33 or newer) or <<lvm-steps, LVM steps>> (older than Fedora 33) to recover your system.
|
||||
|
||||
If your `root` partition is encrypted by LUKS, it must be decrypted:
|
||||
[[btrfs-steps]]
|
||||
== BTRFS steps
|
||||
|
||||
If your `/root` partition is encrypted by LUKS, it must be decrypted:
|
||||
|
||||
. Make sure the crypt module is in use:
|
||||
+
|
||||
----
|
||||
sudo modprobe dm-crypt
|
||||
# modprobe dm-crypt
|
||||
----
|
||||
|
||||
. Decrypt the `root` partition:
|
||||
. Decrypt the `/root` partition (e.g. `/dev/sda3`):
|
||||
+
|
||||
----
|
||||
sudo cryptsetup luksOpen <root_partition> myvolume
|
||||
# cryptsetup luksOpen /dev/sda3 myvolume
|
||||
----
|
||||
+
|
||||
The decrypted device (i.e. `myvolume`) will be accessible under `/dev/mapper/`.
|
||||
|
||||
Mount the `root` partition:
|
||||
Mount the `/root` partition:
|
||||
|
||||
* For LUKS:
|
||||
+
|
||||
----
|
||||
mount <decrypted_device> /mnt -o subvol=root
|
||||
# mount /dev/mapper/myvolume /mnt -o subvol=root
|
||||
----
|
||||
* For non-LUKS:
|
||||
+
|
||||
----
|
||||
mount <root_partition> /mnt -o subvol=root
|
||||
# mount /dev/sda3 /mnt -o subvol=root
|
||||
----
|
||||
|
||||
Mount the `boot` partition:
|
||||
Mount the `/boot` partition (e.g. `/dev/sda2)`:
|
||||
|
||||
----
|
||||
mount <boot_partition> /mnt/boot
|
||||
# mount /dev/sda2 /mnt/boot
|
||||
----
|
||||
|
||||
Mount system processes and devices into the `root` filesystem:
|
||||
Mount system processes and devices into the `/root` filesystem:
|
||||
|
||||
----
|
||||
mount -o bind /dev /mnt/dev
|
||||
mount -o bind /proc /mnt/proc
|
||||
mount -o bind /sys /mnt/sys
|
||||
mount -o bind /run /mnt/run
|
||||
# mount -o bind /dev /mnt/dev
|
||||
# mount -o bind /proc /mnt/proc
|
||||
# mount -o bind /sys /mnt/sys
|
||||
# mount -o bind /run /mnt/run
|
||||
----
|
||||
|
||||
On UEFI systems, bind the efivars directory and mount the EFI system partition:
|
||||
On UEFI systems, bind the `efivars` directory and mount the EFI system partition (e.g. `/dev/sda1`):
|
||||
|
||||
----
|
||||
mount -o bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
|
||||
mount <efi_system_partition> /mnt/boot/efi
|
||||
# mount -o bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
|
||||
# mount /dev/sda1 /mnt/boot/efi
|
||||
----
|
||||
|
||||
Change your filesystem to the one mounted under `/mnt/`:
|
||||
|
||||
----
|
||||
chroot /mnt/
|
||||
# chroot /mnt/
|
||||
----
|
||||
|
||||
Re-install GRUB:
|
||||
|
@ -92,109 +95,103 @@ Re-install GRUB:
|
|||
* On UEFI systems, several packages are required:
|
||||
+
|
||||
----
|
||||
dnf reinstall shim-* grub2-efi-* grub2-common
|
||||
/]# dnf reinstall shim-* grub2-efi-* grub2-common
|
||||
|
||||
----
|
||||
* On BIOS systems, specify the disk where GRUB should be installed:
|
||||
* On BIOS systems, specify the disk (e.g. `/dev/sda`) where GRUB should be installed:
|
||||
+
|
||||
----
|
||||
grub2-install <disk>
|
||||
/]# grub2-install /dev/sda
|
||||
----
|
||||
|
||||
Re-generate the GRUB configuration file:
|
||||
|
||||
----
|
||||
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
/]# grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
----
|
||||
|
||||
Sync and exit the chroot:
|
||||
|
||||
----
|
||||
sync && exit
|
||||
/]# sync && exit
|
||||
----
|
||||
|
||||
Reboot the system.
|
||||
|
||||
== LVM filesystem
|
||||
[[lvm-steps]]
|
||||
== LVM steps
|
||||
|
||||
If your `root` partition is encrypted by LUKS, it must be decrypted:
|
||||
If your `/root` partition is encrypted by LUKS, it must be decrypted:
|
||||
|
||||
. Make sure the crypt module is in use:
|
||||
+
|
||||
----
|
||||
sudo modprobe dm-crypt
|
||||
# modprobe dm-crypt
|
||||
----
|
||||
|
||||
. Decrypt the `root` partition:
|
||||
. Decrypt the `/root` partition (e.g. `/dev/sda3`):
|
||||
+
|
||||
----
|
||||
sudo cryptsetup luksOpen <root_partition> myvolume
|
||||
# cryptsetup luksOpen /dev/sda3 myvolume
|
||||
----
|
||||
|
||||
. Scan the LVM volumes for the volume group corresponding to the `root` partition:
|
||||
. Scan the LVM volumes for the volume group corresponding to the `/root` partition:
|
||||
+
|
||||
----
|
||||
sudo vgscan
|
||||
# vgscan
|
||||
----
|
||||
|
||||
. Activate the volume group:
|
||||
. Activate the volume group (e.g. `fedora_localhost-live`):
|
||||
+
|
||||
----
|
||||
sudo vgchange -ay <volume_group>
|
||||
# vgchange -ay fedora_localhost-live
|
||||
----
|
||||
|
||||
. Find the root volume:
|
||||
. Find the logical volume corresponding to `/root`:
|
||||
+
|
||||
----
|
||||
sudo lvs
|
||||
# lvs
|
||||
----
|
||||
+
|
||||
The root volume will be accessible under `/dev/`.
|
||||
The logical volume will be accessible under `/dev/mapper/`.
|
||||
|
||||
Create a `root` directory under `/mnt`:
|
||||
----
|
||||
mkdir -p /mnt/root
|
||||
# mkdir -p /mnt/root
|
||||
----
|
||||
|
||||
Mount the logical volume of the `root` partition:
|
||||
|
||||
* For LUKS, substitute the root volume from above:
|
||||
+
|
||||
----
|
||||
mount <root_volume> /mnt/root
|
||||
----
|
||||
* For non-LUKS, use `lsblk` to find the `lvm` that corresponds to the `root` partition (the `lvm` should be under `/dev/mapper/`):
|
||||
+
|
||||
----
|
||||
mount <lvm> /mnt/root
|
||||
----
|
||||
|
||||
Mount the `boot` partition:
|
||||
Mount the logical volume (e.g. `/dev/mapper/fedora_localhost--live-root`) corresponding to the `/root` partition:
|
||||
|
||||
----
|
||||
mount <boot_partition> /mnt/root/boot
|
||||
# mount /dev/mapper/fedora_localhost--live-root /mnt/root
|
||||
----
|
||||
|
||||
Mount system processes and devices into the `root` filesystem:
|
||||
Mount the `/boot` partition (e.g. `/dev/sda2`):
|
||||
|
||||
----
|
||||
mount -o bind /dev /mnt/root/dev
|
||||
mount -o bind /proc /mnt/root/proc
|
||||
mount -o bind /sys /mnt/root/sys
|
||||
mount -o bind /run /mnt/root/run
|
||||
# mount /dev/sda2 /mnt/root/boot
|
||||
----
|
||||
|
||||
On UEFI systems, bind the efivars directory and mount the EFI system partition:
|
||||
Mount system processes and devices into the `/root` filesystem:
|
||||
|
||||
----
|
||||
mount -o bind /sys/firmware/efi/efivars /mnt/root/sys/firmware/efi/efivars
|
||||
mount <efi_system_partition> /mnt/root/boot/efi
|
||||
# mount -o bind /dev /mnt/root/dev
|
||||
# mount -o bind /proc /mnt/root/proc
|
||||
# mount -o bind /sys /mnt/root/sys
|
||||
# mount -o bind /run /mnt/root/run
|
||||
----
|
||||
|
||||
On UEFI systems, bind the `efivars` directory and mount the EFI system partition (e.g. `/dev/sda1`):
|
||||
|
||||
----
|
||||
# mount -o bind /sys/firmware/efi/efivars /mnt/root/sys/firmware/efi/efivars
|
||||
# mount /dev/sda1 /mnt/root/boot/efi
|
||||
----
|
||||
|
||||
Change your filesystem to the one mounted under `/mnt/root`:
|
||||
|
||||
----
|
||||
chroot /mnt/root/
|
||||
# chroot /mnt/root/
|
||||
----
|
||||
|
||||
Re-install GRUB and re-generate the GRUB configuration file:
|
||||
|
@ -202,20 +199,20 @@ Re-install GRUB and re-generate the GRUB configuration file:
|
|||
* On UEFI systems, several packages are required:
|
||||
+
|
||||
----
|
||||
dnf reinstall shim-* grub2-efi-* grub2-common
|
||||
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
|
||||
/]# dnf reinstall shim-* grub2-efi-* grub2-common
|
||||
/]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
|
||||
----
|
||||
* On BIOS systems, specify the disk where GRUB should be installed:
|
||||
* On BIOS systems, specify the disk (e.g. `/dev/sda`) where GRUB should be installed:
|
||||
+
|
||||
----
|
||||
grub2-install <disk>
|
||||
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
/]# grub2-install /dev/sda
|
||||
/]# grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
----
|
||||
|
||||
Sync and exit the chroot:
|
||||
|
||||
----
|
||||
sync && exit
|
||||
/]# sync && exit
|
||||
----
|
||||
|
||||
Reboot the system.
|
|
@ -2,12 +2,14 @@
|
|||
[[using-the-grub-2-boot-prompt]]
|
||||
|
||||
If improperly configured, *GRUB2* may fail to load and subsequently drop
|
||||
to a boot prompt. To boot into the system, proceed as follows:
|
||||
to a boot prompt. To boot into the system, follow the steps below.
|
||||
|
||||
.Procedure
|
||||
|
||||
. List the drives which *GRUB2* sees:
|
||||
+
|
||||
----
|
||||
grub2> ls
|
||||
grub> ls
|
||||
----
|
||||
|
||||
. Examine the output to understand the partition table of the `/dev/sda` device. The following example shows a DOS partition table with three partitions:
|
||||
|
@ -25,85 +27,94 @@ A GPT partition table of the `/dev/sda` device with four partitions could look l
|
|||
. Probe each partition of the drive and locate your `vmlinuz` and `initramfs` files.
|
||||
+
|
||||
----
|
||||
ls (hd0,1)/
|
||||
grub> ls (hd0,1)/
|
||||
----
|
||||
+
|
||||
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.
|
||||
|
||||
. Pre-boot procedure for BTRFS filesystems.
|
||||
. 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.
|
||||
+
|
||||
----
|
||||
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.
|
||||
|
||||
* On BIOS systems:
|
||||
+
|
||||
Set *GRUB2* root to your boot partition. If your boot partition is `(hd0,msdos1)`, the command will be:
|
||||
Set *GRUB2* root to your `/boot` partition. If your `/boot` partition is `(hd0,msdos1)`, the command will be:
|
||||
+
|
||||
----
|
||||
set root=(hd0,msdos1)
|
||||
grub> set root=(hd0,msdos1)
|
||||
----
|
||||
Next, select the desired kernel. Set the root partition (e.g. `/dev/sda2`):
|
||||
Next, select the desired kernel. Set the `/root` partition (e.g. `/dev/sda2`):
|
||||
+
|
||||
----
|
||||
linux /vmlinuz-5.14.10-300.fc35.x86_64 root=/dev/sda2 ro rootflags=subvol=root
|
||||
grub> linux /vmlinuz-5.14.10-300.fc35.x86_64 root=/dev/sda2 ro rootflags=subvol=root
|
||||
----
|
||||
+
|
||||
|
||||
* On UEFI systems:
|
||||
+
|
||||
Set *GRUB2* root to your EFI system partition. If your EFI partition is `(hd0,gpt1)`, the command will be:
|
||||
Set *GRUB2* root to your EFI system partition. If your EFI system partition is `(hd0,gpt1)`, the command will be:
|
||||
+
|
||||
----
|
||||
set root=(hd0,gpt1)
|
||||
grub> set root=(hd0,gpt1)
|
||||
----
|
||||
Next, select the desired kernel. Find the path to `vmlinuz` and set the root partition (e.g. `/dev/sda3`):
|
||||
Next, select the desired kernel. Find the path to `vmlinuz` and set the `/root` partition (e.g. `/dev/sda3`):
|
||||
+
|
||||
----
|
||||
linux (hd0,gpt2)/vmlinuz-5.14.10-300.fc35.x86_64 root=/dev/sda3 ro rootflags=subvol=root
|
||||
grub> linux (hd0,gpt2)/vmlinuz-5.14.10-300.fc35.x86_64 root=/dev/sda3 ro rootflags=subvol=root
|
||||
----
|
||||
+
|
||||
Select the RAM filesystem that will be loaded:
|
||||
+
|
||||
----
|
||||
initrd (hd0,gpt2)/initramfs-5.14.10-300.fc35.x86_64.img
|
||||
grub> initrd (hd0,gpt2)/initramfs-5.14.10-300.fc35.x86_64.img
|
||||
----
|
||||
+
|
||||
|
||||
. Pre-boot procedure for LVM filesystems.
|
||||
+
|
||||
[[lvm-boot-setup]]
|
||||
== Pre-boot setup for LVM filesystems.
|
||||
|
||||
Load the `xfs` and `lvm` modules if they are not already loaded (check this with `lsmod`):
|
||||
+
|
||||
----
|
||||
insmod xfs
|
||||
insmod lvm
|
||||
grub> insmod xfs
|
||||
grub> insmod lvm
|
||||
----
|
||||
+
|
||||
|
||||
* On BIOS systems:
|
||||
+
|
||||
Set *GRUB2* root to your boot partition. If your boot partition is `(hd0,msdos1)`, the command will be:
|
||||
Set *GRUB2* root to your `/boot` partition. If your `/boot` partition is `(hd0,msdos1)`, the command will be:
|
||||
+
|
||||
----
|
||||
set root=(hd0,msdos1)
|
||||
grub> set root=(hd0,msdos1)
|
||||
----
|
||||
Next, select the desired kernel. Set `root` to the `lvm` corresponding to the root directory:
|
||||
Next, select the desired kernel. Set `root` to the logical volume that corresponds to the `/root` directory:
|
||||
+
|
||||
----
|
||||
linux /vmlinuz-3.0.0-1.fc16.i686 root=/dev/mapper/fedora_localhost--live-root
|
||||
grub> linux /vmlinuz-3.0.0-1.fc16.i686 root=/dev/mapper/fedora_localhost--live-root
|
||||
----
|
||||
+
|
||||
Select the RAM filesystem that will be loaded:
|
||||
+
|
||||
----
|
||||
initrd /initramfs-3.0.0-1.fc16.i686.img
|
||||
grub> initrd /initramfs-3.0.0-1.fc16.i686.img
|
||||
----
|
||||
+
|
||||
|
||||
* On UEFI systems:
|
||||
+
|
||||
Set *GRUB2* root to your EFI system partition. If your EFI partition is `(hd0,gpt1)`, the command will be:
|
||||
Set *GRUB2* root to your EFI system partition. If your EFI system partition is `(hd0,gpt1)`, the command will be:
|
||||
+
|
||||
----
|
||||
set root=(hd0,gpt1)
|
||||
----
|
||||
Next, select the desired kernel. Find the path to `vmlinuz` and set `root` to the `lvm` corresponding to the root directory:
|
||||
Next, select the desired kernel. Find the path to `vmlinuz` and set `root` to the logical volume that corresponds to the `/root` directory:
|
||||
+
|
||||
----
|
||||
linux (hd0,gpt2)/vmlinuz-3.0.0-1.fc16.i686 root=/dev/mapper/fedora_localhost--live-root
|
||||
|
@ -114,12 +125,3 @@ Select the RAM filesystem that will be loaded:
|
|||
----
|
||||
initrd (hd0,gpt2)/initramfs-3.0.0-1.fc16.i686.img
|
||||
----
|
||||
+
|
||||
|
||||
. Boot with the selected settings.
|
||||
+
|
||||
----
|
||||
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].
|
||||
|
|
Loading…
Reference in a new issue