mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(host-deployer): detect UEFI supported not correct
This commit is contained in:
@@ -504,8 +504,52 @@ func (l *sLinuxRootFs) disableSerialConsoleSystemd(rootFs IDiskPartition) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *sLinuxRootFs) dirWalk(part IDiskPartition, sPath string, wF func(path string, isDir bool) bool) bool {
|
||||
stat := part.Stat(sPath, false)
|
||||
if !stat.IsDir() {
|
||||
if wF(sPath, false) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
if wF(sPath, true) {
|
||||
return true
|
||||
}
|
||||
for _, subPath := range part.ListDir(sPath, false) {
|
||||
if l.dirWalk(part, path.Join(sPath, subPath), wF) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l *sLinuxRootFs) DetectIsUEFISupport(part IDiskPartition) bool {
|
||||
return part.Exists("/efi", false)
|
||||
// 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
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -65,7 +65,7 @@ func (p *SKVMGuestDiskPartition) GetPhysicalPartitionType() string {
|
||||
if idxP > 0 {
|
||||
dev = dev[:idxP]
|
||||
}
|
||||
cmd := fmt.Sprintf(`fdisk -l %s | grep "Disk label type:"`, dev)
|
||||
cmd := fmt.Sprintf(`fdisk -l %s | grep "Disk.*label type:"`, dev)
|
||||
output, err := procutils.NewCommand("sh", "-c", cmd).Output()
|
||||
if err != nil {
|
||||
log.Errorf("get disk label type error %s", output)
|
||||
|
||||
Reference in New Issue
Block a user