add ability to specify partition for extra disk using folder name

This commit is contained in:
Henry Dollman
2024-11-04 20:52:27 -05:00
parent 37a066e6bd
commit 655bfc95ca
2 changed files with 16 additions and 7 deletions

View File

@@ -41,11 +41,20 @@ func (a *Agent) initializeDiskInfo() {
if _, exists := a.fsStats[key]; !exists {
if root {
slog.Info("Detected root device", "name", key)
// check if root device is in /proc/diskstats, use fallback if not
// Check if root device is in /proc/diskstats, use fallback if not
if _, exists := diskIoCounters[key]; !exists {
slog.Warn("Device not found in diskstats", "name", key)
key = findFallbackIoDevice(filesystem, diskIoCounters, a.fsStats)
slog.Info("Using I/O fallback", "name", key)
slog.Info("Using I/O fallback", "device", device, "mountpoint", mountpoint, "fallback", key)
}
} else {
// Check if non-root has diskstats and fall back to folder name if not
// Scenario: device is encrypted and named luks-2bcb02be-999d-4417-8d18-5c61e660fb6e - not in /proc/diskstats.
// However, the device can be specified by mounting folder from luks device at /extra-filesystems/sda1
if _, exists := diskIoCounters[key]; !exists {
efBase := filepath.Base(mountpoint)
if _, exists := diskIoCounters[efBase]; exists {
key = efBase
}
}
}
a.fsStats[key] = &system.FsStats{Root: root, Mountpoint: mountpoint}
@@ -114,7 +123,7 @@ func (a *Agent) initializeDiskInfo() {
mountpoint := filepath.Join(efPath, folder.Name())
slog.Debug("/extra-filesystems", "mountpoint", mountpoint)
if !existingMountpoints[mountpoint] {
a.fsStats[folder.Name()] = &system.FsStats{Mountpoint: mountpoint}
addFsStat(folder.Name(), mountpoint, false)
}
}
}

View File

@@ -61,7 +61,7 @@ If you don't need network stats, remove that line from the compose file and map
### Binary
> [!TIP]
> If using Linux, see [guides/systemd.md](/supplemental/guides/systemd.md) for a script to install the hub or agent as a system service. The agent installer will be built into the web UI in the future.
> If using Linux, see [guides/systemd.md](/supplemental/guides/systemd.md) for a script to install the hub or agent as a system service. This is also built into the web UI.
Download and run the latest binaries from the [releases page](https://github.com/henrygd/beszel/releases) or use the commands below.
@@ -168,8 +168,8 @@ Mount a folder from the target filesystem in the container's `/extra-filesystems
```yaml
volumes:
- /mnt/disk1/.beszel:/extra-filesystems/disk1:ro
- /dev/mmcblk0/.beszel:/extra-filesystems/sd-card:ro
- /mnt/disk1/.beszel:/extra-filesystems/sdb1:ro
- /dev/mmcblk0/.beszel:/extra-filesystems/mmcblk0:ro
```
### Binary