From 9b15d32ec7252c16332e806a497b134f4e234975 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Sun, 21 Jul 2024 20:02:35 +0200 Subject: [PATCH 1/3] Add support for filesystem online resize --- blivetgui/blivet_utils.py | 6 +++++- tests/blivetgui_tests/utils_test.py | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/blivetgui/blivet_utils.py b/blivetgui/blivet_utils.py index f7682414..c290b3ad 100644 --- a/blivetgui/blivet_utils.py +++ b/blivetgui/blivet_utils.py @@ -168,6 +168,8 @@ def __init__(self, ignored_disks=None, exclusive_disks=None, flags=None): if flags: self._set_blivet_flags(flags) + blivet.flags.flags.allow_online_fs_resize = True + self.blivet_reset() self._update_min_sizes_info() @@ -727,7 +729,9 @@ def device_resizable(self, blivet_device): return ProxyDataContainer(resizable=False, error=msg, min_size=blivet.size.Size("1 MiB"), max_size=blivet_device.size) - elif hasattr(blivet_device.format, "system_mountpoint") and blivet_device.format.system_mountpoint: + elif hasattr(blivet_device.format, "system_mountpoint") and blivet_device.format.system_mountpoint and \ + not (blivet_device.format._resize_support & blivet.formats.fslib.FSResize.ONLINE_GROW or + blivet_device.format._resize_support & blivet.formats.fslib.FSResize.ONLINE_SHRINK): msg = _("Mounted devices cannot be resized") return ProxyDataContainer(resizable=False, error=msg, min_size=blivet.size.Size("1 MiB"), max_size=blivet_device.size) diff --git a/tests/blivetgui_tests/utils_test.py b/tests/blivetgui_tests/utils_test.py index ac322342..5b0f81dd 100644 --- a/tests/blivetgui_tests/utils_test.py +++ b/tests/blivetgui_tests/utils_test.py @@ -7,6 +7,7 @@ from blivetgui.i18n import _ from blivet.size import Size +from blivet.formats.fslib import FSResize class FreeSpaceDeviceTest(unittest.TestCase): @@ -82,14 +83,23 @@ def test_resizable(self): self.assertEqual(res.min_size, Size("1 MiB")) self.assertEqual(res.max_size, Size("1 GiB")) - # mounted devices are not resizable - device.format.configure_mock(type="ext4", system_mountpoint="/") + # mounted device, format doesn't support online resize: not resizable + device.format.configure_mock(type="ext4", system_mountpoint="/", _resize_support=0) res = storage.device_resizable(device) self.assertFalse(res.resizable) self.assertEqual(res.error, _("Mounted devices cannot be resized")) self.assertEqual(res.min_size, Size("1 MiB")) self.assertEqual(res.max_size, Size("1 GiB")) + # mounted device, format does support online resize: resizable + device.configure_mock(resizable=True, max_size=Size("2 GiB"), min_size=Size("500 MiB")) + device.format.configure_mock(type="ext4", system_mountpoint="/", _resize_support=FSResize.ONLINE_GROW) + res = storage.device_resizable(device) + self.assertTrue(res.resizable) + self.assertIsNone(res.error) + self.assertEqual(res.min_size, Size("500 MiB")) + self.assertEqual(res.max_size, Size("2 GiB")) + # resizable device device.configure_mock(resizable=True, max_size=Size("2 GiB"), min_size=Size("500 MiB")) device.format.configure_mock(resizable=True, type="ext4", system_mountpoint=None) From 91c118324550fc27b291d22eb26bbc1c9fb06d9c Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Sun, 21 Jul 2024 20:04:13 +0200 Subject: [PATCH 2/3] spec: Bump required version of blive to 3.8.0 Needed for the filesystem online resize feature. --- blivet-gui.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blivet-gui.spec b/blivet-gui.spec index bff88aee..2ebad2c1 100644 --- a/blivet-gui.spec +++ b/blivet-gui.spec @@ -30,7 +30,7 @@ BuildRequires: make Requires: python3 Requires: python3-gobject -Requires: python3-blivet >= 1:3.3.0 +Requires: python3-blivet >= 1:3.8.0 Requires: gtk3 Requires: python3-pid Requires: libreport From a74f99e8b5403ac138753ec24cb49f102330c290 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Sun, 21 Jul 2024 20:05:18 +0200 Subject: [PATCH 3/3] Do not set NTFS as supported This is no longer needed, NTFS is marked as supported in blivet now, see https://github.com/storaged-project/blivet/pull/1016 --- blivetgui/blivet_utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/blivetgui/blivet_utils.py b/blivetgui/blivet_utils.py index c290b3ad..4b916cf3 100644 --- a/blivetgui/blivet_utils.py +++ b/blivetgui/blivet_utils.py @@ -157,10 +157,6 @@ def __init__(self, ignored_disks=None, exclusive_disks=None, flags=None): set_logging(component="blivet") set_logging(component="program") - # allow creating of ntfs format - blivet.formats.fs.NTFS._formattable = True - blivet.formats.fs.NTFS._supported = True - # ignore zram devices blivet.udev.ignored_device_names.append(r"^zram")