diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-04-28 13:58:04 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-06 10:31:12 +0100 |
commit | d03cbac7960c8f39019f2f428647e8100ddc5da0 (patch) | |
tree | 7015264912dc51b07ca6819dd25f0d48c547d97e /scripts/lib/wic/utils | |
parent | e93254b482c09aba884160ea6fea3756702cb1e8 (diff) | |
download | poky-d03cbac7960c8f39019f2f428647e8100ddc5da0.tar.gz |
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]
(From OE-Core rev: d2d0d18dfd3922411d856b98ab6ba5d64c9c1c9f)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/utils')
-rw-r--r-- | scripts/lib/wic/utils/fs_related.py | 12 |
1 files changed, 3 insertions, 9 deletions
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): | |||
71 | def create(self): | 71 | def create(self): |
72 | if self.device is not None: | 72 | if self.device is not None: |
73 | return | 73 | return |
74 | 74 | # create sparse disk image | |
75 | blocks = self.size / 1024 | 75 | cmd = "truncate %s -s %s" % (self.image_file, self.size) |
76 | if self.size - blocks * 1024: | 76 | exec_cmd(cmd) |
77 | blocks += 1 | ||
78 | |||
79 | # create disk image | ||
80 | dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=1" % \ | ||
81 | (self.image_file, blocks) | ||
82 | exec_cmd(dd_cmd) | ||
83 | 77 | ||
84 | self.device = self.image_file | 78 | self.device = self.image_file |