Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-image-creator
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-image-creator
Commits
fa39c7e3
Commit
fa39c7e3
authored
12 years ago
by
Nikos Skalkotos
Browse files
Options
Downloads
Patches
Plain Diff
Truncate the image before fs creation
parent
63e1b902
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
image_creator/bundle_volume.py
+9
-10
9 additions, 10 deletions
image_creator/bundle_volume.py
with
9 additions
and
10 deletions
image_creator/bundle_volume.py
+
9
−
10
View file @
fa39c7e3
...
...
@@ -418,9 +418,17 @@ class BundleVolume(object):
end_sector
=
self
.
_shrink_partitions
(
image
)
size
=
(
end_sector
+
1
)
*
self
.
disk
.
device
.
sectorSize
# Truncate image to the new size.
fd
=
os
.
open
(
image
,
os
.
O_RDWR
)
try
:
os
.
ftruncate
(
fd
,
size
)
finally
:
os
.
close
(
fd
)
# Check if the available space is enough to host the image
dirname
=
os
.
path
.
dirname
(
image
)
size
=
(
end_sector
+
1
)
*
self
.
disk
.
device
.
sectorSize
self
.
out
.
output
(
"
Examining available space in %s ...
"
%
dirname
,
False
)
stat
=
os
.
statvfs
(
dirname
)
available
=
stat
.
f_bavail
*
stat
.
f_frsize
...
...
@@ -431,15 +439,6 @@ class BundleVolume(object):
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 :
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment