Blame SOURCES/0016-Automatically-adjust-size-of-growable-devices-for-new-format.patch

3187bc
From caec289d8220fc9a8d8b3d6e99271394f4ef83fe Mon Sep 17 00:00:00 2001
3187bc
From: Vojtech Trefny <vtrefny@redhat.com>
3187bc
Date: Wed, 27 Feb 2019 12:26:30 +0100
3187bc
Subject: [PATCH] Automatically adjust size of growable devices for new format
3187bc
3187bc
Without this kickstart 'part /home --size=1 --grow --encrypted'
3187bc
will fail because min size for LUKS is 2 MiB.
3187bc
3187bc
Resolves: rhbz#1680013
3187bc
---
3187bc
 blivet/devices/storage.py | 7 ++++++-
3187bc
 1 file changed, 6 insertions(+), 1 deletion(-)
3187bc
3187bc
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
3187bc
index 904b60df..9d6001e8 100644
3187bc
--- a/blivet/devices/storage.py
3187bc
+++ b/blivet/devices/storage.py
3187bc
@@ -721,7 +721,12 @@ def _set_format(self, fmt):
3187bc
             if fmt.max_size and fmt.max_size < self.size:
3187bc
                 raise errors.DeviceError("device is too large for new format")
3187bc
             elif fmt.min_size and fmt.min_size > self.size:
3187bc
-                raise errors.DeviceError("device is too small for new format")
3187bc
+                if self.growable:
3187bc
+                    log.info("%s: using size %s instead of %s to accommodate "
3187bc
+                             "format minimum size", self.name, fmt.min_size, self.size)
3187bc
+                    self.size = fmt.min_size
3187bc
+                else:
3187bc
+                    raise errors.DeviceError("device is too small for new format")
3187bc
 
3187bc
         if self._format != fmt:
3187bc
             callbacks.format_removed(device=self, fmt=self._format)