1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libreerp_ynh.git synced 2024-09-03 19:36:13 +02:00

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
This commit is contained in:
aynic.os 2024-05-09 15:18:03 +00:00
parent d6e5616b47
commit 3c6ada4635

View file

@ -191,6 +191,17 @@ ynh_add_swap () {
# If there's enough space for a swap, and no existing swap here # If there's enough space for a swap, and no existing swap here
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ] if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]
then 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 # 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 if ! fallocate -l ${swap_size}K /swap_$app
then then