[blivet][PATCH] Make space for LUKS metadata if creating encrypted device (#1038847)
Vratislav Podzimek
vpodzime at redhat.com
Wed Dec 11 11:07:39 UTC 2013
LUKS needs 2 MB of space for its metadata, so we should bump up the size of
newly created encrypted devices.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
blivet/devicefactory.py | 10 ++++++++++
blivet/formats/luks.py | 1 +
2 files changed, 11 insertions(+)
diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py
index 090157a..ab7a69c 100644
--- a/blivet/devicefactory.py
+++ b/blivet/devicefactory.py
@@ -247,6 +247,11 @@ class DeviceFactory(object):
container_encrypted whether to encrypt the entire container
container_size requested container size
"""
+
+ if encrypted and size:
+ # encrypted, bump size up with LUKS metadata size
+ size += getFormat("luks").minSize
+
self.storage = storage # a Blivet instance
self.size = size # the requested size for this device
self.disks = disks # the set of disks to allocate from
@@ -799,6 +804,11 @@ class PartitionFactory(DeviceFactory):
self.__fmt = getattr(self, "__fmt", getFormat(self.fstype))
min_format_size = self.__fmt.minSize
+ # min_format_size may be None here, make sure it is a number
+ min_format_size = min_format_size or 0
+ if self.encrypted:
+ min_format_size += getFormat("luks").minSize
+
return max(1, min_format_size)
def _get_device_size(self):
diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py
index 0f1889e..8f9ae7b 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):
""" Create a LUKS instance.
--
1.8.4.2
More information about the anaconda-patches
mailing list