Modern GRUBing: Difference between revisions
Created page with "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). ==== BLS (Boot Loader Specification) ==== /etc/fstab grub2-mkconfig -o /tmp/boot/grub2/grub.cfg --root-directory=/tmp/LV.ROOT ==== GRUB "Installation" for MBR / BIOS ==== Installs the Stage 1 Boot Code (program) in..." |
mNo edit summary |
||
Line 2: | Line 2: | ||
==== BLS (Boot Loader Specification) ==== | ====BLS (Boot Loader Specification)==== | ||
Nope, not anymore (sort of): /etc/fstab | |||
/ | Nope, not anymore (sort of): grub2-mkconfig -o /tmp/boot/grub2/grub.cfg --root-directory=/tmp/LV.ROOT | ||
Look in /boot/loader/entries and / or use GRUBBY | |||
====GRUB "Installation" for MBR / BIOS==== | |||
==== GRUB "Installation" for MBR / BIOS ==== | |||
Installs the Stage 1 Boot Code (program) in the MBR and Stage 1.5 Boot Code (program) in the "MBR Gap": grub2-install --target=i386-pc /dev/sdd | Installs the Stage 1 Boot Code (program) in the MBR and Stage 1.5 Boot Code (program) in the "MBR Gap": grub2-install --target=i386-pc /dev/sdd | ||
Line 19: | Line 19: | ||
Use DD to clone the Boot Partition | Use DD to clone the Boot Partition | ||
==== Sources ==== | ====Sources==== | ||
https://www.baeldung.com/linux/grub-menu-management | https://www.baeldung.com/linux/grub-menu-management | ||
Line 26: | Line 26: | ||
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/managing_monitoring_and_updating_the_kernel/configuring-kernel-command-line-parameters_managing-monitoring-and-updating-the-kernel | https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/managing_monitoring_and_updating_the_kernel/configuring-kernel-command-line-parameters_managing-monitoring-and-updating-the-kernel | ||
==== ChatGPT's Opinion ==== | ====ChatGPT's Opinion==== | ||
===== GRUB "Installation" ('''What Does <code>grub2-install</code> Do?)''' ===== | =====GRUB "Installation" ('''What Does <code>grub2-install</code> Do?)'''===== | ||
The <code>grub2-install</code> command is used to '''install''' the '''GRUB bootloader''' onto a disk or partition. It places the necessary GRUB '''boot code''' onto the target disk and copies GRUB modules required for booting. | The <code>grub2-install</code> command is used to '''install''' the '''GRUB bootloader''' onto a disk or partition. It places the necessary GRUB '''boot code''' onto the target disk and copies GRUB modules required for booting. | ||
====== '''How <code>grub2-install</code> Works''' ====== | ======'''How <code>grub2-install</code> Works'''====== | ||
When executed, <code>grub2-install</code> performs the following actions: | When executed, <code>grub2-install</code> performs the following actions: | ||
'''1. Determines the Installation Target''' | '''1. Determines the Installation Target''' | ||
* If given a disk (e.g., <code>/dev/sda</code>), it installs '''GRUB to the MBR or GPT boot partition'''. | *If given a disk (e.g., <code>/dev/sda</code>), it installs '''GRUB to the MBR or GPT boot partition'''. | ||
* If given a partition (e.g., <code>/dev/sda1</code>), it may fail or install to the '''partition's boot sector''' (not recommended). | *If given a partition (e.g., <code>/dev/sda1</code>), it may fail or install to the '''partition's boot sector''' (not recommended). | ||
* If on a '''BIOS system''', it installs the <code>i386-pc</code> GRUB bootloader. | *If on a '''BIOS system''', it installs the <code>i386-pc</code> GRUB bootloader. | ||
* If on a '''UEFI system''', it installs <code>x86_64-efi</code> and places EFI files in the EFI system partition. | *If on a '''UEFI system''', it installs <code>x86_64-efi</code> and places EFI files in the EFI system partition. | ||
'''2. Copies GRUB Core to the Correct Location''' | '''2. Copies GRUB Core to the Correct Location''' | ||
* On '''BIOS/MBR systems''', GRUB places its '''boot code''' in the MBR and additional code in the '''post-MBR gap''' (sectors after the MBR). | *On '''BIOS/MBR systems''', GRUB places its '''boot code''' in the MBR and additional code in the '''post-MBR gap''' (sectors after the MBR). | ||
* On '''GPT systems using BIOS (BIOS-GPT)''', it places GRUB in the '''BIOS Boot Partition'''. | *On '''GPT systems using BIOS (BIOS-GPT)''', it places GRUB in the '''BIOS Boot Partition'''. | ||
* On '''UEFI systems''', it installs the <code>grubx64.efi</code> file into the '''EFI System Partition (ESP)'''. | *On '''UEFI systems''', it installs the <code>grubx64.efi</code> file into the '''EFI System Partition (ESP)'''. | ||
'''3. Selects the Correct GRUB Modules''' | '''3. Selects the Correct GRUB Modules''' | ||
* <code>grub2-install</code> determines which GRUB modules are needed based on the filesystem, partition layout, and system firmware. | *<code>grub2-install</code> determines which GRUB modules are needed based on the filesystem, partition layout, and system firmware. | ||
* It installs these modules into <code>/boot/grub2/</code> (BIOS) or <code>/boot/efi/EFI/</code> (UEFI). | *It installs these modules into <code>/boot/grub2/</code> (BIOS) or <code>/boot/efi/EFI/</code> (UEFI). | ||
'''4. Writes GRUB Boot Code''' | '''4. Writes GRUB Boot Code''' | ||
* '''BIOS (MBR) Installation:''' | *'''BIOS (MBR) Installation:''' | ||
** The '''Stage 1 boot code''' is written into the MBR. | **The '''Stage 1 boot code''' is written into the MBR. | ||
** The '''Stage 1.5 boot code''' is stored in the post-MBR gap (if available). | **The '''Stage 1.5 boot code''' is stored in the post-MBR gap (if available). | ||
** The '''Stage 2 boot code''' (GRUB core modules) is stored in <code>/boot/grub2/</code>. | **The '''Stage 2 boot code''' (GRUB core modules) is stored in <code>/boot/grub2/</code>. | ||
* '''UEFI Installation:''' | *'''UEFI Installation:''' | ||
** The <code>grubx64.efi</code> file is copied to the EFI System Partition. | **The <code>grubx64.efi</code> file is copied to the EFI System Partition. | ||
** GRUB is registered as a boot entry with the system's UEFI firmware. | **GRUB is registered as a boot entry with the system's UEFI firmware. | ||
'''5. Registers the Bootloader (If UEFI)''' | '''5. Registers the Bootloader (If UEFI)''' | ||
* 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>. | ||
<br /> | <br /> |
Revision as of 17:07, 9 February 2025
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).
BLS (Boot Loader Specification)
Nope, not anymore (sort of): /etc/fstab
Nope, not anymore (sort of): grub2-mkconfig -o /tmp/boot/grub2/grub.cfg --root-directory=/tmp/LV.ROOT
Look in /boot/loader/entries and / or use GRUBBY
GRUB "Installation" for MBR / BIOS
Installs the Stage 1 Boot Code (program) in the MBR and Stage 1.5 Boot Code (program) in the "MBR Gap": grub2-install --target=i386-pc /dev/sdd
...and don't forget to set the Boot Partition active using CFDISK or something else
OR
Use DD to clone the Boot Partition
Sources
https://www.baeldung.com/linux/grub-menu-management
https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ > https://uapi-group.org/specifications/specs/boot_loader_specification/
ChatGPT's Opinion
GRUB "Installation" (What Does grub2-install
Do?)
The grub2-install
command is used to install the GRUB bootloader onto a disk or partition. It places the necessary GRUB boot code onto the target disk and copies GRUB modules required for booting.
How grub2-install
Works
When executed, grub2-install
performs the following actions:
1. Determines the Installation Target
- If given a disk (e.g.,
/dev/sda
), it installs GRUB to the MBR or GPT boot partition. - If given a partition (e.g.,
/dev/sda1
), it may fail or install to the partition's boot sector (not recommended). - If on a BIOS system, it installs the
i386-pc
GRUB bootloader. - If on a UEFI system, it installs
x86_64-efi
and places EFI files in the EFI system partition.
2. Copies GRUB Core to the Correct Location
- On BIOS/MBR systems, GRUB places its boot code in the MBR and additional code in the post-MBR gap (sectors after the MBR).
- On GPT systems using BIOS (BIOS-GPT), it places GRUB in the BIOS Boot Partition.
- On UEFI systems, it installs the
grubx64.efi
file into the EFI System Partition (ESP).
3. Selects the Correct GRUB Modules
grub2-install
determines which GRUB modules are needed based on the filesystem, partition layout, and system firmware.- It installs these modules into
/boot/grub2/
(BIOS) or/boot/efi/EFI/
(UEFI).
4. Writes GRUB Boot Code
- BIOS (MBR) Installation:
- The Stage 1 boot code is written into the MBR.
- The Stage 1.5 boot code is stored in the post-MBR gap (if available).
- The Stage 2 boot code (GRUB core modules) is stored in
/boot/grub2/
.
- UEFI Installation:
- The
grubx64.efi
file is copied to the EFI System Partition. - GRUB is registered as a boot entry with the system's UEFI firmware.
- The
5. Registers the Bootloader (If UEFI)
- On UEFI systems,
grub2-install
registersgrubx64.efi
with the UEFI boot manager usingefibootmgr
.