Skip to content

Commit

Permalink
Check result of swapon. May fail on openvz.
Browse files Browse the repository at this point in the history
  • Loading branch information
swelljoe committed Aug 5, 2017
1 parent 27fb2c6 commit 000f159
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions slib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 000f159

Please sign in to comment.