fix(configuration): put new EFI boot entry first and install removable fallback
This commit is contained in:
@@ -18,13 +18,24 @@
|
|||||||
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
|
- name: Remove stale EFI boot entries for this OS
|
||||||
ansible.builtin.command: efibootmgr
|
# UEFI NVRAM entries survive a disk wipe (they live in firmware, not on disk).
|
||||||
register: configuration_efi_entries
|
# A prior install leaves a dead entry, and a case-insensitive duplicate label
|
||||||
changed_when: false
|
# ("ArchLinux" vs "archlinux") would otherwise win the boot order - the firmware
|
||||||
|
# then falls through to removable media. Delete every entry carrying our label,
|
||||||
|
# then recreate exactly one clean entry.
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: >-
|
||||||
|
set -o pipefail;
|
||||||
|
efibootmgr | grep -iP '^Boot[0-9A-F]{4}\*?\s+{{ _efi_vendor }}\s*$'
|
||||||
|
| grep -oP '^Boot\K[0-9A-F]{4}'
|
||||||
|
| xargs -r -I{} efibootmgr -b {} -B
|
||||||
|
executable: /bin/bash
|
||||||
|
register: _efi_gc_result
|
||||||
|
changed_when: _efi_gc_result.stdout | length > 0
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: Ensure EFI boot entry exists
|
- name: Create EFI boot entry (efibootmgr -c prepends it to BootOrder)
|
||||||
when: ('* ' + _efi_vendor) not in configuration_efi_entries.stdout
|
|
||||||
ansible.builtin.command: >-
|
ansible.builtin.command: >-
|
||||||
efibootmgr -c
|
efibootmgr -c
|
||||||
-L '{{ _efi_vendor }}'
|
-L '{{ _efi_vendor }}'
|
||||||
@@ -34,15 +45,16 @@
|
|||||||
register: configuration_efi_entry_result
|
register: configuration_efi_entry_result
|
||||||
changed_when: configuration_efi_entry_result.rc == 0
|
changed_when: configuration_efi_entry_result.rc == 0
|
||||||
|
|
||||||
- name: Set installed OS as first EFI boot entry
|
- name: Install removable EFI fallback loader
|
||||||
ansible.builtin.shell:
|
# Firmware-agnostic fallback (\EFI\BOOT\BOOTX64.EFI): many consumer firmwares
|
||||||
cmd: >-
|
# ignore or reset custom NVRAM entries and boot only the removable path.
|
||||||
set -o pipefail &&
|
when: _configuration_platform.grub_install
|
||||||
efibootmgr | grep -i '{{ _efi_vendor }}' | grep -oP 'Boot\K[0-9A-F]+' | head -1
|
ansible.builtin.command: >-
|
||||||
| xargs -I{} efibootmgr -o {}
|
{{ chroot_command }} /usr/bin/install -Dm644
|
||||||
executable: /bin/bash
|
{{ partitioning_efi_mountpoint }}/EFI/{{ _efi_vendor }}/{{ _efi_loader }}
|
||||||
register: _efi_bootorder_result
|
{{ partitioning_efi_mountpoint }}/EFI/BOOT/BOOTX64.EFI
|
||||||
changed_when: _efi_bootorder_result.rc == 0
|
register: _efi_fallback_result
|
||||||
|
changed_when: _efi_fallback_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"
|
||||||
|
|||||||
Reference in New Issue
Block a user