Skip to content

Commit

Permalink
Disable swap before OS Update (#333)
Browse files Browse the repository at this point in the history
Mask all swap targets.

Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
  • Loading branch information
mdhorn authored Dec 17, 2020
1 parent e74b3ca commit 5ca6454
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions clr-k8s-examples/setup_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ function add_os_deps() {

# permanently disable swap
function disable_swap() {
swapcount=$(sudo grep '^/dev/\([0-9a-z]*\).*' /proc/swaps | wc -l)

if [ "$swapcount" != "0" ]; then
sudo systemctl mask "$(sed -n -e 's#^/dev/\([0-9a-z]*\).*#dev-\1.swap#p' /proc/swaps)" 2>/dev/null
else
echo "Swap not enabled"
fi
# disable current swap
sudo swapoff -a
# permanently disable swap
sudo systemctl mask swap.target
}

# enable ip forwarding
Expand Down Expand Up @@ -137,7 +134,6 @@ function enable_kubelet_runner() {

# ensure that the system is ready without requiring a reboot
function ensure_system_ready() {
sudo swapoff -a
sudo systemctl restart systemd-modules-load.service
}

Expand Down Expand Up @@ -192,12 +188,12 @@ fi

echo "Init..."
init
echo "Disabling swap..."
disable_swap
echo "Setting OS Version..."
upate_os_version
echo "Adding OS Dependencies..."
add_os_deps
echo "Disabling swap..."
disable_swap
echo "Enabling IP Forwarding..."
enable_ip_forwarding
echo "Setting up modules to load..."
Expand Down

0 comments on commit 5ca6454

Please # to comment.