From 39d6313b3e8bef0faa7d3ac1c34dde485327d62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 29 Nov 2024 19:47:55 -0500 Subject: [PATCH] incusd/storage/lvm: Handle newer LVM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1438 Signed-off-by: Stéphane Graber --- internal/server/storage/drivers/driver_lvm_utils.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/server/storage/drivers/driver_lvm_utils.go b/internal/server/storage/drivers/driver_lvm_utils.go index 4309e85c964..87c0fe27ac4 100644 --- a/internal/server/storage/drivers/driver_lvm_utils.go +++ b/internal/server/storage/drivers/driver_lvm_utils.go @@ -503,7 +503,17 @@ func (d *lvm) lvmDevPath(vgName string, volType VolumeType, contentType ContentT // resizeLogicalVolume resizes an LVM logical volume. This function does not resize any filesystem inside the LV. func (d *lvm) resizeLogicalVolume(lvPath string, sizeBytes int64) error { - _, err := subprocess.TryRunCommand("lvresize", "-L", fmt.Sprintf("%db", sizeBytes), "-f", lvPath) + isRecent, err := d.lvmVersionIsAtLeast(lvmVersion, "2.03.17") + if err != nil { + return fmt.Errorf("Error checking LVM version: %w", err) + } + + args := []string{"-L", fmt.Sprintf("%db", sizeBytes), "-f", lvPath} + if isRecent { + args = append(args, "--fs=ignore") + } + + _, err = subprocess.TryRunCommand("lvresize", args...) if err != nil { return err }