Add swap precheck and clean jobs
Before create and add swap on system, check whether swapfile is mounted. If so, try to swapoff the swapfile and remove it. Change-Id: Ic3a9ffc34872a83a491412237369442f369c21d1
This commit is contained in:
parent
a8449161fa
commit
fac24451af
@ -91,6 +91,13 @@ fi
|
||||
|
||||
if [ "${ADD_SWAP}" = true ]; then
|
||||
print_header "Create $SWAP_SIZE_GB GB swapfile"
|
||||
set +e
|
||||
$SUDO swapon -s |grep -q '/swapfile'
|
||||
RESULT=$?
|
||||
set -e
|
||||
if [ $RESULT -eq 0 ]; then
|
||||
swapoff /swapfile && rm -f /swapfile
|
||||
fi
|
||||
$SUDO dd if=/dev/zero of=/swapfile count=${SWAP_SIZE_GB}k bs=1M
|
||||
$SUDO chmod 0600 /swapfile
|
||||
$SUDO mkswap /swapfile
|
||||
|
Loading…
x
Reference in New Issue
Block a user