From d2d0d18dfd3922411d856b98ab6ba5d64c9c1c9f Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Thu, 28 Apr 2016 13:58:04 +0300 Subject: wic: use truncate utility to create sparse files Used truncate instead of dd to create wic images for the following reasons: - dd doesn't preserve sparseness - truncate syntax is much more clear - dd requires additional calculations of the image size in blocks - the way dd was used in the code is not always correct. In some cases it was writing one block to the file which makes it not 100% sparse. [YOCTO #9099] Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- scripts/lib/wic/utils/fs_related.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'scripts/lib/wic/utils/fs_related.py') diff --git a/scripts/lib/wic/utils/fs_related.py b/scripts/lib/wic/utils/fs_related.py index 2e74461a40..2658dcfc20 100644 --- a/scripts/lib/wic/utils/fs_related.py +++ b/scripts/lib/wic/utils/fs_related.py @@ -71,14 +71,8 @@ class DiskImage(Disk): def create(self): if self.device is not None: return - - blocks = self.size / 1024 - if self.size - blocks * 1024: - blocks += 1 - - # create disk image - dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=1" % \ - (self.image_file, blocks) - exec_cmd(dd_cmd) + # create sparse disk image + cmd = "truncate %s -s %s" % (self.image_file, self.size) + exec_cmd(cmd) self.device = self.image_file -- cgit 1.2.3-korg