From 8b85f343a42071b9265d418d5794f2d4842ee0ca Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Tue, 14 Feb 2023 23:19:35 +0800 Subject: [PATCH] fix(host-deployer): revert linux efi check Signed-off-by: wanyaoqi --- pkg/hostman/guestfs/fsdriver/linux.go | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/pkg/hostman/guestfs/fsdriver/linux.go b/pkg/hostman/guestfs/fsdriver/linux.go index a191ae2803..3f42f671dc 100644 --- a/pkg/hostman/guestfs/fsdriver/linux.go +++ b/pkg/hostman/guestfs/fsdriver/linux.go @@ -606,13 +606,32 @@ func (l *sLinuxRootFs) dirWalk(part IDiskPartition, sPath string, wF func(path s } func (l *sLinuxRootFs) DetectIsUEFISupport(part IDiskPartition) bool { - partDev := part.GetPartDev() - output, err := procutils.NewCommand("efibootmgr", part.GetPartDev()).Output() - if err != nil { - log.Infof("part is not efi partition %s: %s, %s", partDev, output, err) + // ref: https://wiki.archlinux.org/title/EFI_system_partition#Check_for_an_existing_partition + // To confirm this is the ESP, mount it and check whether it contains a directory named EFI, + // if it does this is definitely the ESP. + efiDir := "/EFI" + exits := part.Exists(efiDir, false) + if !exits { return false } - return true + + hasEFIFirmware := false + + l.dirWalk(part, efiDir, func(path string, isDir bool) bool { + if isDir { + return false + } + // check file is UEFI firmware + if strings.HasSuffix(path, ".efi") { + log.Infof("EFI firmware %s found", path) + hasEFIFirmware = true + return true + } + // continue walk + return false + }) + + return hasEFIFirmware } func (l *sLinuxRootFs) IsCloudinitInstall() bool {