From 951a1bbf9c299d6eac588a4f6e8d3c9b792575e4 Mon Sep 17 00:00:00 2001 From: Kayou Date: Sun, 12 May 2019 18:59:07 +0200 Subject: [PATCH] Fix fallocate can't be used --- scripts/_common.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f8ec859..1caa856 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -76,8 +76,11 @@ ynh_add_swap () { # If there's enough space for a swap, and no existing swap here if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ] then - # Preallocate space for the swap file - fallocate -l ${swap_size}K /swap_$app + # Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case + if ! fallocate -l ${swap_size}K /swap_$app + then + dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size} + fi chmod 0600 /swap_$app # Create the swap mkswap /swap_$app