Modern GRUBing: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
Rocky Linux 9 does not use the /etc/default/grub and /boot/grub2/grub.cfg Files any longer. Instead the BLS (Boot Loader Specification) 'method' is used. If one reads the documentation from RedHat, it seems like thing got really messy (and confusing). | Rocky Linux 9 does not use the /etc/default/grub and /boot/grub2/grub.cfg Files any longer. Instead the BLS (Boot Loader Specification) 'method' is used. If one reads the documentation from RedHat, it seems like thing got really messy (and confusing). | ||
==== Quick D for Cloning, err, "Recreating" a drive from a BackUp (IE, the closest thing to Acronis that Linux seems to have) ==== | |||
* Create a duplicate or functionally similar Partition layout to the original | |||
** CFDISK and "Logical Volume Commands" | |||
** Use Blivet from a Rocky 8 Live Boot Device<br /> | |||
==== Rough D ==== | |||
* Start from a 'Clean Slate': <code>wipefs -a /dev/sdX</code> (make dang sure the proper 'sdX' is chosen!) | |||
* Set the Partition Type (MBR or GPT): <code>cfdisk /dev/sdX</code>, (select DOS or GPT, save it (write) ) | |||
* Create Partitions: cfdisk | |||
** https://en.wikipedia.org/wiki/Partition_type | |||
** Linux EXT4: $83 (that's Commodore Speaky for 83h) | |||
** Linux LVM (and LVM2): $8E | |||
* LVM Stuff using Commands or BLIVET | |||
** <code>pvcreate /dev/sdX</code> | |||
** <code>vgcreate VG.NVMe.ROOT /dev/sdX</code> | |||
*** <code>vgrename WhatEverOldName WhatEverNewName</code> | |||
** <code>lvcreate -L 64G -n LV.ROOT VG.NVMe.ROOT</code> | |||
* BLIVET | |||
====BLS (Boot Loader Specification)==== | ====BLS (Boot Loader Specification)==== | ||
| Line 9: | Line 29: | ||
Look in /boot/loader/entries and / or use GRUBBY | Look in /boot/loader/entries and / or use GRUBBY | ||
...see below for key information on /etc/default/grub and BLS | |||
====GRUB "Installation" for MBR / BIOS==== | ====GRUB "Installation" for MBR / BIOS==== | ||
| Line 66: | Line 88: | ||
*On '''UEFI systems''', <code>grub2-install</code> registers <code>grubx64.efi</code> with the UEFI boot manager using <code>efibootmgr</code>. | *On '''UEFI systems''', <code>grub2-install</code> registers <code>grubx64.efi</code> with the UEFI boot manager using <code>efibootmgr</code>. | ||
=== More from ChatGPT on "GRUBing" === | |||
= '''Comprehensive Guide to Installing GRUB on Rocky Linux (UEFI & BIOS)''' = | |||
This guide covers: | |||
* '''UEFI bootloader installation''' on a target drive. | |||
* '''Legacy BIOS (MBR) bootloader installation'''. | |||
* '''BLS (Boot Loader Specification) and its effect on <code>grub2-mkconfig</code>.''' | |||
* '''GRUB Boot Stages Explanation (Stage 1, Stage 1.5, Stage 2).''' | |||
* '''How to properly configure bootloader entries and verify installation.''' | |||
---- | |||
== '''1. Understanding GRUB Boot Stages''' == | |||
{| class="wikitable" | |||
!'''GRUB Stage''' | |||
!'''Description''' | |||
!'''Applies To''' | |||
|- | |||
|'''Stage 1''' | |||
|'''MBR code''' (first 512 bytes of disk) loads Stage 1.5 or Stage 2. | |||
|'''Legacy BIOS (MBR) Only''' | |||
|- | |||
|'''Stage 1.5''' | |||
|Located in the first 30KB after MBR, it helps find <code>/boot/grub2</code>. | |||
|'''Legacy BIOS (MBR) Only''' | |||
|- | |||
|'''Stage 2''' | |||
|Loads the GRUB menu, kernel, and initrd. | |||
|'''Both UEFI and BIOS''' | |||
|- | |||
|'''UEFI Firmware Boot''' | |||
|Uses the '''EFI System Partition (ESP)''' instead of MBR. Loads <code>grubx64.efi</code>. | |||
|'''UEFI Only''' | |||
|} | |||
---- | |||
== '''2. Installing GRUB for UEFI Booting''' == | |||
=== '''A. Identify the Target Drive''' === | |||
List available drives and partitions: | |||
Look for the '''EFI System Partition (ESP)''', usually '''formatted as FAT32 (<code>vfat</code>)'''. | |||
Example: If the target drive is <code>/dev/sdb</code>, and the EFI partition is <code>/dev/sdb1</code>, mount it: | |||
=== '''B. Bind System Directories (for Chroot)''' === | |||
If configuring an external system: | |||
=== '''C. Install Required UEFI GRUB Packages''' === | |||
=== '''D. Install GRUB to the Target Drive''' === | |||
* <code>--target=x86_64-efi</code> → Specifies '''UEFI mode'''. | |||
* <code>--efi-directory=/boot/efi</code> → Ensures GRUB is installed in the EFI partition. | |||
* <code>--bootloader-id=rocky</code> → Labels the boot entry as '''"Rocky"'''. | |||
* <code>--recheck</code> → Forces a re-scan of the drive layout. | |||
=== '''E. Generate the GRUB Configuration''' === | |||
⚠ '''However, Rocky Linux follows BLS, which makes this step less critical''' (explained in Section 4). | |||
---- | |||
== '''3. Installing GRUB for Legacy BIOS (MBR Boot)''' == | |||
=== '''A. Mount the Target Drive's Root Partition''' === | |||
If the system has a separate <code>/boot</code> partition: | |||
=== '''B. Chroot into the Target System''' === | |||
=== '''C. Install Required BIOS GRUB Packages''' === | |||
=== '''D. Install GRUB to the MBR of the Target Drive''' === | |||
* <code>--target=i386-pc</code> → '''Required for Legacy BIOS (MBR) booting'''. | |||
* <code>/dev/sdb</code> → '''Must be the whole disk (not a partition like <code>/dev/sdb1</code>)'''. | |||
* <code>--recheck</code> → Forces a disk layout rescan. | |||
=== '''E. Generate the GRUB Configuration''' === | |||
⚠ '''But due to BLS, <code>grub.cfg</code> is no longer the main configuration source.''' | |||
---- | |||
== '''4. Understanding BLS (Boot Loader Specification)''' == | |||
Rocky Linux follows '''BLS (Boot Loader Specification)''', meaning '''boot entries are controlled by systemd-boot entries, not <code>grub2-mkconfig</code>'''. | |||
=== '''How to Manually Manage BLS Entries''' === | |||
# '''List Existing Boot Entries:''' | |||
# '''Manually Create a BLS Entry:''' | |||
# '''Example BLS Entry (<code>rocky.conf</code>)''' | |||
# '''Enable BLS Support in GRUB (if needed)''' | |||
=== '''Why BLS Makes <code>grub2-mkconfig</code> Less Relevant''' === | |||
* '''Traditional GRUB entries are no longer used''' in Rocky Linux. | |||
* The '''bootloader reads BLS entries instead'''. | |||
* '''<code>grub.cfg</code> is still used for bootloader settings''', but '''kernel entries are controlled by BLS'''. | |||
---- | |||
== '''5. Verify Installation''' == | |||
=== '''Check EFI Boot Entries (For UEFI Only)''' === | |||
=== '''Check GRUB Installation''' === | |||
=== '''Check BLS Entries''' === | |||
=== '''Reboot and Test''' === | |||
---- | |||
== '''6. Summary''' == | |||
{| class="wikitable" | |||
!'''Boot Mode''' | |||
!'''Target Option for GRUB''' | |||
!'''Install Command''' | |||
!'''Config Location''' | |||
|- | |||
|'''UEFI''' | |||
|<code>x86_64-efi</code> | |||
|<code>grub2-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=rocky</code> | |||
|<code>/boot/efi/EFI/rocky/grub.cfg</code> | |||
|- | |||
|'''BIOS (MBR)''' | |||
|<code>i386-pc</code> | |||
|<code>grub2-install --target=i386-pc /dev/sdb</code> | |||
|<code>/boot/grub2/grub.cfg</code> | |||
|- | |||
|'''BLS (Rocky Linux Default)''' | |||
|<code>systemd-boot controlled</code> | |||
|<code>bootctl list</code> | |||
|<code>/boot/loader/entries/</code> | |||
|} | |||
<br /> | <br /> | ||
== '''1. The Presence (or Absence) of <code>/boot/grub2/grub.cfg</code>''' == | |||
* If '''<code>grub.cfg</code> exists''', GRUB will parse it. | |||
* If '''<code>grub.cfg</code> does NOT exist''', GRUB will attempt to '''read the BLS entries directly''' instead. | |||
This means: | |||
✔ '''Deleting <code>grub.cfg</code> forces GRUB to rely entirely on BLS.''' | |||
✔ '''Regenerating <code>grub.cfg</code> (<code>grub2-mkconfig</code>) puts GRUB back into a "hybrid mode" where it may still reference BLS but also maintain compatibility with legacy boot setups.''' | |||
---- | |||
== '''2. GRUB’s Bootloader Installation (<code>grub2-install</code>)''' == | |||
The actual bootloader installed to the disk controls whether it defaults to '''BLS mode or <code>grub.cfg</code> mode'''. | |||
When GRUB is installed with: | |||
(''where <code>/dev/sdX</code> is your boot disk, like <code>/dev/sda</code> or <code>/dev/nvme0n1</code>''), it does the following: | |||
* Sets up '''GRUB’s core image''' (<code>/boot/grub2/i386-pc/core.img</code> for BIOS systems or <code>/boot/efi/EFI/rocky/grubx64.efi</code> for UEFI systems). | |||
* Embeds the logic for '''how GRUB will find and load boot entries'''. | |||
* If BLS is active, it instructs GRUB to '''skip parsing <code>grub.cfg</code> and go directly to BLS entries'''. | |||
This means: ✔ If GRUB was installed '''with BLS enabled''', even if <code>grub.cfg</code> exists, it may not be used. | |||
✔ If GRUB was installed '''without BLS support''', it will fall back to <code>grub.cfg</code>. | |||
---- | |||
== '''How to Explicitly Switch Between BLS and <code>grub.cfg</code>''' == | |||
=== '''To Force BLS Mode (and Ignore <code>grub.cfg</code> Completely)''' === | |||
# '''Ensure BLS entries exist''': If this folder is empty, something is broken. | |||
# '''Delete <code>grub.cfg</code>''' (this ensures GRUB won’t use it): | |||
# '''Ensure GRUB is installed with BLS support''': ''(For UEFI systems; adjust for BIOS if needed.)'' | |||
# '''Reboot''' and verify that <code>grub.cfg</code> is no longer in use. | |||
---- | |||
=== '''To Force Legacy <code>grub.cfg</code> Mode (and Ignore BLS)''' === | |||
# '''Ensure <code>grub.cfg</code> is present''': | |||
# '''Reinstall GRUB to disable BLS mode''': ''(The <code>--no-bootloader-spec</code> flag explicitly prevents GRUB from using BLS.)'' | |||
# '''Reboot''' and verify that <code>grub.cfg</code> is being used. | |||
---- | |||
=== '''Final Answer''' === | |||
✔ '''The real switch between BLS and <code>grub.cfg</code> is NOT in <code>/etc/default/grub</code>—it's controlled by how GRUB is installed and configured.''' | |||
✔ '''Deleting <code>grub.cfg</code> forces BLS mode, provided GRUB was installed with BLS support.''' | |||
✔ '''Reinstalling GRUB with <code>--no-bootloader-spec</code> forces it to use <code>grub.cfg</code> instead of BLS.''' | |||
✔ '''To change modes, you must either delete <code>grub.cfg</code> (to force BLS) or reinstall GRUB (to force legacy mode).''' | |||