Fix swap.sh (#3897)

The script used to compare “10M” with “10” as if
they were both integers.

Signed-off-by: David Gageot <david.gageot@docker.com>

Signed-off-by: David Gageot <david.gageot@docker.com>
This commit is contained in:
David Gageot 2023-01-12 10:50:47 +01:00 committed by GitHub
parent e668b25a82
commit f9f1ec7de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,11 +121,13 @@ else
SWAPDEV=$path
fi
if [ ! -f $path ] || ! [ $(stat -c "%s" $path) == $(disksize_to_count 1 $size) ]; then
count="$(disksize_to_count 1 $size)"
if [ ! -f $path ] || ! [ $(stat -c "%s" $path) == $count ]; then
## Allocate the file
## If possible use a large blocksize:
bs=1048576 # 1 MiB
if [ "$size" -lt "$bs" ]; then
if [ "$count" -lt "$bs" ]; then
bs=1024 # fall back to 1KiB
fi
dd if=/dev/zero of=$path bs=$bs count=$(disksize_to_count $bs $size)