On DietPi it’s enabled by default on <2GB ram devices. Please @Joulinar correct me if I’m wrong.
Yes correct, we ensure at least 2GB of ram, combined phys+SWAP. As well we store /tmp folder in memory. This needs to be taken into account if you have an app heavily storing stuff there.
In general availability of SWAP did not harm. Yes using SWAP will slow down the system as data needs to be copied between pyhs memory and SWAP. However it could help in peak periods.
If you see memory exhausting, check as well /tmp usage.
Got it! But why my RPi4 which is 2GB requires swap?
Should I set it to 4GB in dietpi-config
?
In general the usage of SWAP depends on your individual system usage.
As said above, by default we have located /tmp file system in memory as well. Means, if you have an app that will store a lot of data inside /tmp, your memory will be used as well. In such cases you could think of moving the temporary location for such apps to another location.
Therefore you need to watch memory usage as well as tmp file system.
Okay but I still don’t understand why I see in both DietPi Dashboard and htop
less than 200MB of used RAM but 50/75% used SWAP.
Your SWAP is very small. It’s just 150MB. A usage of 50% means just a usage of 75MB.
In general you need to watch your system closely if and how memory will be used.
Have a look at df -h
if /tmp is used. As well on htop
you see different colour codes. Most of ram is yellow. Means something is cached into memory. Could be some temporary data linux - What exactly do the colors in htop status bars mean? - Server Fault
Dashboard don’t count these cached data.
Will reporst asap I torrent something!
Thanks.
I would put a 1x zram swap in…it can compress quite a bit, so I would say do a 2048MB (2GB zram swap) this way it doesn’t have to write/read to the physical media)
I believe dietpi supports zram swap, you can see if it’s active/enabled with
# cat /proc/swaps
If you see a zram entry, it active, you can then adjust the size and compression algorithm in the
/etc/default/zramswap
file
Mine is as follows for a 1GB zram swap on an AtomicPi I use to run my Anet A8 3D printer
warhawk@AtomicPI:/etc/default$ cat /etc/default/zramswap
# Compression algorithm selection
# speed: lz4 > zstd > lzo
# compression: zstd > lzo > lz4
# This is not inclusive of all that is available in latest kernels
# See /sys/block/zram0/comp_algorithm (when zram module is loaded) to see
# what is currently set and available for your kernel[1]
# [1] https://github.com/torvalds/linux/blob/3a568e3a961ba330091cd031647e4c303fa0badb/Documentation/blockdev/zram .txt#L86
ALGO=lz4
# Specifies the amount of RAM that should be used for zram
# based on a percentage the total amount of available memory
# This takes precedence and overrides SIZE below
#PERCENT=10
# Specifies a static amount of RAM that should be used for
# the ZRAM devices, this is in MiB
SIZE=1024
# Specifies the priority for the swap devices, see swapon(2)
# for more details. Higher number = higher priority
# This should probably be higher than hdd/ssd swaps.
PRIORITY=100
https://manpages.debian.org/testing/zram-tools/zramswap.1.en.html
zram
is supported directly via our configuration options. No need to perform manual configuration.
Hi again @Joulinar
Is it enabled by default or do I have to enable it? If the second one, how can I enable and what are the best settings?
nope
/boot/dietpi/func/dietpi-set_swapfile 1024 zram
Thanks will this be used as swap and allowing me to have 1GB of swap?
Completly unreleted but I was fiddling with qBittorrent’s advanced settings and have disabled disk io read/write OS cache, started downloading Ubuntu and it failed, I then paused and removed the torrent but think everything crashed, rebooted (multiple times) and cannot do anything: cannot login via SSH, DietPi Dashboard shows nothing. Can you help me please?
connect a screen and check what happen
I’ve disabled HDMI output
while disabling HDMI on RPI, you should have seen the information on how to reenable
Re-enabling HDMI requires a reboot. If you need emergency HDMI output, edit the following files on first partition
of the SDcard from external system:
- In config.txt, set "hdmi_ignore_hotplug=0" and comment/remove the "max_framebuffers=0" line.
- In dietpi.txt, set "AUTO_SETUP_HEADLESS=0".
Will try and report back!
Thanks for now!
Thanks @Joulinar everything’s good again! Don’t really know what happened as when I booted up and hooked a monitor everything was normal
Is there a funcion/tool to check if everything is running fine or there’s any problem? Hadn’t see any error while booting with monithor hooked.
Can you answer this too? Also is zram/zswap better then swap?
Thanks again!
one option is to check status of all services.
dietpi-services status
Maybe this give some inside. Alan Doyle - Swap vs ZSwap vs zRAM
I’m not sure if there will be black or white answer
Everything’s fine
Thanks! Will have a look at this.
Just a question: do I need to disable swap once created zram or I just run your command above? Also only 1GB?
to be on save side, disable SWAP first before creating zRAM
/boot/dietpi/func/dietpi-set_swapfile 0
/boot/dietpi/func/dietpi-set_swapfile 1024 zram
yes, that would be half of your physical memory. Let’s start with this value.