MutantMahesh's Blog

Seeking to know.

May 9, 2021 - 1 minute read - Raspberry PI

Disable Swap on Raspberry PI cluster

I had the requirement of disabling the Swap memory on Raspberry PI because this is one of the requirement to run the Kubernetes on Raspberry PI. As per the Kubernetes official documentation Kubernetes does not supports the Swap .

By following the initial instruction given on most of the blog post I disabled the swap by running the command:

$ sudo swapoff -a

But I noticed each time I reboot the Raspberry PI it will reenable the swap.

Even after running the following commands the swap was getting enabled on each boot.

$ dphys-swapfile swapoff
$ dphys-swapfile uninstall
$ update-rc.d dphys-swapfile remove

After a bit of research on internet I found that I need to stop and disable the dphys-swapfile service.

By running the following commands it will disable the Swap memory on Raspberry PI permanently:

$ dphys-swapfile swapoff
$ dphys-swapfile uninstall
$ update-rc.d dphys-swapfile remove
$ rm -f /etc/init.d/dphys-swapfile

$ service dphys-swapfile stop
$ systemctl disable dphys-swapfile.service

Note: You need to run the above commands on each node of raspberry pi cluster to disable the swap.