Merge pull request #3441 from djs55/swap-bigger-blocksize

swap: speed up by preferring a 1MiB blocksize
This commit is contained in:
Rolf Neugebauer 2019-12-19 17:38:22 +00:00 committed by GitHub
commit 2475233653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,7 +123,12 @@ fi
if [ ! -f $path ] || ! [ $(stat -c "%s" $path) == $(disksize_to_count 1 $size) ]; then if [ ! -f $path ] || ! [ $(stat -c "%s" $path) == $(disksize_to_count 1 $size) ]; then
## Allocate the file ## Allocate the file
dd if=/dev/zero of=$path bs=1024 count=$(disksize_to_count 1024 $size) ## If possible use a large blocksize:
bs=1048576 # 1 MiB
if [ "$size" -lt "$bs" ]; then
bs=1024 # fall back to 1KiB
fi
dd if=/dev/zero of=$path bs=$bs count=$(disksize_to_count $bs $size)
chmod 0600 $path chmod 0600 $path
## was it encrypted? use cryptsetup and get the mapped device ## was it encrypted? use cryptsetup and get the mapped device