Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 5ca6454

Browse files
authored
Disable swap before OS Update (#333)
Mask all swap targets. Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
1 parent e74b3ca commit 5ca6454

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

clr-k8s-examples/setup_system.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@ function add_os_deps() {
2929

3030
# permanently disable swap
3131
function disable_swap() {
32-
swapcount=$(sudo grep '^/dev/\([0-9a-z]*\).*' /proc/swaps | wc -l)
33-
34-
if [ "$swapcount" != "0" ]; then
35-
sudo systemctl mask "$(sed -n -e 's#^/dev/\([0-9a-z]*\).*#dev-\1.swap#p' /proc/swaps)" 2>/dev/null
36-
else
37-
echo "Swap not enabled"
38-
fi
32+
# disable current swap
33+
sudo swapoff -a
34+
# permanently disable swap
35+
sudo systemctl mask swap.target
3936
}
4037

4138
# enable ip forwarding
@@ -137,7 +134,6 @@ function enable_kubelet_runner() {
137134

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

@@ -192,12 +188,12 @@ fi
192188

193189
echo "Init..."
194190
init
191+
echo "Disabling swap..."
192+
disable_swap
195193
echo "Setting OS Version..."
196194
upate_os_version
197195
echo "Adding OS Dependencies..."
198196
add_os_deps
199-
echo "Disabling swap..."
200-
disable_swap
201197
echo "Enabling IP Forwarding..."
202198
enable_ip_forwarding
203199
echo "Setting up modules to load..."

0 commit comments

Comments
 (0)