[PATCH 3/6] Align end sector in the appropriate direction for resize. (#1120964)

David Lehman dlehman at redhat.com
Tue Oct 28 19:20:00 UTC 2014


When shrinking, align the end sector up to ensure the aligned partition
is still larger than the formatting's minimum size.

When growing, align the end sector down to ensure the aligned partition
is completely within the free region (and not larger than the formatting's
maximum size).
---
 blivet/devices/partition.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
index 6ad107a..e419ce7 100644
--- a/blivet/devices/partition.py
+++ b/blivet/devices/partition.py
@@ -582,8 +582,14 @@ class PartitionDevice(StorageDevice):
                                       start=currentGeom.start,
                                       length=newLen)
         # and align the end sector
-        newGeometry.end = self.disk.format.endAlignment.alignDown(newGeometry,
-                                                               newGeometry.end)
+        if newGeometry.length < currentGeom.length:
+            align = self.disk.format.endAlignment.alignUp
+            alignGeom = currentGeom # we can align up into the old geometry
+        else:
+            align = self.disk.format.endAlignment.alignDown
+            alignGeom = newGeometry
+
+        newGeometry.end = align(alignGeom, newGeometry.end)
         constraint = parted.Constraint(exactGeom=newGeometry)
 
         return (constraint, newGeometry)
-- 
1.9.3



More information about the anaconda-patches mailing list