Blivet should be able to resize empty devices.
There is no way to tell, if a device is empty or has unknown filesystem,
so let's allow resize them all and hope that admin knows what he's doing,
OpenLMI is fine with that.
This may have impact on GUI, users might be able to resize devices with unknown
filesystems like UFS2 and destroy its data. Maybe the DeviceFormat should be
resizable only in non-installer mode?
---
blivet/formats/__init__.py | 17 ++++++++++++++++-
blivet/formats/biosboot.py | 1 +
blivet/formats/disklabel.py | 1 +
blivet/formats/fs.py | 1 +
blivet/formats/luks.py | 1 +
blivet/formats/lvmpv.py | 1 +
blivet/formats/mdraid.py | 3 ++-
blivet/formats/prepboot.py | 1 +
blivet/formats/swap.py | 1 +
9 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py
index f018c6c..9d10351 100644
--- a/blivet/formats/__init__.py
+++ b/blivet/formats/__init__.py
@@ -154,7 +154,7 @@ class DeviceFormat(object):
_linuxNative = False # for clearpart
_packages = [] # required packages
_services = [] # required services
- _resizable = False # can be resized
+ _resizable = True # can be resized
_maxSize = 0 # maximum size in MB
_minSize = 0 # minimum size in MB
_dump = False
@@ -439,4 +439,19 @@ class DeviceFormat(object):
(udev_device_get_major(dev), udev_device_get_minor(dev))
return self._majorminor
+ def doResize(self):
+ """ Resize this filesystem to new size @newsize.
+
+ Arguments:
+
+ None
+ """
+ if not self.exists:
+ raise FSResizeError("format does not exist", self.device)
+ if not self.resizable:
+ raise FSResizeError("format not resizable", self.device)
+ if self.targetSize == self.currentSize:
+ return
+ self._size = self.targetSize
+
collect_device_format_classes()
diff --git a/blivet/formats/biosboot.py b/blivet/formats/biosboot.py
index c3aef8d..9d2f11e 100644
--- a/blivet/formats/biosboot.py
+++ b/blivet/formats/biosboot.py
@@ -36,6 +36,7 @@ class BIOSBoot(DeviceFormat):
_linuxNative = True # for clearpart
_maxSize = 2 # maximum size in MB
_minSize = 0.5 # minimum size in MB
+ _resizable = False # can be resized
def __init__(self, *args, **kwargs):
""" Create a BIOSBoot instance.
diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py
index 90b73f3..8d7766e 100644
--- a/blivet/formats/disklabel.py
+++ b/blivet/formats/disklabel.py
@@ -45,6 +45,7 @@ class DiskLabel(DeviceFormat):
_name = "partition table"
_formattable = True # can be formatted
_supported = False # is supported
+ _resizable = False # can be resized
def __init__(self, *args, **kwargs):
""" Create a DiskLabel instance.
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index ed7eac3..356404f 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -130,6 +130,7 @@ class FS(DeviceFormat):
_defaultInfoOptions = []
_existingSizeFields = []
_fsProfileSpecifier = None # mkfs option specifying fsprofile
+ _resizable = False # can be resized
def __init__(self, *args, **kwargs):
""" Create a FS instance.
diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py
index ab12eba..dfd1d82 100644
--- a/blivet/formats/luks.py
+++ b/blivet/formats/luks.py
@@ -51,6 +51,7 @@ class LUKS(DeviceFormat):
_supported = False # is supported
_linuxNative = True # for clearpart
_packages = ["cryptsetup-luks"] # required packages
+ _resizable = False # can be resized
def __init__(self, *args, **kwargs):
""" Create a LUKS instance.
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
index 300b849..6edf9df 100644
--- a/blivet/formats/lvmpv.py
+++ b/blivet/formats/lvmpv.py
@@ -46,6 +46,7 @@ class LVMPhysicalVolume(DeviceFormat):
_linuxNative = True # for clearpart
_minSize = lvm.LVM_PE_SIZE * 2 # one for metadata and one for data
_packages = ["lvm2"] # required packages
+ _resizable = False # can be resized
def __init__(self, *args, **kwargs):
""" Create an LVMPhysicalVolume instance.
diff --git a/blivet/formats/mdraid.py b/blivet/formats/mdraid.py
index a99dec8..a57c93a 100644
--- a/blivet/formats/mdraid.py
+++ b/blivet/formats/mdraid.py
@@ -46,7 +46,8 @@ class MDRaidMember(DeviceFormat):
_supported = True # is supported
_linuxNative = True # for clearpart
_packages = ["mdadm"] # required packages
-
+ _resizable = False # can be resized
+
def __init__(self, *args, **kwargs):
""" Create a MDRaidMember instance.
diff --git a/blivet/formats/prepboot.py b/blivet/formats/prepboot.py
index c7ed111..4e7f2fb 100644
--- a/blivet/formats/prepboot.py
+++ b/blivet/formats/prepboot.py
@@ -38,6 +38,7 @@ class PPCPRePBoot(DeviceFormat):
_linuxNative = True # for clearpart
_maxSize = 10 # maximum size in MB
_minSize = 4 # minimum size in MB
+ _resizable = False # can be resized
def __init__(self, *args, **kwargs):
""" Create a PRePBoot instance.
diff --git a/blivet/formats/swap.py b/blivet/formats/swap.py
index da8f4df..ced63b3 100644
--- a/blivet/formats/swap.py
+++ b/blivet/formats/swap.py
@@ -44,6 +44,7 @@ class SwapSpace(DeviceFormat):
_formattable = True # can be formatted
_supported = True # is supported
_linuxNative = True # for clearpart
+ _resizable = False # can be resized
#see rhbz#744129 for details
_maxSize = 128 * 1024