Class: Bootloader::Systeminfo
- Inherits:
-
Object
- Object
- Bootloader::Systeminfo
- Extended by:
- Yast::Logger
- Defined in:
- src/lib/bootloader/systeminfo.rb
Overview
Provide system and architecture dependent information
Class Method Summary collapse
-
.bls_timeout_supported?(bootloader_name) ⇒ Boolean
Using bls timeout settings.
-
.console_supported?(bootloader_name) ⇒ Boolean
Check if console settings are supported.
-
.dasd?(device) ⇒ Boolean
Check if device is a ECKD DASD device.
-
.device_map?(bootloader_name) ⇒ Boolean
Check if setting device map is available.
- .efi? ⇒ Boolean
-
.efi_arch ⇒ String
Effective UEFI architecture.
-
.efi_mandatory? ⇒ Boolean
Check if EFI mandatory on this system.
-
.efi_platform_size ⇒ Integer
UEFI platform size (32 or 64 bits).
-
.efi_supported? ⇒ Boolean
Check if UEFI is available on this system.
-
.efi_used?(bootloader_name) ⇒ Boolean
Check if UEFI will be used.
-
.generic_mbr_available?(bootloader_name) ⇒ Boolean
Check if mbr configurable with a bootloader.
-
.hiding_menu_supported?(bootloader_name) ⇒ Boolean
Check if hiding menu are supported.
-
.loader_location_available?(bootloader_name) ⇒ Boolean
Check if loader location is configurable with a bootloader.
-
.nvram_available?(bootloader_name = nil) ⇒ Boolean
Check if the system is expected to have nvram - ie.
-
.password_supported?(bootloader_name) ⇒ Boolean
Check if setting password is supported.
-
.ppc_secure_boot ⇒ Object
Return secure boot status on ppc.
-
.ppc_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an ppc machine.
-
.ppc_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an ppc machine.
-
.ppc_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
-
.s390_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an s390 machine.
-
.s390_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an s390 machine.
-
.s390_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
-
.scsi?(device) ⇒ Boolean
Check if device is a SCSI device.
-
.secure_boot_active? ⇒ Boolean
Check current secure boot state.
-
.secure_boot_available?(bootloader_name) ⇒ Boolean
Check if secure boot is configurable with a bootloader.
-
.secure_boot_supported? ⇒ Boolean
Check if secure boot is in principle supported.
-
.shim_needed?(bootloader_name, secure_boot) ⇒ Boolean
Check if shim-install should be used instead of grub2-install.
- .update_nvram_active? ⇒ Boolean
-
.writable_efivars? ⇒ Boolean
Checks if efivars exists and can be written The point here is that without writable UEFI variables the UEFI boot manager cannot (and must not) be updated.
-
.zipl_device ⇒ Y2Storage::Partition, NilClass
The partition where zipl is installed.
Class Method Details
.bls_timeout_supported?(bootloader_name) ⇒ Boolean
Using bls timeout settings
param bootloader_name [String] bootloader name
132 133 134 |
# File 'src/lib/bootloader/systeminfo.rb', line 132 def bls_timeout_supported?(bootloader_name) bootloader_name == "grub2-bls" end |
.console_supported?(bootloader_name) ⇒ Boolean
Check if console settings are supported
param bootloader_name [String] bootloader name
116 117 118 |
# File 'src/lib/bootloader/systeminfo.rb', line 116 def console_supported?(bootloader_name) !Yast::Arch.s390 && bootloader_name != "grub2-bls" end |
.dasd?(device) ⇒ Boolean
Check if device is a ECKD DASD device.
param device [Y2Storage::Partition, NilClass] partition device (or nil)
311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'src/lib/bootloader/systeminfo.rb', line 311 def dasd?(device) return false unless device if device.is?(:partition) disk = device.partitionable return false unless disk dasd?(disk) else device.is?(:dasd) && device.type == Y2Storage::DasdType::ECKD end end |
.device_map?(bootloader_name) ⇒ Boolean
Check if setting device map is available.
74 75 76 77 |
# File 'src/lib/bootloader/systeminfo.rb', line 74 def device_map?(bootloader_name) (Yast::Arch.x86_64 || Yast::Arch.i386) && !["grub2-efi", "grub2-bls"].include?(bootloader_name) end |
.efi? ⇒ Boolean
324 325 326 |
# File 'src/lib/bootloader/systeminfo.rb', line 324 def efi? Y2Storage::Arch.new.efiboot? end |
.efi_arch ⇒ String
Effective UEFI architecture.
Usually the same as the architecture except on x86_64 where it depends on the platform size.
173 174 175 176 177 |
# File 'src/lib/bootloader/systeminfo.rb', line 173 def efi_arch arch = Yast::Arch.architecture arch = "i386" if arch == "x86_64" && efi_platform_size == 32 arch end |
.efi_mandatory? ⇒ Boolean
Check if EFI mandatory on this system.
108 109 110 |
# File 'src/lib/bootloader/systeminfo.rb', line 108 def efi_mandatory? Yast::Arch.aarch64 || Yast::Arch.arm || Yast::Arch.riscv64 end |
.efi_platform_size ⇒ Integer
UEFI platform size (32 or 64 bits).
On x86_64 systems both variants are possible.
159 160 161 162 163 164 165 |
# File 'src/lib/bootloader/systeminfo.rb', line 159 def efi_platform_size bits = File.read("/sys/firmware/efi/fw_platform_size").to_i log.info "EFI platform size: #{bits}" bits rescue StandardError 0 end |
.efi_supported? ⇒ Boolean
Check if UEFI is available on this system.
It need not currently be used. It should just be possible to put the system into UEFI mode.
102 103 104 |
# File 'src/lib/bootloader/systeminfo.rb', line 102 def efi_supported? Yast::Arch.x86_64 || Yast::Arch.i386 || efi_mandatory? end |
.efi_used?(bootloader_name) ⇒ Boolean
Check if UEFI will be used.
param bootloader_name [String] bootloader name
92 93 94 |
# File 'src/lib/bootloader/systeminfo.rb', line 92 def efi_used?(bootloader_name) ["grub2-efi", "systemd-boot", "grub2-bls"].include?(bootloader_name) end |
.generic_mbr_available?(bootloader_name) ⇒ Boolean
Check if mbr configurable with a bootloader.
57 58 59 60 |
# File 'src/lib/bootloader/systeminfo.rb', line 57 def generic_mbr_available?(bootloader_name) (Yast::Arch.x86_64 || Yast::Arch.i386) && !["grub2-efi", "grub2-bls"].include?(bootloader_name) end |
.hiding_menu_supported?(bootloader_name) ⇒ Boolean
Check if hiding menu are supported
param bootloader_name [String] bootloader name
124 125 126 |
# File 'src/lib/bootloader/systeminfo.rb', line 124 def (bootloader_name) bootloader_name != "grub2-bls" end |
.loader_location_available?(bootloader_name) ⇒ Boolean
Check if loader location is configurable with a bootloader.
66 67 68 |
# File 'src/lib/bootloader/systeminfo.rb', line 66 def loader_location_available?(bootloader_name) (Yast::Arch.x86_64 || Yast::Arch.i386 || Yast::Arch.ppc) && bootloader_name == "grub2" end |
.nvram_available?(bootloader_name = nil) ⇒ Boolean
Check if the system is expected to have nvram - ie. update_nvram_active? makes a difference
80 81 82 |
# File 'src/lib/bootloader/systeminfo.rb', line 80 def nvram_available?(bootloader_name = nil) (bootloader_name ? efi_used?(bootloader_name) : efi_supported?) || Yast::Arch.ppc end |
.password_supported?(bootloader_name) ⇒ Boolean
Check if setting password is supported
param bootloader_name [String] bootloader name
140 141 142 |
# File 'src/lib/bootloader/systeminfo.rb', line 140 def password_supported?(bootloader_name) bootloader_name != "grub2-bls" end |
.ppc_secure_boot ⇒ Object
Return secure boot status on ppc
nil - no support 0 - disabled 1 - enabled in audit-only mode 2+ - enabled in enforcing mode
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'src/lib/bootloader/systeminfo.rb', line 234 def ppc_secure_boot # see bsc#1192764 result = nil return nil unless Yast::Arch.ppc begin result = File.read("/proc/device-tree/ibm,secure-boot") result = result.unpack1("N") log.info "reading ibm,secure-boot result #{result}" rescue StandardError => e log.info "reading ibm,secure-boot failed with #{e}" result = nil end result end |
.ppc_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an ppc machine.
The 'real' state, not any config file setting.
271 272 273 274 |
# File 'src/lib/bootloader/systeminfo.rb', line 271 def ppc_secure_boot_active? # see bsc#1192764 ppc_secure_boot.to_i > 0 end |
.ppc_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an ppc machine.
253 254 255 256 |
# File 'src/lib/bootloader/systeminfo.rb', line 253 def ppc_secure_boot_available? # see bsc#1192764 !ppc_secure_boot.nil? end |
.ppc_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
262 263 264 |
# File 'src/lib/bootloader/systeminfo.rb', line 262 def ppc_secure_boot_supported? ppc_secure_boot_available? end |
.s390_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an s390 machine.
The 'real' state, not any config file setting.
216 217 218 219 220 221 222 223 224 225 226 |
# File 'src/lib/bootloader/systeminfo.rb', line 216 def s390_secure_boot_active? return false unless Yast::Arch.s390 # see jsc#SLE-9425 res = File.read("/sys/firmware/ipl/secure", 1) log.info "s390 secure: #{res}" res == "1" rescue StandardError false end |
.s390_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an s390 machine.
182 183 184 185 186 187 188 189 190 191 192 |
# File 'src/lib/bootloader/systeminfo.rb', line 182 def s390_secure_boot_available? # see jsc#SLE-9425 return false unless Yast::Arch.s390 res = File.read("/sys/firmware/ipl/has_secure", 1) log.info "s390 has secure: #{res}" res == "1" rescue StandardError false end |
.s390_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
The catch here is that secure boot works only with SCSI disks.
200 201 202 203 204 205 206 207 208 209 |
# File 'src/lib/bootloader/systeminfo.rb', line 200 def s390_secure_boot_supported? return false unless Yast::Arch.s390 zipl_dev = zipl_device # for ECKD DASD zipl install both modes, so secure boot can be always # enabled (jsc#PED-13734) return true if dasd?(zipl_dev) s390_secure_boot_available? && scsi?(zipl_dev) end |
.scsi?(device) ⇒ Boolean
Check if device is a SCSI device.
param device [Y2Storage::Partition, NilClass] partition device (or nil)
295 296 297 298 299 300 301 302 |
# File 'src/lib/bootloader/systeminfo.rb', line 295 def scsi?(device) # checking if device name starts with 'sd' is not enough: it could # be a device mapper target (e.g. multipath) # see bsc#1171821 device.name.start_with?("/dev/sd") || device.udev_ids.any?(/^scsi-/) rescue StandardError false end |
.secure_boot_active? ⇒ Boolean
Check current secure boot state.
This reflects settings on OS level. If secure boot is not supported, it returns false.
23 24 25 26 |
# File 'src/lib/bootloader/systeminfo.rb', line 23 def secure_boot_active? secure_boot_supported? && Sysconfig.from_system.secure_boot end |
.secure_boot_available?(bootloader_name) ⇒ Boolean
Check if secure boot is configurable with a bootloader.
44 45 46 47 48 49 50 51 |
# File 'src/lib/bootloader/systeminfo.rb', line 44 def secure_boot_available?(bootloader_name) # no shim for i386 (yet) return false if efi_arch == "i386" # no shim neither secure boot support for 32 bit arm nor riscv64 (bsc#1229070) return false if Yast::Arch.arm || Yast::Arch.riscv64 efi_used?(bootloader_name) || s390_secure_boot_available? || ppc_secure_boot_available? end |
.secure_boot_supported? ⇒ Boolean
Check if secure boot is in principle supported.
31 32 33 34 35 36 37 38 |
# File 'src/lib/bootloader/systeminfo.rb', line 31 def secure_boot_supported? # no shim for i386 (yet) return false if efi_arch == "i386" # no shim neither secure boot support for 32 bit arm nor riscv64 (bsc#1229070) return false if Yast::Arch.arm || Yast::Arch.riscv64 efi_supported? || s390_secure_boot_supported? || ppc_secure_boot_supported? end |
.shim_needed?(bootloader_name, secure_boot) ⇒ Boolean
Check if shim-install should be used instead of grub2-install.
param bootloader_name [String] bootloader name param secure_boot [Boolean] secure boot setting
149 150 151 152 |
# File 'src/lib/bootloader/systeminfo.rb', line 149 def shim_needed?(bootloader_name, secure_boot) (Yast::Arch.x86_64 || Yast::Arch.i386 || Yast::Arch.aarch64) && secure_boot && efi_used?(bootloader_name) end |
.update_nvram_active? ⇒ Boolean
84 85 86 |
# File 'src/lib/bootloader/systeminfo.rb', line 84 def update_nvram_active? Sysconfig.from_system.update_nvram end |
.writable_efivars? ⇒ Boolean
Checks if efivars exists and can be written The point here is that without writable UEFI variables the UEFI boot manager cannot (and must not) be updated.
335 336 337 338 |
# File 'src/lib/bootloader/systeminfo.rb', line 335 def writable_efivars? storage_arch = Y2Storage::Arch.new storage_arch.efiboot? && storage_arch.efibootmgr? end |
.zipl_device ⇒ Y2Storage::Partition, NilClass
The partition where zipl is installed.
279 280 281 282 283 284 285 286 287 288 |
# File 'src/lib/bootloader/systeminfo.rb', line 279 def zipl_device staging = Y2Storage::StorageManager.instance.staging mountpoint = Y2Storage::MountPoint.find_by_path(staging, "/boot/zipl").first || Y2Storage::MountPoint.find_by_path(staging, "/boot").first || Y2Storage::MountPoint.find_by_path(staging, "/").first mountpoint.filesystem.blk_devices.first rescue StandardError nil end |