Swapfile really needed? Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
naddel81
Posts: 31
Joined: Sun Jul 21, 2019 12:54 pm

Swapfile really needed?

Post by naddel81 »

Hi at all,

I have a Pi 2B and only use it for Phiole and wireguard. It is installed on a 4gb Card. The Pi tells me there is not enough space when updating. Can I simply disable swap file? Why ist 4gb not sufficient?

Best wishes.
User avatar
Joulinar
Posts: 2568
Joined: Sat Nov 16, 2019 12:49 am

Re: Swapfile really needed?

Post by Joulinar »

Hi,

many thanks for your message. Basically SWAP setting depends on your application and usage. By default, DietPi will create a swap file fir SBC running less than 2GB RAM. If you just running PiHole + Wireguard, it could be ok to disable SWAP as it should not use that much. However you never know if there are other processes, like updates, who might need more RAM. I would recommend to use free -m (available memory) or htop to check current usage and then to assure that total memory (including swap) is at least double of size of what is currently used, to cover peaks. Best is to perfrom checks not directly after reboot, as for sure there not much RAM uses. Therefore let it run for some days and check how it looks like.

Regarding disk space, you can have a look using df -h how much space is left on your device. For safety reason, DietPi expect at least 500 MB free space if you run dietpi-software
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
naddel81
Posts: 31
Joined: Sun Jul 21, 2019 12:54 pm

Re: Swapfile really needed?

Post by naddel81 »

thanks for your help. currently I have this situation:

https://abload.de/img/dietpigwjfu.png

I guess it is not enough space for an update. I only have pihole and wireguard installed. shouldn't there be more space left?
User avatar
Joulinar
Posts: 2568
Joined: Sat Nov 16, 2019 12:49 am

Re: Swapfile really needed?

Post by Joulinar »

yes, the amount of used space is quite normal and similar to my system

Code: Select all

root@DietPi4:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        29G  3.5G   25G  13% /
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G  1.6M  1.9G   1% /dev/shm
tmpfs           1.9G  8.3M  1.9G   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           2.0G     0  2.0G   0% /tmp
tmpfs            50M   28K   50M   1% /var/log
/dev/mmcblk0p1  253M   55M  198M  22% /boot
root@DietPi4:~#
Anyway, let's check your memory usage and if we can reduce SWAP. Pls can you post free -m
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
naddel81
Posts: 31
Joined: Sun Jul 21, 2019 12:54 pm

Re: Swapfile really needed?

Post by naddel81 »

problem is that I only have 400 MB available now :(

there you go:

https://abload.de/img/dietpi2k5j98.png
User avatar
Joulinar
Posts: 2568
Joined: Sat Nov 16, 2019 12:49 am

Re: Swapfile really needed?

Post by Joulinar »

Hi,

there is no need to do screen prints. You are able to copy the content from putty directly. Just mark it in putty and paste it here ;)
problem is that I only have 400 MB available now
Not really a problem, just a small challenge :D

let's reduce your SWAP file down to 512MB. pls do

Code: Select all

/boot/dietpi/func/dietpi-set_swapfile 512
You should have sufficient free space now
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
naddel81
Posts: 31
Joined: Sun Jul 21, 2019 12:54 pm

Re: Swapfile really needed?

Post by naddel81 »

great, but would this here help aswell?

--> https://www.zdnet.com/article/raspberry ... e-sd-card/
User avatar
Joulinar
Posts: 2568
Joined: Sat Nov 16, 2019 12:49 am

Re: Swapfile really needed?

Post by Joulinar »

not sure what you mean exactly. But DietPi is using quite some tmpfs already

Code: Select all

root@DietPi3:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  1.2G   13G   9% /
devtmpfs        456M     0  456M   0% /dev
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           488M   13M  476M   3% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           488M     0  488M   0% /sys/fs/cgroup
tmpfs            50M  8.0K   50M   1% /var/log
tmpfs           743M     0  743M   0% /tmp
/dev/mmcblk0p1  253M   55M  198M  22% /boot
root@DietPi3:~#
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
naddel81
Posts: 31
Joined: Sun Jul 21, 2019 12:54 pm

Re: Swapfile really needed?

Post by naddel81 »

I thought using RAM and completely abandon swap file unless it is needed (RAM is full). that would save space.
User avatar
Joulinar
Posts: 2568
Joined: Sat Nov 16, 2019 12:49 am

Re: Swapfile really needed?

Post by Joulinar »

Well SWAP was used on the picture you shared

https://abload.de/img/dietpi2k5j98.png

That's why we reduced it by 50% to gain space but still have some SWAP file if needed.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply