From 000f1591b7296294b21a6cd9165af24716fa9f7d Mon Sep 17 00:00:00 2001 From: Joe Cooper Date: Sat, 5 Aug 2017 00:01:43 -0500 Subject: [PATCH] Check result of swapon. May fail on openvz. --- slib.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/slib.sh b/slib.sh index fd5d6f1..683c1af 100644 --- a/slib.sh +++ b/slib.sh @@ -616,12 +616,15 @@ memory_ok () { # Create a new file if ! dd if=/dev/zero of=/swapfile bs=1024 count=$swap_min; then - log_fatal "Creating swap file /swapfile failed: $res" + log_fatal "Creating swap file /swapfile failed." return 4 fi chmod 0600 /swapfile mkswap /swapfile - swapon /swapfile + if ! swapon /swapfile; then + log_fatal "Enabling swap file failed. If this is a VM, it may be prohibited by your provider." + return 5 + fi echo "/swapfile swap swap defaults 0 0" >> /etc/fstab return 0 }