summaryrefslogtreecommitdiffstats
path: root/storage/formats/fs.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-10-29 16:46:22 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-10-29 17:55:50 -1000
commit81db293d502cdfbd70665572f940b1cf5fb4dfbb (patch)
tree2515d99d297108fe0ab8208d09f1d32acf051784 /storage/formats/fs.py
parent576f138544016634ceb33df83636eda40d392f25 (diff)
downloadanaconda-81db293d502cdfbd70665572f940b1cf5fb4dfbb.tar.gz
anaconda-81db293d502cdfbd70665572f940b1cf5fb4dfbb.tar.xz
anaconda-81db293d502cdfbd70665572f940b1cf5fb4dfbb.zip
Fix "resize failed: 1" errors for ext2/ext3/ext4 (#517491).
The following install test case has been failing: https://fedoraproject.org/wiki/QA:Testcase_Anaconda_autopart_%28shrink%29_install The problem was with the minSize property in Ext2FS. We use resize2fs to get the minSize for ext2/3/4 filesystems, which is good because resize2fs accounts for additional things an extX volume may need. The problem is the value it reports is in blocks. We have to convert those blocks to bytes, then to megabytes, then round up to account for any fractional megabytes. Use dumpe2fs to get the block size and use resize2fs as we have been, but modify the calculation of size. Also the _setTargetSize() method in FS needed a change. minSize can be less than or equal to newsize, not just less than.
Diffstat (limited to 'storage/formats/fs.py')
-rw-r--r--storage/formats/fs.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 493abb62e..12f624f22 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -169,7 +169,7 @@ class FS(DeviceFormat):
self._targetSize = None
return
- if not self.minSize < newsize < self.maxSize:
+ if not self.minSize <= newsize < self.maxSize:
raise ValueError("invalid target size request")
self._targetSize = newsize
@@ -909,7 +909,23 @@ class Ext2FS(FS):
# try once in the beginning to get the minimum size for an
# existing filesystem.
size = self._minSize
+ blockSize = None
+
if self.exists and os.path.exists(self.device):
+ # get block size
+ buf = iutil.execWithCapture(self.infofsProg,
+ ["-h", self.device],
+ stderr="/dev/tty5")
+ for line in buf.splitlines():
+ if line.startswith("Block size:"):
+ blockSize = int(line.split(" ")[-1])
+ break
+
+ if blockSize is None:
+ raise FSError("failed to get block size for %s filesystem "
+ "on %s" % (self.mountType, self.device))
+
+ # get minimum size according to resize2fs
buf = iutil.execWithCapture(self.resizefsProg,
["-P", self.device],
stderr="/dev/tty5")
@@ -917,9 +933,15 @@ class Ext2FS(FS):
if "minimum size of the filesystem:" not in line:
continue
+ # line will look like:
+ # Estimated minimum size of the filesystem: 1148649
+ #
+ # NOTE: The minimum size reported is in blocks. Convert
+ # to bytes, then megabytes, and finally round up.
(text, sep, minSize) = line.partition(": ")
-
- size = int(minSize) / 1024.0
+ size = long(minSize) * blockSize
+ size = math.ceil(size / 1024.0 / 1024.0)
+ break
if size is None:
log.warning("failed to get minimum size for %s filesystem "