I'm at my wit's end; it seems there's no way to tell Raspbian Stretch Lite to permanently disable swap space.
Now, it's a bit of an edge case, wanting to keep swap turned off (in this case it's for a Kubernetes cluster, so kubectl
doesn't complain about swap being enabled)... but it's something that's easy enough to do on most any other platform I've tried.
Here's what I'm currently doing (seems to be recommended all over the Internet as the normal way of disabling swap space permanently):
sudo dphys-swapfile swapoff && \
sudo dphys-swapfile uninstall && \
sudo systemctl disable dphys-swapfile
(Whether you use systemctl disable
or update-rc.d remove
, it does the same thing—and I've tried both.)
Every time I reboot the Pi, I get:
$ free -h
total used free shared buff/cache available
Mem: 976M 89M 579M 6.5M 308M 829M
Swap: 99M 0B 99M
And then I have to run the commands to disable swap again. Am I going mad or is there really no way to tell the Pi to stop creating swap space on boot!?
The Pi/Raspbian Stretch seems to not use fstab as would be standard on most of the other systems I manage; after reboot, when free -h
shows 99M
of swap, and kubelet
complains that swap needs to be disabled, this is the exact contents of the swap file on one of the nodes:
$ cat /etc/fstab
proc /proc proc defaults 0 0
PARTUUID=c220ffa8-01 /boot vfat defaults 0 2
PARTUUID=c220ffa8-02 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
10.0.100.61:/srv/nfs /mnt/nfs nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14 0 0
(Note that it contains verbiage about using dphys-swapfile
there.)
dphys-swapfile
.sudo update-rc.d -f dphys-swapfile remove
there's still adphys-swapfile
startup script inside/etc/init.d
... Do I have to manually delete that file?