projects
/
snf-image-creator
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
69a4f89
)
In bundle_volume truncate img file after shrinking
author
Nikos Skalkotos
<skalkoto@grnet.gr>
Sat, 29 Dec 2012 16:30:02 +0000
(18:30 +0200)
committer
Nikos Skalkotos
<skalkoto@grnet.gr>
Sat, 29 Dec 2012 16:33:15 +0000
(18:33 +0200)
image_creator/bundle_volume.py
patch
|
blob
|
history
diff --git
a/image_creator/bundle_volume.py
b/image_creator/bundle_volume.py
index
afcc6b8
..
9f08276
100644
(file)
--- a/
image_creator/bundle_volume.py
+++ b/
image_creator/bundle_volume.py
@@
-219,7
+219,7
@@
class BundleVolume():
image_disk.setPartitionGeometry(
image_disk.getPartitionBySector(last.start),
parted.Constraint(device=image_disk.device),
image_disk.setPartitionGeometry(
image_disk.getPartitionBySector(last.start),
parted.Constraint(device=image_disk.device),
- start=last.start, end=last.end)
+ start=last.start, end=part_end)
image_disk.commit()
# Parted may have changed this for better alignment
image_disk.commit()
# Parted may have changed this for better alignment
@@
-228,7
+228,7
@@
class BundleVolume():
partitions[-1] = last
# Leave 2048 blocks at the end.
partitions[-1] = last
# Leave 2048 blocks at the end.
- new_end = new_size + 2048
+ new_end = part_end + 2048
if last.type == parted.PARTITION_LOGICAL:
# Fix the extended partition
if last.type == parted.PARTITION_LOGICAL:
# Fix the extended partition
@@
-239,6
+239,7
@@
class BundleVolume():
ext.geometry.start, end=last.end)
image_disk.commit()
ext.geometry.start, end=last.end)
image_disk.commit()
+ image_dev.destroy()
return new_end
def _map_partition(self, dev, num, start, end):
return new_end
def _map_partition(self, dev, num, start, end):
@@
-417,6
+418,15
@@
class BundleVolume():
self._create_filesystems(image)
self._create_filesystems(image)
+ # Truncate image to the new size. I counldn't find a better way to do
+ # this. It seems that python's high level functions work in a different
+ # way.
+ fd = os.open(image, os.O_RDWR)
+ try:
+ os.ftruncate(fd, size)
+ finally:
+ os.close(fd)
+
return image
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
return image
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :