Swap File Problem filling to 100%

I have a 4GB Pi4 so I disabled the swap file with

sudo swapoff -a

Not sure if you have access to the Pi to run this command but if you are running off an SD card it may be worth doing it. It’s easy to SSD boot off that Pi as it’s enabled by default. With an SSD you could also increase the swap file if the Pi starts slowing down or freezing.

Unfortunately because the way they lock HomeAssistant up with the standard version that command is not allowed…my Swap file is now 100% full

Is there any way to increase the swap file size easily…

I guessed that may be the case.

My Pi4 with 4GB of ram will use the swap file if enabled even though there is plenty of RAM available so go figure. If your Pi is still stable then there shouldn’t be an issue, but, if you are running this off an SD card then you are very likely to get issues with card corruption at some point. Running off SSD would be much more preferable and stable in the long run.

Have you tried disabling your addons and integrations one by one to see if you can determine which one is causing the problem? Does the swap file usage clear up when you restart or only when you reboot? If only on a reboot it will probably be an addon causing your problem.

I have swap file issues when I have too many ONVIF cameras enabled at once (I’m still on an RPi 3 with an SD card).

The only way to reduce it is to reboot the OS…If I restart HA nothing really reduces maybe a few kilobytes

The swap file filling up is normal behaviour so unless there are stability problems it’s not an issue. As I have mentioned several times, if you are running off an SD card you are pretty certain to get card corruption in the future so the sooner you move over to SSD the better.

1 Like

Hi, I have the same problem as your colleague. My SWAP is full very often. My HA going on SSD. Is some way how to change SWAP memory if I have installed with Hassio image? Thanks

sudo systemctl stop docker
sudo dphys-swapfile swapoff
SWAPSIZE=256
sudo sed -i "s/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=${SWAPSIZE}/" /etc/dphys-swapfile
sudo dphys-swapfile swapon
sudo systemctl start docker

@Johan_Lander This commands I will enter in SSH & WEB Terminal? Because I can´t enter to RPi via putty.

In the ssh terminal… Do you know how to enable it ?

I was having the exact same issue previously. I was using a Rpi 3 Model B, which only had 1 GB of RAM. It was constantly filling right up, and then the swap file would kick it. It would become unresponsive after only a few days. Automations such as motion detectors turning lights on and off were massively delayed (lights would come on 2 minutes after I left the room!). I asked on this forum and twitter. Didn’t get much help with it, to be honest.

I took a backup upgraded to Raspberry Pi 4 with 8GB and it’s been totally fine since then. The memory usage flats around 1220MB, which would have been too much for the RPi3 to be stable with.

I suspect you’re having the same problems I was having. Upgrading to a RPi with more memory was my only solution.

1 Like

@Johan_Lander Yes, I have enabled it. But this commands are unknown…

"sudo stop docker "

dphys-swapfile is not in use by home assistant OS. So these commands do not work

I had that problem on Supervised version (with Raspbian) on RPi4 with 2MB RAM. Standard SWAP filled up quickly, HA becomes less responsive. I enlarged SWAP and problem gone.

Now I went to the supported version and SWAP is high or full most the time again with, that I read, no possibility to enlarge.

I am not sure that supported version is much better for users.

experiencing similar issue.
Raspberry PI B.
|Friday, December 25, 2020|00:13|After installing Grafana & InFluxDB. system was unresponsive and had to p/c. Did not solve.|
|Friday, December 25, 2020|11:50|! Noticed Swap = 100%|
|Friday, December 25, 2020|18:55|removed Grafana & InFlux DB. Swap 84%. Responsiveness ok.|
My conclusion is that PI has reached its limit. Need more need bigger Hardware. Anyone disagree? Do not want to invest in more Hardware if not required.
Thanks,

1 Like

See if this post helps:

Has the possibility to switch “Protection mode” on/off been removed in the HassOS? I cannot see it on any add-on.

Is there some setting in the HassOS that can enable it?

Is this at all relevant to the new HA blue? I was having to reboot my pi 3-4 times a day. When I got the blue I had no issues for 2 months. Now I’m rebooting 3-4 times a day again.

1 Like