Skip to content

Commit

Permalink
Only utilize reboot for systems with known issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Rangsmo committed Feb 28, 2022
1 parent 41c9f6b commit bbbce37
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cmd/pbainit/dmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
type DMIData struct {
SystemUUID string
SystemSerialNumber string
BaseboardManufacturer string
BaseboardProduct string
BaseboardSerialNumber string
ChassisSerialNumber string
}
Expand Down Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions cmd/pbainit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions rootfs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit bbbce37

Please sign in to comment.