5A : how to switch the swap file to SDD

This is the output of lsblk on my Rock 5A:

mtdblock0    31:0    0    16M  0 disk 
zram0       254:0    0   3.8G  0 disk [SWAP]
nvme0n1     259:0    0 465.8G  0 disk 
├─nvme0n1p1 259:1    0    16M  0 part /config
└─nvme0n1p2 259:2    0  29.7G  0 part /

I suppose that zram0 (the swap file) is allocated in 3.8 GB of the 8 GB of RAM of the Rock chip…
Apart from the fact that I do not understand the logic of allocating the swap file in RAM, what I would like to do is to move it into the free space of the NVME SSD.

The command ‘swap off’ is not recognized by the Debian 11 loaded into the board… is there a way to do the above?
I am not much proficient in Linux, so I am in search of advice, thanks.

Fred

Using part of RAM as a zswap is an efficient way of increasing the effective RAM capacity. It’s not simply a swap file but a compressed swap file.

…a compressed swap file… understood.
That seems logical.
Anyway I would like to move to swap file (maybe still compressed) to the SSD disk, thus freeing 3.8GB of RAM… any takers?

Fred

create the SSD swap partition, put it in /etc/fstab, run systemctl daemon-reload, e.g.
mkswap /dev/nvme0n1p3
/dev/nvme0n1p3 none swap sw 0 0

That would require the use of zswap otherwise it will worsen your situation.

You’re not ‘freeing 3.8GB’ this way, you’re just fooling yourself. These 3.8GB are not gone since otherwise those people having created the OS image you’re using would be clearly idiots. And they aren’t.

Use zramctl to see how much RAM is really occupied for which amount of data. Output might look like this:

NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       3.9G 27.6M  9.3M 10.1M       8 [SWAP]
1 Like

I think it is preferable to use a swap file instead of a swap partition nowadays because it can be easily resized and/or removed. Instruction on how to create a swap file can be found by googling “how to create a swap file” and clicking the top link.