fix boot device detection failing on ZFS /boot

findmnt returns 'flash/boot' for a ZFS dataset, not a /dev/* path.
lsblk -no pkname then fails, leaving transport as 'unknown'. Resolve
ZFS pools to a backing device via zpool before checking transport.
This commit is contained in:
Gmer4Lfe
2026-06-27 23:18:36 -04:00
parent b314aa4aff
commit 5d32f58f5d
+24 -6
View File
@@ -6,10 +6,22 @@ $action = $_GET['action'] ?? $_POST['action'] ?? '';
// ── Boot device detection ─────────────────────────────────────────────────────
function vv_storage_detect_transport(): string {
$part = trim(shell_exec("findmnt -n -o SOURCE /boot 2>/dev/null") ?: '');
if (!$part) return 'unknown';
$disk = trim(shell_exec("lsblk -no pkname " . escapeshellarg($part) . " 2>/dev/null") ?: '');
if (!$disk) return 'unknown';
$src = trim(shell_exec("findmnt -n -o SOURCE /boot 2>/dev/null") ?: '');
if (!$src) return 'unknown';
if (str_starts_with($src, '/dev/')) {
// Block device partition — walk up to whole disk
$disk = trim(shell_exec("lsblk -no pkname " . escapeshellarg($src) . " 2>/dev/null") ?: '');
if (!$disk) return 'unknown';
} else {
// ZFS dataset (pool/dataset) — find a backing device via zpool
$pool = explode('/', $src)[0];
$dev = trim(shell_exec("zpool list -vHp " . escapeshellarg($pool) . " 2>/dev/null | awk 'NR>1 && \$1~/^[a-z]/ && \$1!~/mirror|raidz|spare/{print \$1; exit}'") ?: '');
if (!$dev) return 'unknown';
// Strip partition suffix to get the whole-disk name
$disk = trim(shell_exec("lsblk -no pkname /dev/" . escapeshellarg($dev) . " 2>/dev/null") ?: $dev);
}
return strtolower(trim(shell_exec("lsblk -dno TRAN /dev/" . escapeshellarg($disk) . " 2>/dev/null") ?: 'unknown'));
}
@@ -29,8 +41,14 @@ if ($action === 'status') {
$confVal = $vars[$confKey] ?? null;
// Boot device name for display
$bootPart = trim(shell_exec("findmnt -n -o SOURCE /boot 2>/dev/null") ?: '');
$bootDisk = $bootPart ? trim(shell_exec("lsblk -no pkname " . escapeshellarg($bootPart) . " 2>/dev/null") ?: '') : '';
$bootSrc = trim(shell_exec("findmnt -n -o SOURCE /boot 2>/dev/null") ?: '');
$bootDisk = '';
if (str_starts_with($bootSrc, '/dev/')) {
$bootDisk = trim(shell_exec("lsblk -no pkname " . escapeshellarg($bootSrc) . " 2>/dev/null") ?: '');
$bootDisk = $bootDisk ? '/dev/' . $bootDisk : '';
} elseif ($bootSrc) {
$bootDisk = $bootSrc; // ZFS: show "flash/boot"
}
echo json_encode([
'ok' => true,