From 8fed77f7fce8dd2d4793e9300b8aee904b00bdc3 Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Fri, 24 Aug 2012 12:48:18 +0300 Subject: [PATCH] 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. --- image_creator/disk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 1.7.10.4