Class: Bootloader::Grub2EFI
- Inherits:
-
Grub2Base
- Object
- BootloaderBase
- Grub2Base
- Bootloader::Grub2EFI
- Includes:
- Yast::Logger
- Defined in:
- src/lib/bootloader/grub2efi.rb
Overview
Represents grub2 bootloader with efi target
Instance Attribute Summary
Attributes inherited from Grub2Base
#console, #grub_default, #password, #pmbr_action, #sections, #secure_boot, #stage1, #trusted_boot, #update_nvram
Instance Method Summary collapse
-
#initialize ⇒ Grub2EFI
constructor
A new instance of Grub2EFI.
- #name ⇒ Object
- #packages ⇒ Object
- #propose ⇒ Object
-
#summary ⇒ Object
Display bootloader summary.
-
#write ⇒ Object
Write bootloader settings to disk.
-
#write_sysconfig(prewrite: false) ⇒ Object
overwrite BootloaderBase version to save secure boot.
Methods inherited from Grub2Base
#cpu_mitigations, #cpu_mitigations=, #disable_serial_console, #enable_serial_console, #explicit_cpu_mitigations, #include_os_prober_package?, #merge, #pmbr_setup, #read, #serial_console?
Methods inherited from BootloaderBase
#merge, #prepare, #proposed?, #read, #read?
Constructor Details
#initialize ⇒ Grub2EFI
Returns a new instance of Grub2EFI.
17 18 19 20 21 22 23 |
# File 'src/lib/bootloader/grub2efi.rb', line 17 def initialize super textdomain "bootloader" @grub_install = GrubInstall.new(efi: true) end |
Instance Method Details
#name ⇒ Object
79 80 81 |
# File 'src/lib/bootloader/grub2efi.rb', line 79 def name "grub2-efi" end |
#packages ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'src/lib/bootloader/grub2efi.rb', line 83 def packages res = super case Yast::Arch.architecture when "i386" res << "grub2-i386-efi" when "x86_64" res << "grub2-x86_64-efi" res << "shim" << "mokutil" if secure_boot when "arm" res << "grub2-arm-efi" when "aarch64" res << "grub2-arm64-efi" res << "shim" << "mokutil" if secure_boot when "riscv64" res << "grub2-riscv64-efi" else log.warn "Unknown architecture #{Yast::Arch.architecture} for EFI" end res end |
#propose ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'src/lib/bootloader/grub2efi.rb', line 51 def propose super # for UEFI always remove PMBR flag on disk (bnc#872054) self.pmbr_action = :remove # linuxefi/initrdefi are available on x86 only grub_default.generic_set("GRUB_USE_LINUXEFI", (Yast::Arch.x86_64 || Yast::Arch.i386) ? "true" : "false") end |
#summary ⇒ Object
Display bootloader summary
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'src/lib/bootloader/grub2efi.rb', line 64 def summary(*) result = [ Yast::Builtins.sformat( _("Boot Loader Type: %1"), "GRUB2 EFI" ) ] result << secure_boot_summary if Systeminfo.secure_boot_available?(name) result << trusted_boot_summary if Systeminfo.trusted_boot_available?(name) result << update_nvram_summary if Systeminfo.nvram_available?(name) result end |
#write ⇒ Object
Write bootloader settings to disk
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'src/lib/bootloader/grub2efi.rb', line 26 def write # super have to called as first as grub install require some config written in ancestor super if pmbr_action fs = filesystems efi_partition = fs.find { |f| f.mount_path == "/boot/efi" } efi_partition ||= fs.find { |f| f.mount_path == "/boot" } efi_partition ||= fs.find { |f| f.mount_path == "/" } raise "could not find boot partiton" unless efi_partition disks = Yast::BootStorage.stage1_disks_for(efi_partition) # set only gpt disks disks.select! { |disk| disk.gpt? } pmbr_setup(*disks.map(&:name)) end @grub_install.execute(secure_boot: secure_boot, trusted_boot: trusted_boot, update_nvram: update_nvram) true end |
#write_sysconfig(prewrite: false) ⇒ Object
overwrite BootloaderBase version to save secure boot
107 108 109 110 111 112 |
# File 'src/lib/bootloader/grub2efi.rb', line 107 def write_sysconfig(prewrite: false) sysconfig = Bootloader::Sysconfig.new(bootloader: name, secure_boot: secure_boot, trusted_boot: trusted_boot, update_nvram: update_nvram) prewrite ? sysconfig.pre_write : sysconfig.write end |