Skip to content

Commit d53ccd2

Browse files
Bortlesboatjakeaturner
authored andcommitted
fix: prefer real block devices over tmpfs for storage display
The disk-collector could produce an empty fsSize array when /host/proc/1/mounts is unreadable, causing the admin UI to fall back to systeminformation's fsSize which includes tmpfs mounts. This led to the storage display showing ~1.5 GB (tmpfs /run) instead of the actual storage capacity. Two changes: - disk-collector: fall back to df on /storage when host mount table yields no real filesystems, since /storage is always bind-mounted from the host and reflects the actual backing device. - easy-setup UI: when falling back to systeminformation fsSize, filter for /dev/ block devices and prefer the largest one instead of blindly taking the first entry. Fixes #373
1 parent c0b1980 commit d53ccd2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

admin/inertia/pages/easy-setup/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,19 @@ export default function EasySetupWizard(props: { system: { services: ServiceSlim
318318
}
319319

320320
const primaryDisk = getPrimaryDisk()
321-
const primaryFs = systemInfo?.fsSize?.[0]
321+
// When falling back to fsSize (systeminformation), prefer real block devices
322+
// over virtual filesystems like tmpfs which report misleading capacity.
323+
const getPrimaryFs = () => {
324+
if (!systemInfo?.fsSize || systemInfo.fsSize.length === 0) return null
325+
const realDevices = systemInfo.fsSize.filter((fs) => fs.fs.startsWith('/dev/'))
326+
if (realDevices.length > 0) {
327+
return realDevices.reduce((largest, current) =>
328+
current.size > largest.size ? current : largest
329+
)
330+
}
331+
return systemInfo.fsSize[0]
332+
}
333+
const primaryFs = getPrimaryFs()
322334
const storageInfo = primaryDisk
323335
? { totalSize: primaryDisk.totalSize, totalUsed: primaryDisk.totalUsed }
324336
: primaryFs

install/sidecar-disk-collector/collect-disk-info.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ while true; do
5050
FS_JSON+="{\"fs\":\"${dev}\",\"size\":${size},\"used\":${used},\"available\":${avail},\"use\":${pct},\"mount\":\"${mountpoint}\"}"
5151
FIRST=0
5252
done < /host/proc/1/mounts
53+
54+
# Fallback: if no real filesystems were found from the host mount table
55+
# (e.g. /host/proc/1/mounts was unreadable), try the /storage mount directly.
56+
# The disk-collector container always has /storage bind-mounted from the host,
57+
# so df on /storage reflects the actual backing device and its capacity.
58+
if [[ "$FIRST" -eq 1 ]] && mountpoint -q /storage 2>/dev/null; then
59+
STATS=$(df -B1 /storage 2>/dev/null | awk 'NR==2{print $1,$2,$3,$4,$5}')
60+
if [[ -n "$STATS" ]]; then
61+
read -r dev size used avail pct <<< "$STATS"
62+
pct="${pct/\%/}"
63+
FS_JSON+="{\"fs\":\"${dev}\",\"size\":${size},\"used\":${used},\"available\":${avail},\"use\":${pct},\"mount\":\"/storage\"}"
64+
FIRST=0
65+
log "Used /storage mount as fallback for filesystem info."
66+
fi
67+
fi
68+
5369
FS_JSON+="]"
5470

5571
# Use a tmp file for atomic update

0 commit comments

Comments
 (0)