Skip to content

Commit

Permalink
qvm-template-postprocess: call fstrim after removing image file
Browse files Browse the repository at this point in the history
This is especially important on LVM thin pool, where space after
removing the file needs to be given back to the pool, to be reused for
other volumes (for example this template).
  • Loading branch information
marmarek committed Mar 4, 2018
1 parent 090cccd commit 4a9b57f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qubesadmin/tools/qvm_template_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ def post_install(args):

if not args.keep_source:
shutil.rmtree(args.dir)
# if running as root, tell underlying storage layer about just freed
# data blocks
if os.getuid() == 0:
subprocess.call(['sync', '-f', os.path.dirname(args.dir)])
subprocess.call(['fstrim', os.path.dirname(args.dir)])

return 0

Expand Down

0 comments on commit 4a9b57f

Please sign in to comment.