Commit 827b7b90 authored by Scott Moser's avatar Scott Moser

swap: create swap with fallocate if possible

fallocate is much faster than 'dd' for creating and initializing a
swap file.

LP: #1482994
parent a9c1e3f7
......@@ -206,7 +206,8 @@ def setup_swapfile(fname, size=None, maxsize=None):
util.log_time(LOG.debug, msg, func=util.subp,
args=[['sh', '-c',
('rm -f "$1" && umask 0066 && '
'dd if=/dev/zero "of=$1" bs=1M "count=$2" && '
'{ fallocate -l "${2}M" "$1" || '
' dd if=/dev/zero "of=$1" bs=1M "count=$2"; } && '
'mkswap "$1" || { r=$?; rm -f "$1"; exit $r; }'),
'setup_swap', fname, mbsize]])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment