All of lore.kernel.org
 help / color / mirror / Atom feed
* [wic][PATCH 1/6] wic: use truncate utility to create sparse file
@ 2016-04-28  7:14 Ed Bartosh
  2016-04-28  7:14 ` [wic][PATCH 2/6] wic: get rid of inheritance Disk->DiskImage Ed Bartosh
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ed Bartosh @ 2016-04-28  7:14 UTC (permalink / raw)
  To: openembedded-core

Used truncate instead of dd to create wic image for the
following reasons:
 - 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 entirely correct.
   It was still writing one block to the file, which made it not
   100% sparse.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 scripts/lib/wic/utils/fs_related.py | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/scripts/lib/wic/utils/fs_related.py b/scripts/lib/wic/utils/fs_related.py
index 2e74461..2658dcf 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
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-04-28 11:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-28  7:14 [wic][PATCH 1/6] wic: use truncate utility to create sparse file Ed Bartosh
2016-04-28  7:14 ` [wic][PATCH 2/6] wic: get rid of inheritance Disk->DiskImage Ed Bartosh
2016-04-28  7:14 ` [wic][PATCH 3/6] wic: get rid of fs_related.makedirs Ed Bartosh
2016-04-28  7:14 ` [wic][PATCH 4/6] wic: moved DiskImage to direct.py Ed Bartosh
2016-04-28  7:14 ` [wic][PATCH 5/6] wic: add FIEMAP/SEEK_HOLE APIs from bmaptool Ed Bartosh
2016-04-28  7:14 ` [wic][PATCH 6/6] wic: use sparse_copy to copy partitions Ed Bartosh
2016-04-28  8:53 ` [wic][PATCH 1/6] wic: use truncate utility to create sparse file Ed Bartosh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.