[blivet][PATCH] Make sure LUKS metadata fit in to the newly created device (#1038847)

David Lehman dlehman at redhat.com
Tue Dec 10 16:58:41 UTC 2013


On Tue, 2013-12-10 at 17:45 +0100, Vratislav Podzimek wrote:
> On Tue, 2013-12-10 at 10:40 -0600, David Lehman wrote:
> > On Tue, 2013-12-10 at 17:22 +0100, Vratislav Podzimek wrote:
> > > If there is a request to create encrypted device smaller than LUKS metadata
> > > size, we should bump up the requested size with the metadata size to make sure
> > > it fits in and negative values are not reported.
> > 
> > I think this should fix LUKS._minSize to reflect the metadata size and
> > then use the minSize property so it can be a generic solution instead of
> > only solving this problem for LUKS.
> > 
> > I'm also wondering if we should be raising an exception instead of
> > quietly adjusting the size like this.
> I'd like to fix this somehow for F20 ASAP. I'll try the _minSize
> approach tomorrow, but I'm not sure I'll be able to come up with such
> cleaner solution in one day without risk of breaking a lot of other
> things.

I just noticed the bug is related to the device factory. How about
something along these lines:

diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py
index 97d8f89..89999ff 100644
--- a/blivet/devicefactory.py
+++ b/blivet/devicefactory.py
@@ -802,6 +802,9 @@ class PartitionFactory(DeviceFactory):
             self.__fmt = getattr(self, "__fmt", getFormat(self.fstype))
             min_format_size = self.__fmt.minSize
 
+        if self.encrypted:
+            min_format_size += getFormat("luks").minSize
+
         return max(Size(en_spec="1MB"), min_format_size)
 
     def _get_device_size(self):
diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py
index 33705ec..137e585 100644
--- a/blivet/formats/luks.py
+++ b/blivet/formats/luks.py
@@ -50,6 +50,7 @@ class LUKS(DeviceFormat):
     _supported = False                  # is supported
     _linuxNative = True                 # for clearpart
     _packages = ["cryptsetup-luks"]     # required packages
+    _minSize = crypto.LUKS_METADATA_SIZE
 
     def __init__(self, *args, **kwargs):
         """

David



More information about the anaconda-patches mailing list