From 5d32f58f5d7768f22c4a644fe0380176349cab1e Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sat, 27 Jun 2026 23:18:36 -0400 Subject: [PATCH] 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. --- Plugin/unraid/api/storage.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Plugin/unraid/api/storage.php b/Plugin/unraid/api/storage.php index c91987d..53848a7 100644 --- a/Plugin/unraid/api/storage.php +++ b/Plugin/unraid/api/storage.php @@ -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,