From bbbce37982ce56473846691459103d87d3b89040 Mon Sep 17 00:00:00 2001 From: Joel Rangsmo Date: Mon, 28 Feb 2022 11:43:39 +0000 Subject: [PATCH] Only utilize reboot for systems with known issues --- cmd/pbainit/dmi.go | 4 ++++ cmd/pbainit/main.go | 20 +++++++++++++++----- rootfs.mk | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cmd/pbainit/dmi.go b/cmd/pbainit/dmi.go index de95836..3a1ebcd 100644 --- a/cmd/pbainit/dmi.go +++ b/cmd/pbainit/dmi.go @@ -10,6 +10,8 @@ import ( type DMIData struct { SystemUUID string SystemSerialNumber string + BaseboardManufacturer string + BaseboardProduct string BaseboardSerialNumber string ChassisSerialNumber string } @@ -39,6 +41,8 @@ func readDMI() (*DMIData, error) { if ci, ok := pt.(*smbios.ChassisInfo); ok { dmi.ChassisSerialNumber = ci.SerialNumber } else if bi, ok := pt.(*smbios.BaseboardInfo); ok { + dmi.BaseboardManufacturer = bi.Manufacturer + dmi.BaseboardProduct = bi.Product dmi.BaseboardSerialNumber = bi.SerialNumber } else if si, ok := pt.(*smbios.SystemInfo); ok { dmi.SystemSerialNumber = si.SerialNumber diff --git a/cmd/pbainit/main.go b/cmd/pbainit/main.go index c26a38d..0e8aefc 100644 --- a/cmd/pbainit/main.go +++ b/cmd/pbainit/main.go @@ -71,10 +71,12 @@ func main() { return } - log.Printf("System UUID: %s", dmi.SystemUUID) - log.Printf("System serial: %s", dmi.SystemSerialNumber) - log.Printf("Baseboard serial: %s", dmi.BaseboardSerialNumber) - log.Printf("Chassis serial: %s", dmi.ChassisSerialNumber) + log.Printf("System UUID: %s", dmi.SystemUUID) + log.Printf("System serial: %s", dmi.SystemSerialNumber) + log.Printf("Baseboard manufacturer: %s", dmi.BaseboardManufacturer) + log.Printf("Baseboard product: %s", dmi.BaseboardProduct) + log.Printf("Baseboard serial: %s", dmi.BaseboardSerialNumber) + log.Printf("Chassis serial: %s", dmi.ChassisSerialNumber) sysblk, err := ioutil.ReadDir("/sys/class/block/") if err != nil { @@ -169,7 +171,15 @@ func main() { case <-time.After(5 * time.Second): // pass } - Execute("/bbin/shutdown", "reboot") + // Work-around for systems which are known to fail during boot/kexec - these + // systems keep the drives in an unlocked state during software triggered reboots, + // which means that the "real" kernel and rootfs should be booted afterwards + if dmi.BaseboardManufacturer == "Supermicro" && strings.HasPrefix(dmi.BaseboardProduct, "X12") { + log.Printf("Work-around: Rebooting system instead of utilizing 'boot'") + Execute("/bbin/shutdown", "reboot") + } else { + Execute("/bbin/boot") + } }() reader.ReadString('\n') diff --git a/rootfs.mk b/rootfs.mk index 9cfc917..f028c78 100644 --- a/rootfs.mk +++ b/rootfs.mk @@ -7,6 +7,7 @@ rootfs-$(ARCH).cpio: go/bin/u-root $(wildcard cmd/*/*.go) -o "$(@)" \ -build=gbb \ -initcmd pbainit \ + boot \ core \ github.com/u-root/u-root/cmds/exp/dmidecode \ github.com/u-root/u-root/cmds/exp/page \