mirror of
https://github.com/kairos-io/immucore.git
synced 2025-09-17 23:38:10 +00:00
Mount ESP under /efi if possible + identify EFI run source (#158)
This commit is contained in:
@@ -233,3 +233,24 @@ func GetHostProcCmdline() string {
|
||||
}
|
||||
return proc
|
||||
}
|
||||
|
||||
// EfiBootFromInstall will try to check the /sys/firmware/efi/LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
|
||||
// systemd vendor Id is 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f and will never change
|
||||
// LoaderDevicePartUUID contains the partition UUID of the EFI System Partition the boot loader was run from. Set by the boot loader.
|
||||
// This will return true if we are running from a DISK device, which sets the efivar
|
||||
// This wil return false when running from a volatile media, like CD or netboot as it cannot infer where it was booted from
|
||||
// Useful to check if we are on install phase or not
|
||||
// This efi var is VOLATILE so once we reboot is GONE. No way of keeping it across reboots, its set by the bootloader.
|
||||
func EfiBootFromInstall() bool {
|
||||
file := "/sys/firmware/efi/efivars/LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f"
|
||||
readFile, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
Log.Debug().Err(err).Msg("Error reading LoaderDevicePartUUID file")
|
||||
return false
|
||||
}
|
||||
if len(readFile) == 0 || string(readFile) == "" {
|
||||
Log.Debug().Str("file", string(readFile)).Msg("Error reading LoaderDevicePartUUID file")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user