summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/partition.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r--scripts/lib/wic/partition.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 90f65a1e39..89c33ab8b7 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -217,7 +217,8 @@ class Partition():
217 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ 217 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
218 (extra_blocks, self.mountpoint, rootfs_size)) 218 (extra_blocks, self.mountpoint, rootfs_size))
219 219
220 exec_cmd("truncate %s -s %d" % (rootfs, rootfs_size * 1024)) 220 with open(rootfs, 'w') as sparse:
221 os.ftruncate(sparse.fileno(), rootfs_size * 1024)
221 222
222 extra_imagecmd = "-i 8192" 223 extra_imagecmd = "-i 8192"
223 224
@@ -250,7 +251,8 @@ class Partition():
250 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ 251 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
251 (extra_blocks, self.mountpoint, rootfs_size)) 252 (extra_blocks, self.mountpoint, rootfs_size))
252 253
253 exec_cmd("truncate %s -s %d" % (rootfs, rootfs_size * 1024)) 254 with open(rootfs, 'w') as sparse:
255 os.ftruncate(sparse.fileno(), rootfs_size * 1024)
254 256
255 label_str = "" 257 label_str = ""
256 if self.label: 258 if self.label:
@@ -305,7 +307,8 @@ class Partition():
305 """ 307 """
306 Prepare an empty ext2/3/4 partition. 308 Prepare an empty ext2/3/4 partition.
307 """ 309 """
308 exec_cmd("truncate %s -s %d" % (rootfs, self.size * 1024)) 310 with open(rootfs, 'w') as sparse:
311 os.ftruncate(sparse.fileno(), rootfs_size * 1024)
309 312
310 extra_imagecmd = "-i 8192" 313 extra_imagecmd = "-i 8192"
311 314
@@ -322,7 +325,8 @@ class Partition():
322 """ 325 """
323 Prepare an empty btrfs partition. 326 Prepare an empty btrfs partition.
324 """ 327 """
325 exec_cmd("truncate %s -s %d" % (rootfs, self.size * 1024)) 328 with open(rootfs, 'w') as sparse:
329 os.ftruncate(sparse.fileno(), rootfs_size * 1024)
326 330
327 label_str = "" 331 label_str = ""
328 if self.label: 332 if self.label:
@@ -383,7 +387,8 @@ class Partition():
383 """ 387 """
384 path = "%s/fs.%s" % (cr_workdir, self.fstype) 388 path = "%s/fs.%s" % (cr_workdir, self.fstype)
385 389
386 exec_cmd("truncate %s -s %d" % (path, self.size * 1024)) 390 with open(path, 'w') as sparse:
391 os.ftruncate(sparse.fileno(), self.size * 1024)
387 392
388 import uuid 393 import uuid
389 label_str = "" 394 label_str = ""