From 36d66190993d1bca4cb99f53655d817135941140 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 11 Aug 2025 10:01:13 -0700 Subject: [PATCH] Create LVM snapshots as read-write to avoid an error when snapshotting ext4 filesystems with orphaned files that need recovery (#1126). --- NEWS | 2 ++ borgmatic/hooks/data_source/lvm.py | 2 +- tests/unit/hooks/data_source/test_lvm.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index fa620f83..6dcede31 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ * #1114: Document systemd configuration changes for the ZFS filesystem hook. * #1118: Fix a bug in which Borg hangs during database backup when different filesystems are in use. + * #1126: Create LVM snapshots as read-write to avoid an error when snapshotting ext4 filesystems + with orphaned files that need recovery. * When running tests, use Ruff for faster and more comprehensive code linting and formatting, replacing Flake8, Black, isort, etc. * Switch from pipx to uv for installing development tools, and added tox-uv for speeding up test diff --git a/borgmatic/hooks/data_source/lvm.py b/borgmatic/hooks/data_source/lvm.py index 8a8306b0..1e5fd266 100644 --- a/borgmatic/hooks/data_source/lvm.py +++ b/borgmatic/hooks/data_source/lvm.py @@ -106,7 +106,7 @@ def snapshot_logical_volume( ('--extents' if '%' in snapshot_size else '--size'), snapshot_size, '--permission', - 'r', # Read-only. + 'rw', # Read-write in case an ext4 filesystem has orphaned files that need recovery. '--name', snapshot_name, logical_volume_device, diff --git a/tests/unit/hooks/data_source/test_lvm.py b/tests/unit/hooks/data_source/test_lvm.py index a6e6eb6d..e692a48c 100644 --- a/tests/unit/hooks/data_source/test_lvm.py +++ b/tests/unit/hooks/data_source/test_lvm.py @@ -212,7 +212,7 @@ def test_snapshot_logical_volume_with_percentage_snapshot_name_uses_lvcreate_ext '--extents', '10%ORIGIN', '--permission', - 'r', + 'rw', '--name', 'snap', '/dev/snap', @@ -232,7 +232,7 @@ def test_snapshot_logical_volume_with_non_percentage_snapshot_name_uses_lvcreate '--size', '10TB', '--permission', - 'r', + 'rw', '--name', 'snap', '/dev/snap',