David Cantrell wrote: > On existing ext2 and ext3 filesystems, initialize our size property > to the size of the filesystem in megabytes. Initialize targetSize > to the size in megabytes of the used space. Use dumpe2fs to collect > size information as the size does not necessarily match with the > underlying StorageDevice this format sits on. Just to double check; I assume ext4 inherits this too right? Also just to check; do you assume that you can shrink to that minimum size or is that just a rough target? FWIW, resize2fs -P *should* give you the minimum size for the fs, with the necessary intricate details. -P Print the minimum size of the filesystem and exit. -Eric > --- > storage/formats/fs.py | 35 +++++++++++++++++++++++++++++++++++ > 1 files changed, 35 insertions(+), 0 deletions(-) > > diff --git a/storage/formats/fs.py b/storage/formats/fs.py > index 0c66d38..7579122 100644 > --- a/storage/formats/fs.py > +++ b/storage/formats/fs.py > @@ -26,6 +26,7 @@ > - migration > - bug 472127: allow creation of tmpfs filesystems (/tmp, /var/tmp, &c) > """ > +import math > import os > import isys > > @@ -704,6 +705,40 @@ class Ext2FS(FS): > _migratefs = "tune2fs" > _defaultMigrateOptions = ["-j"] > > + def __init__(self, *args, **kwargs): > + FS.__init__(self, *args, **kwargs) > + > + # get size of existing filesystem > + if self.exists: > + blockCount = None > + blockSize = None > + freeBlocks = None > + > + buf = iutil.execWithCapture('dumpe2fs', ['-h', self.device], > + stderr="/dev/tty5") > + > + for line in buf.splitlines(): > + tmp = line.split(' ') > + > + if line.startswith('Block count:'): > + blockCount = long(tmp[len(tmp) - 1]) > + elif line.startswith('Block size:'): > + blockSize = long(tmp[len(tmp) - 1]) > + elif line.startswith('Free blocks:'): > + freeBlocks = long(tmp[len(tmp) - 1]) > + > + if blockCount and blockSize and freeBlocks: > + break > + > + total = blockCount * blockSize > + free = freeBlocks * blockSize > + > + # report current size as megabytes > + self._size = total / 1024.0 / 1024.0 > + > + # set target size to used space > + self.targetSize = math.ceil(total - free) / 1024.0 / 1024.0 > + > @property > def minSize(self): > """ Minimum size for this filesystem in MB. """ _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list