[OE-core] [wic][PATCH 1/6] wic: use truncate utility to create sparse file

Ed Bartosh ed.bartosh at linux.intel.com
Thu Apr 28 08:53:27 UTC 2016


Please, igrnore. I'll send updated patchset today.

On Thu, Apr 28, 2016 at 10:14:52AM +0300, Ed Bartosh wrote:
> 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 at 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
> 

-- 
--
Regards,
Ed



More information about the Openembedded-core mailing list