Skip to content

Commit

Permalink
Merge pull request #442 from vojtechtrefny/main_fs-online-resize
Browse files Browse the repository at this point in the history
Add support for filesystem online resize
  • Loading branch information
vojtechtrefny committed Jul 21, 2024
2 parents 8fd1f81 + a74f99e commit d2e8b1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion blivet-gui.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions blivetgui/blivet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,15 @@ 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")

# set blivet flags
if flags:
self._set_blivet_flags(flags)

blivet.flags.flags.allow_online_fs_resize = True

self.blivet_reset()
self._update_min_sizes_info()

Expand Down Expand Up @@ -727,7 +725,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)
Expand Down
14 changes: 12 additions & 2 deletions tests/blivetgui_tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from blivetgui.i18n import _

from blivet.size import Size
from blivet.formats.fslib import FSResize


class FreeSpaceDeviceTest(unittest.TestCase):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d2e8b1f

Please sign in to comment.