Compare commits

...

2 Commits

Author SHA1 Message Date
7b213e7456 fix(partitioning): create separate /boot for LVM-based filesystems
VMware EFI firmware may not initialize all SCSI devices before GRUB
runs, preventing LVM assembly when the root LV spans multiple disks.
A separate /boot partition (the standard RHEL Anaconda layout) lets
GRUB load kernels without LVM; the kernel initramfs handles LVM
activation with proper device waiting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 04:50:32 +01:00
cfc261878a fix(bootloader): run efibootmgr on host for universal chroot compatibility
The previous approach ran efibootmgr inside the chroot, which only works
with arch-chroot (auto-mounts efivars) but fails silently with
systemd-nspawn or plain chroot. Move EFI boot entry creation to the host
where efivars is always available.

Also fixes wrong EFI loader path (\efi\EFI\... -> \EFI\...) and uses
the correct vendor label (e.g. "redhat" instead of raw os variable).

For non-RHEL distros, grub-install now uses --no-nvram to avoid
redundant NVRAM writes; the host efibootmgr handles entry creation
for all distros uniformly with idempotent pre-check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 03:36:20 +01:00
2 changed files with 36 additions and 22 deletions

View File

@@ -1,27 +1,40 @@
--- ---
- name: Configure Bootloader - name: Configure Bootloader
block:
- name: Install Bootloader
vars: vars:
configuration_use_efibootmgr: "{{ is_rhel | bool }}" _efi_vendor: >-
configuration_efi_dir: "{{ partitioning_efi_mountpoint }}" {{
configuration_bootloader_id: >- "redhat" if os == "rhel"
{{ "ubuntu" if os in ["ubuntu", "ubuntu-lts"] else os }} else ("ubuntu" if os in ["ubuntu", "ubuntu-lts"] else os)
configuration_efi_vendor: >- }}
{{ "redhat" if os == "rhel" else os }} _efi_loader: >-
configuration_efibootmgr_cmd: >- {{ "shimx64.efi" if is_rhel | bool else "grubx64.efi" }}
/usr/sbin/efibootmgr -c -L '{{ os }}' -d "{{ install_drive }}" -p 1 block:
-l '\efi\EFI\{{ configuration_efi_vendor }}\shimx64.efi' - name: Install GRUB EFI binary
configuration_grub_cmd: >- when: not (is_rhel | bool)
/usr/sbin/grub-install --target=x86_64-efi ansible.builtin.command: >-
--efi-directory={{ configuration_efi_dir }} {{ chroot_command }} /usr/sbin/grub-install --target=x86_64-efi
--bootloader-id={{ configuration_bootloader_id }} --efi-directory={{ partitioning_efi_mountpoint }}
configuration_bootloader_cmd: >- --bootloader-id={{ _efi_vendor }}
{{ configuration_efibootmgr_cmd if configuration_use_efibootmgr else configuration_grub_cmd }} --no-nvram
ansible.builtin.command: "{{ chroot_command }} {{ configuration_bootloader_cmd }}"
register: configuration_bootloader_result register: configuration_bootloader_result
changed_when: configuration_bootloader_result.rc == 0 changed_when: configuration_bootloader_result.rc == 0
- name: Check existing EFI boot entries
ansible.builtin.command: efibootmgr
register: _efi_entries
changed_when: false
- name: Ensure EFI boot entry exists
when: ('* ' + _efi_vendor) not in _efi_entries.stdout
ansible.builtin.command: >-
efibootmgr -c
-L '{{ _efi_vendor }}'
-d '{{ install_drive }}'
-p 1
-l '\EFI\{{ _efi_vendor }}\{{ _efi_loader }}'
register: _efi_entry_result
changed_when: _efi_entry_result.rc == 0
- name: Ensure lvm2 for non btrfs filesystems - name: Ensure lvm2 for non btrfs filesystems
when: os == "archlinux" and system_cfg.filesystem != "btrfs" when: os == "archlinux" and system_cfg.filesystem != "btrfs"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
@@ -50,13 +63,11 @@
- name: Generate grub config - name: Generate grub config
vars: vars:
configuration_efi_vendor: >-
{{ "redhat" if os == "rhel" else os }}
configuration_grub_cfg_cmd: >- configuration_grub_cfg_cmd: >-
{{ {{
'/usr/sbin/grub2-mkconfig -o ' '/usr/sbin/grub2-mkconfig -o '
+ partitioning_efi_mountpoint + partitioning_efi_mountpoint
+ '/EFI/' + configuration_efi_vendor + '/grub.cfg' + '/EFI/' + _efi_vendor + '/grub.cfg'
if is_rhel | bool if is_rhel | bool
else '/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg' else '/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg'
}} }}

View File

@@ -9,7 +9,10 @@ partitioning_boot_size_mib: 1024
partitioning_use_full_disk: true partitioning_use_full_disk: true
partitioning_separate_boot: >- partitioning_separate_boot: >-
{{ {{
(
(system_cfg.luks.enabled | bool) (system_cfg.luks.enabled | bool)
or (system_cfg.filesystem != 'btrfs')
)
and (os not in ['archlinux']) and (os not in ['archlinux'])
}} }}
partitioning_boot_fs_fstype: >- partitioning_boot_fs_fstype: >-