diff --git a/install/OneClickInstall/install-Debian/tools.sh b/install/OneClickInstall/install-Debian/tools.sh index e1265b2522..182f6fb79c 100644 --- a/install/OneClickInstall/install-Debian/tools.sh +++ b/install/OneClickInstall/install-Debian/tools.sh @@ -12,6 +12,8 @@ make_swap () { EXIST=$(swapon -s | awk '{ print $1 }' | { grep -x ${SWAPFILE} || true; }); if [[ -z $EXIST ]] && [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ] && [ ${AVAILABLE_DISK_SPACE} -gt ${DISK_REQUIREMENTS} ]; then + touch "${SWAPFILE}" + [[ "$(df -T / | awk 'NR==2{print $2}')" = "btrfs" ]] && chattr +C "${SWAPFILE}" fallocate -l 6G ${SWAPFILE} chmod 600 ${SWAPFILE} mkswap ${SWAPFILE} diff --git a/install/OneClickInstall/install-RedHat/tools.sh b/install/OneClickInstall/install-RedHat/tools.sh index dcae0ada8e..338a266414 100644 --- a/install/OneClickInstall/install-RedHat/tools.sh +++ b/install/OneClickInstall/install-RedHat/tools.sh @@ -13,13 +13,10 @@ function make_swap () { if [[ -z $EXIST ]] && [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ] && [ ${AVAILABLE_DISK_SPACE} -gt ${DISK_REQUIREMENTS} ]; then touch "$SWAPFILE" - # No Copy-on-Write - no compression - [[ "$DIST" == "fedora" ]] && chattr +C "$SWAPFILE" - # Allocate 6 GB, much faster than: dd if=/dev/zero of=${SWAPFILE} count=6144 bs=1MiB + [[ "$(df -T / | awk 'NR==2{print $2}')" = "btrfs" ]] && chattr +C "$SWAPFILE" fallocate -l 6G "$SWAPFILE" chmod 600 "$SWAPFILE" mkswap "$SWAPFILE" - # Activate, enable upon system boot swapon "$SWAPFILE" echo "$SWAPFILE none swap sw 0 0" >> /etc/fstab fi