From cb4a6e0d02782c75cf270276667ea2f062afd051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 26 Aug 2022 08:01:37 +0200 Subject: [PATCH] fix swap --- scripts/experimental_helper.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 6df5480..08d405e 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -72,6 +72,12 @@ 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 + # Create file + truncate -s 0 /swap_$app + + # set the No_COW attribute on the swapfile with chattr + chattr +C /swap_$app || true + # 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 @@ -81,7 +87,7 @@ ynh_add_swap () { # Create the swap mkswap /swap_$app # And activate it - swapon /swap_$app + swapon /swap_$app || true # Then add an entry in fstab to load this swap at each boot. echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab fi @@ -115,4 +121,3 @@ ynh_is_main_device_a_sd_card () { return 1 fi } -