From: Nikos Skalkotos Date: Fri, 24 Aug 2012 09:48:18 +0000 (+0300) Subject: Make the cow file size equal to the original media X-Git-Tag: v0.1~29 X-Git-Url: https://code.grnet.gr/git/snf-image-creator/commitdiff_plain/8fed77f7fce8dd2d4793e9300b8aee904b00bdc3 Make the cow file size equal to the original media The size of the cow file was hardcoded to 1G. This was buggy, because for a big image, the resize operation could fill up the cow file and fail. --- diff --git a/image_creator/disk.py b/image_creator/disk.py index 7e3b166..c367efd 100644 --- a/image_creator/disk.py +++ b/image_creator/disk.py @@ -114,12 +114,12 @@ class Disk(object): # Take a snapshot and return it to the user self.out.output("Snapshotting media source...", False) - size = blockdev('--getsize', sourcedev) + size = blockdev('--getsz', sourcedev) cowfd, cow = tempfile.mkstemp() os.close(cowfd) self._add_cleanup(os.unlink, cow) - # Create 1G cow sparse file - dd('if=/dev/null', 'of=%s' % cow, 'bs=1k', 'seek=%d' % (1024 * 1024)) + # Create cow sparse file + dd('if=/dev/null', 'of=%s' % cow, 'bs=512', 'seek=%d' % int(size)) cowdev = self._losetup(cow) snapshot = uuid.uuid4().hex