# Auto-Restart on Power Loss — Consumer Mini PCs (2026-07-04)

## Context

n5pro (10.0.20.91) is a Micro Computer N5 PRO (AMD Ryzen, AMI BIOS 1.01, no IPMI/BMC).
Needs to auto-restart after power outage for Ceph OSD availability.

## Problem

Enterprise servers have IPMI/BMC with "Restore on Power Loss" configurable via `ipmitool`.
Consumer mini PCs lack IPMI — the setting lives in BIOS NVRAM only.

### AMI BIOS Limitations

- The "Restore on AC Power Loss" / "State After G3" setting is stored in AMI proprietary NVRAM
  variables (`AMD_PBS_SETUP`, `AmdSetup`) — **not** standard EFI vars.
- These variables are opaque binary blobs; writing them blindly risks bricking the board.
- `efivar` / `efibootmgr` cannot parse or modify AMI setup menus.
- **Conclusion:** This setting must be changed manually in BIOS UI.

### BIOS Instructions (manual, one-time)

1. Boot → press `Del` or `F2` → enter BIOS Setup
2. Navigate to **Chipset** → **South Cluster Configuration** (or **Advanced** → **Power Management**)
3. Find **State After G3** (or **Restore on AC Power Loss**)
4. Set to **Power On** (or **S0** / **Last State**)
5. Save & exit (F10)

### Wake-on-LAN as Fallback

WoL can wake a powered-off machine IF:
- The NIC receives standby power (machine is plugged in, PSU switch on)
- WoL is enabled in BOTH BIOS and OS

⚠️ WoL does NOT help after a complete power outage — the NIC has no power.
It only helps for soft power-off (S5 state with standby power).

## Enabling WoL Persistently

### Identify the Physical NIC

Mini PCs often have bond/team interfaces. Check which physical NIC supports WoL:

```bash
# List all interfaces
ip link show

# Check WoL support on each physical NIC
ethtool nic0 | grep -i "wake"
# Supports Wake-on: pumbg  ← good
# Wake-on: d         ← disabled

# Enable WoL magic packet
ethtool -s nic0 wol g
```

⚠️ Bond interfaces (`bond0`) don't have WoL — enable it on the **physical slave** (`nic0`).

### Persistent systemd Service

```ini
# /etc/systemd/system/wol-enable.service
[Unit]
Description=Enable Wake-on-LAN
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s nic0 wol g
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
```

```bash
systemctl daemon-reload
systemctl enable --now wol-enable.service
```

### Triggering WoL Remotely

```bash
# From any machine on the same broadcast domain
wakeonlan <MAC_ADDRESS>
# or
etherwake -i <interface> <MAC_ADDRESS>
```

## Node Inventory: n5pro (10.0.20.91)

| Property | Value |
|----------|-------|
| Hardware | Micro Computer (HK) Tech N5 PRO |
| BIOS | AMI 1.01 (2025-10-24) |
| CPU | AMD Ryzen |
| NVMe | 128 GB AirDisk SSD (MAP1202 DRAM-less) |
| SATA Controller | JMicron JMB58x AHCI, **5/5 ports implemented** |
| USB Boot | SanDisk 3.2Gen1 14.3 GB (Proxmox installer) |
| Network | bond0 (nic0 + eno1), MAC: 38:05:25:37:8e:08 |
| WoL | Enabled on nic0, systemd service active |
| BIOS Auto-Start | ⚠️ MANUAL — needs "State After G3 = Power On" in BIOS |
| Ceph OSDs | None yet — prepared for 2x 3TB HDDs |

## General Decision Matrix: Auto-Restart Methods

| Hardware Type | Method | Remote Config? |
|---------------|--------|-----------------|
| Enterprise server with IPMI | `ipmitool chassis setenv` | Yes |
| Consumer PC with AMI BIOS | BIOS "State After G3" | Manual BIOS |
| Consumer PC, no BIOS option | WoL + external waker | Partial (needs power) |
| PiKVM / BMC add-on | Virtual media + IPMI emulation | Yes |

## Pitfalls

1. **Don't write AMI NVRAM vars blind** — `AMD_PBS_SETUP` is an opaque binary blob, not a simple key-value store. Writing wrong bytes bricks the board.
2. **Bond interfaces don't support ethtool WoL** — target the physical slave interface, not bond0.
3. **WoL after full power outage is useless** — NIC has no standby power. Only BIOS "Restore on AC" helps.
4. **AHCI port count misleading** — some controllers advertise N ports but implement fewer. Check `dmesg | grep "ports implemented"` (e.g. OptiPlex 3070: 5 ports shown, only 1 implemented = port mask 0x1).
