1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libreerp_ynh.git synced 2024-09-03 19:36:13 +02:00
This commit is contained in:
Yann Autissier 2024-05-24 13:40:59 +02:00 committed by GitHub
commit e1a5266dcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -190,6 +190,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