From 3c6ada4635aadbd0700d00cecfd8f0b8bafa0970 Mon Sep 17 00:00:00 2001 From: "aynic.os" Date: Thu, 9 May 2024 15:18:03 +0000 Subject: [PATCH] add btrfs support in install script When / is mounted on a btrfs filesystem, the install fails to add swap with the following error : swapon: /swap_libreerp: swapon failed: Invalid argument --- scripts/_common.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index ededc6c..9d48d55 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -191,6 +191,17 @@ 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 + # Check if / is mounted on btrfs + if [ "$(awk '$2 == "/" {print $3}' /proc/mounts)" = "btrfs" ] + then + if [ "$(uname -r | awk -F. '{print $1}')" -lt 5 ] + then + ynh_print_warn --message="The main mountpoint of your system '/' is on an BTRFS filesystem, but current kernel does not support swap files on BTRFS. Swap file will not be added to prevent file system corruption. If you still want to activate the swap, please update your kernel to at least version 5." + return + fi + truncate -s 0 /swap_$app + chattr +C /swap_$app + fi # 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