I upgraded from 12.0-U8.1 to 13.0-U2 recently. Some days later I discovered during a power outage that halt -p and poweroff still powered the server down, but then it didn't stay off, starting right back up on its own about 5 seconds later, which became a very significant problem for my UPS runtime.
My initial suspicion was a hardware-related issue since everything had worked fine for years, so I spent a lot of time eliminating USB, WOL, and other suspects. After also doing quite a lot of searching around, I finally discovered the solution and wanted to post it here so that hopefully someone else can save themselves several days of frustrated root causing.
It turns out that FreeBSD 13.0 changed the default power off mechanism from ACPI to EFI. My server's motherboard is not the newest any more and, unsurprisingly, this FreeBSD change surfaced someone's bug. So while the system did power off, the EFI path resulted in an automatic restart despite all the BIOS settings having been carefully set to Stay Off.
The solution is to add hw.efi.poweroff=0 to /etc/sysctl.conf — for those wanting to do this when the system is already up sudo sysctl hw.efi.poweroff=0 does the job.
Now the server behaves just like it did with 12.0-U8.1: it powers down and stays off until manual power on.
Since manual config changes via shell are frowned upon and unsupported, I'd like to suggest to the TrueNAS devs that they consider at least adding an option to prefer ACPI over EFI in the settings for Services > UPS and defaulting this setting to on when upgrading from pre-13 TrueNAS.
I won't be surprised at all to learn that this is going to bite many other 12->13 upgraders in the future as they exercise their power loss plans.
My initial suspicion was a hardware-related issue since everything had worked fine for years, so I spent a lot of time eliminating USB, WOL, and other suspects. After also doing quite a lot of searching around, I finally discovered the solution and wanted to post it here so that hopefully someone else can save themselves several days of frustrated root causing.
It turns out that FreeBSD 13.0 changed the default power off mechanism from ACPI to EFI. My server's motherboard is not the newest any more and, unsurprisingly, this FreeBSD change surfaced someone's bug. So while the system did power off, the EFI path resulted in an automatic restart despite all the BIOS settings having been carefully set to Stay Off.
The solution is to add hw.efi.poweroff=0 to /etc/sysctl.conf — for those wanting to do this when the system is already up sudo sysctl hw.efi.poweroff=0 does the job.
Now the server behaves just like it did with 12.0-U8.1: it powers down and stays off until manual power on.
Since manual config changes via shell are frowned upon and unsupported, I'd like to suggest to the TrueNAS devs that they consider at least adding an option to prefer ACPI over EFI in the settings for Services > UPS and defaulting this setting to on when upgrading from pre-13 TrueNAS.
I won't be surprised at all to learn that this is going to bite many other 12->13 upgraders in the future as they exercise their power loss plans.