Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions collector/lsblk_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ func (c *lsblkCollector) Update(ch chan<- prometheus.Metric) error {
}

args := []string{"--json", "-b", "-o", "NAME,SIZE,FSTYPE,MOUNTPOINT,FSUSED,FSUSE%"}
// When running inside a container with the host rootfs mounted under
// --path.rootfs (e.g. /host/root), the in-container lsblk cannot see the
// host's device-mapper/LVM topology or filesystem usage. Pointing lsblk at
// the host root via --sysroot makes it read the host's sysfs, udev and
// mountinfo, so LVM volumes and their FSUSED/FSUSE% are reported correctly.
if *rootfsPath != "" && *rootfsPath != "/" {
args = append(args, "--sysroot", *rootfsPath)
}
cmd := execCommand(path, args...)
out, err := CombinedOutputTimeout(cmd, *lsblkTimeout)
if err != nil {
Expand Down
Loading