Steam Deck

Steam Deck

How disable zram?
I use cryoutilities with an enlarged swapfile, however, zram appeared in update 3.6. (Currently, the priority is 100 for zram, and -2 for swap file.)
According to my observations, zram works worse, I'm not an expert, but it seems that this is due to the fact that zram has no equivalent value for swappiness, and therefore the system often accesses the swap file(zram), which leads to more serious stutters. Here's a question for those who understand linux and steamos - is it possible to disable zram?
< >
Showing 1-13 of 13 comments
Mahjik Jan 11 @ 9:12am 
This is listed on the CryoUtilities bug report. Nothing has been done though so either CryoByte33 can't do anything about it or doesn't see as a problem.

https://github.com/CryoByte33/steam-deck-utilities/issues/179
Pepe Jan 11 @ 12:06pm 
Post your output values for these commands.
sysctl vm.swappiness
swapon
free -wh
sysctl vm.dirty_ratio
sysctl vm.dirty_background_ratio
Last edited by Pepe; Jan 11 @ 12:17pm
KVass Jan 26 @ 12:26am 
Originally posted by Pepe:
Post your output values for these commands.
sysctl vm.swappiness
swapon
free -wh
sysctl vm.dirty_ratio
sysctl vm.dirty_background_ratio
Sorry for the long answer. I was very busy during the holidays.
vm.swappiness = 1

Name Type size used priority
/dev/zram0 partitition 5.8g 288k 100
/home/swapfile file 16g 0b -2


Mem: total 11gi, used 3.3gi, free 713mi, shared 436mi, buffers 238 mi, cashe 8gi, available 8.2gi
Swap: 21gi, 288ki, free 21gi

dirty_ratio = 20

dirty_background_ratio = 10
Pepe Jan 26 @ 5:56pm 
Originally posted by KVass:
Originally posted by Pepe:
Post your output values for these commands.
sysctl vm.swappiness
swapon
free -wh
sysctl vm.dirty_ratio
sysctl vm.dirty_background_ratio
Sorry for the long answer. I was very busy during the holidays.
vm.swappiness = 1

Name Type size used priority
/dev/zram0 partitition 5.8g 288k 100
/home/swapfile file 16g 0b -2


Mem: total 11gi, used 3.3gi, free 713mi, shared 436mi, buffers 238 mi, cashe 8gi, available 8.2gi
Swap: 21gi, 288ki, free 21gi

dirty_ratio = 20

dirty_background_ratio = 10

Could you give the output of the following commands as well?
zramctl
cat /sys/block/zram0/comp_algorithm
Last edited by Pepe; Jan 26 @ 5:59pm
KVass Jan 27 @ 12:08am 
Originally posted by Pepe:
Originally posted by KVass:
Sorry for the long answer. I was very busy during the holidays.
vm.swappiness = 1

Name Type size used priority
/dev/zram0 partitition 5.8g 288k 100
/home/swapfile file 16g 0b -2


Mem: total 11gi, used 3.3gi, free 713mi, shared 436mi, buffers 238 mi, cashe 8gi, available 8.2gi
Swap: 21gi, 288ki, free 21gi

dirty_ratio = 20

dirty_background_ratio = 10

Could you give the output of the following commands as well?
zramctl
cat /sys/block/zram0/comp_algorithm


Name/algorithm/disksize/data/compr/total/streams/mountpoint
/dev/zram0 zstd 5.8G 4K 64B 20K 8 [swap]

lzo lzo-rle lz4 lz4hc 842 [zstd]
Pepe Jan 27 @ 10:34am 
Originally posted by KVass:
Originally posted by Pepe:

Could you give the output of the following commands as well?
zramctl
cat /sys/block/zram0/comp_algorithm


Name/algorithm/disksize/data/compr/total/streams/mountpoint
/dev/zram0 zstd 5.8G 4K 64B 20K 8 [swap]

lzo lzo-rle lz4 lz4hc 842 [zstd]

OK. Thanks!

Now that we have the full picture... It's time to add my personal opinion. :)


Let's say your assumptions are not quite right.

1. Swappiness parameter is used for all virtual memory any kind of swap, that includes zram. Swap items are used, as required, by priority.
https://docs.kernel.org/admin-guide/sysctl/vm.html
swappiness

This control is used to define the rough relative IO cost of swapping and filesystem paging, as a value between 0 and 200. At 100, the VM assumes equal IO cost and will thus apply memory pressure to the page cache and swap-backed pages equally; lower values signify more expensive swap IO, higher values indicates cheaper.

Keep in mind that filesystem IO patterns under memory pressure tend to be more efficient than swap’s random IO. An optimal value will require experimentation and will also be workload-dependent.

The default value is 60.

For in-memory swap, like zram or zswap, as well as hybrid setups that have swap on faster devices than the filesystem, values beyond 100 can be considered. For example, if the random IO against the swap device is on average 2x faster than IO from the filesystem, swappiness should be 133 (x + 2x = 200, 2x = 133.33).

At 0, the kernel will not initiate swap until the amount of free and file-backed pages is less than the high watermark in a zone.

https://www.kernel.org/doc/gorman/html/understand/understand014.html
prio Each swap area has a priority which is stored in this field. Areas are arranged in order of priority and determine how likely the area is to be used. By default the priorities are arranged in order of activation but the system administrator may also specify it using the -p flag when using swapon;

That being said, the Kernel docs must be taken with a grain of salt for swappiness values suggestions. They are talking more about servers and highly specific systems rather than personal computers. So that example with swappiness over 100 is not for you.

Funny enough, for the issue regarding vm.swappiness set 100 on SteamDeck (which is one problem you don't have exactly, because, on your SteamDeck, it's set to 1), one GitHub user used the formula in the Kernel docs and ended up to the conclusion that swapinness needs to be 198, which is absurd. Then again, reddit techies are testing zram performance with swappiness 200, very sensible /s. Later Edit: Not to be misunderstood, for testing purposes, to force kernel to do a lot of swapping, this is fine, but it may lead readers thinking this is a normal value to use on a normal system.

Probably, the devs working at Valve skimmed through the same text, saw zram and 100 in the same sentence, and said, bam! That's it! 100! Let's gooooo!

2. zram is great. It is used from Small Board Computing like Raspberry Pis to fully blown PCs to improve performance, not making it worse. It is the best thing that ever happened to swapping. The only logical reason to have a swap file on a storage device on a personal computer in 2024/2025 is if you want to hibernate.




Now, let's analyze the numbers posted.

Firstly, vm.swappiness is way too low. When you have multiple processes fighting for the same amount of RAM, the system might work too hard hard evicting pages from RAM to swap and sending them back again to RAM over and over because that value is at the limit of saying don't use swap at all, better kill the process.

Secondly, you have only 11-12GiB available as system memory, that means your GPU is probably using around 4GiB of RAM as video memory (a.k.a. VRAM). If you don't play some games that just don't work with less VRAM, you can free up 1-2GiB. I think you can set up VRAM from SteamDeck UEFI > UMA Frame buffer size. 2GiB should be more than enough for VRAM. If VRAM is not used, it can't be used as normal system virtual memory.

Third point, zram. The zram value seems to be set for about half the RAM available as system virtual memory. Very important note that this size is not used by default. The operating system is using as little as it's needed. So, opposed to VRAM, zram is not actual using 6GiB of system memory. And on top of that, everything is compressed to over 2.5x, no matter the compression algorithm used. 6GiB might be a little too much though (especially with Valve's default swappiness of 100). Seems like Valve picked zstd as the compression alghorithm which offers the highest compression, but it also has the worst latency and IOPS, which on a mobile device with limited power is not quite right; we want to make everything snappy, even if we don't get the best compression. So lzo-rle and lz4 are the best contenders. Fedora, for example, uses lzo-rle.

Dirty_* params are fine for the amount of memory.



Final thoughts:

a. Ditch the swap file if you don't use hibernation.

b. Set swappiness to 20. I don't know how cryo-utilities does it, if you want to use that tool, use it.

If you want to set up swappiness the right way... there are enough articles on the web. The only thing to look for is the default swappiness configuration made by Valve (should be in /etc/sysctl.d/). If their config file starts with 20-, your config should be 21- or more, to overwrite what Valve is setting by default, and, of course, not changing their own file that might be ovewritten by an update.

https://www.freedesktop.org/software/systemd/man/latest/sysctl.d.html#Configuration%20Directories%20and%20Precedence
All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence. Thus, the configuration in a certain file may either be replaced completely (by placing a file with the same name in a directory with higher priority), or individual settings might be changed (by specifying additional settings in a file with a different name that is ordered later).

c. Set zram to 4 GiB. You could try lower (3, 2), if you still have issues. The thing with zram is that it can be set in different ways. I'm not sure how Steam Deck is setting up zram at boot. Considering Steam Deck is based on Arch Linux, Valve should have set it up with one of the methods described here: https://wiki.archlinux.org/title/zram#Usage_as_swap. I can only guess that they've used zram-generator, as it's also been used by other distros. Look for the conf file. If it's not at /etc/systemd/zram-generator.conf, it might be at /usr/lib/systemd/zram-generator.conf, /usr/local/lib/systemd/zram-generator.conf, /run/systemd/zram-generator.conf (https://man.archlinux.org/man/zram-generator.conf.5. Of course, as with swappiness, if you want to keep Valve's zram, but make it secondary, create a new zram config in zram-generator.conf.d/ (check the link above) and set its swap-priority to 200. Compression algorithm should be lzo-rle or lz4. You should end up with something like this:
[zram1] zram-size = 4096 compression-algorithm = lzo-rle swap-priority = 200
If you edit Valve's zram0 config file, everything would look the same except for the name: [zram0] instead of [zram1].

Even though I won't recommend it, if you still want to remove zram, you've got the solution just above: delete the zram-generator.conf made by Valve.


Here's a table with viable values you can try before purging zram from your SteamDeck. :)
swappiness VRAM remaining sys mem zram min sys memory # balanced 20 2GiB 14GiB 4GiB 10GiB 20 2GiB 14GiB 3GiB 11GiB 20 3GiB 13GiB 3GiB 10GiB # minimal 20 1GiB 15GiB 2GiB 13GiB # VRAM priority 20 3GiB 13GiB 2GiB 11GiB 20 4GiB 12GiB 2GiB 10GiB


Later Edit: I don't know how SteamDeck immutable system works, Fedora's immutable spin uses os-tree on /usr and root (/), but not on /etc and /var, which means configuration and data files can be created or edited. In case SteamOS works differently and you can't set up the config files required, there's another way to set these settings at runtime by using the kernel ins and outs, but it's more tedious and not quite the way things should be done under GNU/Linux, especially if you have a service that works as intended for a specific task.
Last edited by Pepe; Feb 7 @ 9:07am
KVass Jan 27 @ 2:08pm 
Originally posted by Pepe:
Originally posted by KVass:


Name/algorithm/disksize/data/compr/total/streams/mountpoint
/dev/zram0 zstd 5.8G 4K 64B 20K 8 [swap]

lzo lzo-rle lz4 lz4hc 842 [zstd]

OK. Thanks!

Now that we have the full picture... It's time to add my personal opinion. :)


Let's say your assumptions are not quite right.

1. Swappiness parameter is used for all virtual memory, that includes zram. Swap items are used, as required, by priority.
https://docs.kernel.org/admin-guide/sysctl/vm.html
swappiness

This control is used to define the rough relative IO cost of swapping and filesystem paging, as a value between 0 and 200. At 100, the VM assumes equal IO cost and will thus apply memory pressure to the page cache and swap-backed pages equally; lower values signify more expensive swap IO, higher values indicates cheaper.

Keep in mind that filesystem IO patterns under memory pressure tend to be more efficient than swap’s random IO. An optimal value will require experimentation and will also be workload-dependent.

The default value is 60.

For in-memory swap, like zram or zswap, as well as hybrid setups that have swap on faster devices than the filesystem, values beyond 100 can be considered. For example, if the random IO against the swap device is on average 2x faster than IO from the filesystem, swappiness should be 133 (x + 2x = 200, 2x = 133.33).

At 0, the kernel will not initiate swap until the amount of free and file-backed pages is less than the high watermark in a zone.

https://www.kernel.org/doc/gorman/html/understand/understand014.html
prio Each swap area has a priority which is stored in this field. Areas are arranged in order of priority and determine how likely the area is to be used. By default the priorities are arranged in order of activation but the system administrator may also specify it using the -p flag when using swapon;

That being said, the Kernel docs must be taken with a grain of salt for swappiness values suggestions. They are talking more about servers and highly specific systems rather than personal computers. So that example with swappiness over 100 is not for you.

Funny enough, for the issue regarding vm.swappiness set 100 on SteamDeck (which is one problem you don't have exactly, because, on your SteamDeck, it's set it to 1), one GitHub user used the formula in the Kernel docs and ended up to the conclusion that swapinness needs to be 198, which is absurd. The again, reddit techies are testing zram performance with swappiness 200, very sensible /s.

Probably, the devs working at Valve skimmed through the same text, saw zram and 100 in the same sentence, and said, bam! That's it! 100! Let's gooooo!

2. zram is great. It is used from Small Board Computing like Raspberry Pis to fully blown PCs to improve performance, not making it worse. It is the best thing that ever happened to swapping. The only logical reason to have a swap file on a storage device on a personal computer in 2024/2025 is if you want to hibernate.




Now, let's analyze the numbers posted.

Firstly, vm.swappiness is way too low. When you have multiple processes fighting for the same amount of RAM, the system might work too hard hard evicting pages from RAM to swap and sending them back again to RAM over and over because that value is at the limit of saying don't use swap at all, better kill the process.

Secondly, you have only 11-12GiB available as system memory, that means your GPU is probably using around 4GiB of RAM as video memory (a.k.a. VRAM). If you don't play some games that just don't work with less VRAM, you can free up 1-2GiB. I think you can set up VRAM from SteamDeck UEFI > UMA Frame buffer size. 2GiB should be more than enough for VRAM. If VRAM is not used, it can't be used as normal system virtual memory.

Third point, zram. The zram value seems to be set for about half the RAM available as system virtual memory. Very important note that this size is not used by default. The operating system is using as little as it's needed. So, opposed to VRAM, zram is not actual using 6GiB of system memory. And on top of that, everything is compressed to over 2.5x, no matter the compression algorithm used. 6GiB might be a little too much though (especially with Valve's default swappiness of 100). Seems like Valve picked zstd as the compression alghorithm which offers the highest compression, but it also has the worst latency and IOPS, which on a mobile device with limited power is not quite right; we want to make everything snappy, even if we don't get the best compression. So lzo-rle and lz4 are the best contenders. Fedora, for example, uses lzo-rle.

Dirty_* params are fine for the amount of memory.



Final thoughts:

a. Ditch the swap file if you don't use hibernation.

b. Set swappiness to 20. I don't know how cryo-utilities does it, if you want to use that tool, use it.

If you want to set up swappiness the right way... there are enough articles on the web. The only thing to look for is the default swappiness configuration made by Valve (should be in /etc/sysctl.d/). If their config file starts with 20-, your config should be 21- or more, to overwrite what Valve is setting by default, and, of course, not changing their own file that might be ovewritten by an update.

https://www.freedesktop.org/software/systemd/man/latest/sysctl.d.html#Configuration%20Directories%20and%20Precedence
All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence. Thus, the configuration in a certain file may either be replaced completely (by placing a file with the same name in a directory with higher priority), or individual settings might be changed (by specifying additional settings in a file with a different name that is ordered later).

c. Set zram to 4 GiB. You could try lower (3, 2), if you still have issues. The thing with zram is that it can be set in different ways. I'm not sure how Steam Deck is setting up zram at boot. Considering Steam Deck is based on Arch Linux, Valve should have set it up with one of the methods described here: https://wiki.archlinux.org/title/zram#Usage_as_swap. I can only guess that they've used zram-generator, as it's also been used by other distros. Look for the conf file. If it's not at /etc/systemd/zram-generator.conf, it might be at /usr/lib/systemd/zram-generator.conf, /usr/local/lib/systemd/zram-generator.conf, /run/systemd/zram-generator.conf (https://man.archlinux.org/man/zram-generator.conf.5. Of course, as with swappiness, if you want to keep Valve's zram, but make it secondary, create a new zram config in zram-generator.conf.d/ (check the link above) and set its swap-priority to 200. Compression algorithm should be lzo-rle or lz4. You should end up with something like this:
[zram1] zram-size = 4096 compression-algorithm = lzo-rle swap-priority = 200


Even though I won't recommend it, if you still want to remove zram, you've got the solution just above: delete the zram-generator.conf made by Valve.


Here's a table with viable values you can try before purging zram from your SteamDeck. :)
swappiness VRAM remaining sys mem zram min sys memory # balanced 20 2GiB 14GiB 4GiB 10GiB 20 2GiB 14GiB 3GiB 11GiB 20 3GiB 13GiB 3GiB 10GiB # minimal 20 1GiB 15GiB 2GiB 13GiB # VRAM priority 20 3GiB 13GiB 2GiB 11GiB 20 4GiB 12GiB 2GiB 10GiB


Later Edit: I don't know how SteamDeck immutable system works, Fedora's immutable spin uses os-tree on /usr and root (/), but not on /etc and /var, which means configuration and data files can be created or edited. In case SteamOS works differently and you can't set up the config files required, there's another way to set these settings at runtime by using the kernel ins and outs, but it's more tedious and not quite the way things should be done under GNU/Linux, especially if you have a service that works as intended for a specific task.
Ok. Thank you very much. Interesting thoughts to think about
Pepe Jan 28 @ 4:34am 
I've made a couple of "fixes" in my post:
- fixed wrong use of "virtual memory" in this context, "swap" is the right word:
Originally posted by Pepe:
1. Swappiness parameter is used for all virtual memory any kind of swap, that includes zram. Swap items are used, as required, by priority.
- for testing purposes 200 value is fair, but I wouldn't use it on a normal system, added some explanation on that:
Originally posted by Pepe:
Funny enough, for the issue regarding vm.swappiness set 100 on SteamDeck (which is one problem you don't have exactly, because, on your SteamDeck, it's set it to 1), one GitHub user used the formula in the Kernel docs and ended up to the conclusion that swapinness needs to be 198, which is absurd. The again, reddit techies are testing zram performance with swappiness 200, very sensible /s. Later Edit: Not to be misunderstood, for testing purposes, to force kernel to do a lot of swapping, this is fine, but it may lead readers thinking this is a normal value to use on a normal system.
- added an additional explanation on zram conf file content:
Originally posted by Pepe:
If you edit Valve's zram0 config file, everything would look the same except for the name: [zram0] instead of [zram1].
- a few insignificant text format changes and typos fixes

Anyway, let me know if any of this worked for you. I really hope it does and you don't disable the zram. :)
Last edited by Pepe; Jan 28 @ 4:34am
KVass Jan 30 @ 7:56am 
Originally posted by Pepe:
I've made a couple of "fixes" in my post:
- fixed wrong use of "virtual memory" in this context, "swap" is the right word:
Originally posted by Pepe:
1. Swappiness parameter is used for all virtual memory any kind of swap, that includes zram. Swap items are used, as required, by priority.
- for testing purposes 200 value is fair, but I wouldn't use it on a normal system, added some explanation on that:
Originally posted by Pepe:
Funny enough, for the issue regarding vm.swappiness set 100 on SteamDeck (which is one problem you don't have exactly, because, on your SteamDeck, it's set it to 1), one GitHub user used the formula in the Kernel docs and ended up to the conclusion that swapinness needs to be 198, which is absurd. The again, reddit techies are testing zram performance with swappiness 200, very sensible /s. Later Edit: Not to be misunderstood, for testing purposes, to force kernel to do a lot of swapping, this is fine, but it may lead readers thinking this is a normal value to use on a normal system.
- added an additional explanation on zram conf file content:
Originally posted by Pepe:
If you edit Valve's zram0 config file, everything would look the same except for the name: [zram0] instead of [zram1].
- a few insignificant text format changes and typos fixes

Anyway, let me know if any of this worked for you. I really hope it does and you don't disable the zram. :)
Nope, the steam os does not give me the rights to change the config. There is no desire to directly understand root rights. So I guess I'll have to wait for a couple of updates. But I found a zram generator file. Here's what's written in the file in full, if you're interested
(If needed, i wrote some comment to) #comment -*- mode:sh; indent-tabs-mode: nill; sh-basic-offset: 2; -*- #vim: et sts=2 sw=2 [zram0] zram-size = ram/2 compression-algorithm = zstd swap-priority = 100 fs-type = swap
Last edited by KVass; Jan 30 @ 7:57am
Pepe Jan 30 @ 10:19am 
Originally posted by KVass:
Originally posted by Pepe:
I've made a couple of "fixes" in my post:
- fixed wrong use of "virtual memory" in this context, "swap" is the right word:

- for testing purposes 200 value is fair, but I wouldn't use it on a normal system, added some explanation on that:

- added an additional explanation on zram conf file content:

- a few insignificant text format changes and typos fixes

Anyway, let me know if any of this worked for you. I really hope it does and you don't disable the zram. :)
Nope, the steam os does not give me the rights to change the config. There is no desire to directly understand root rights. So I guess I'll have to wait for a couple of updates. But I found a zram generator file. Here's what's written in the file in full, if you're interested
(If needed, i wrote some comment to) #comment -*- mode:sh; indent-tabs-mode: nill; sh-basic-offset: 2; -*- #vim: et sts=2 sw=2 [zram0] zram-size = ram/2 compression-algorithm = zstd swap-priority = 100 fs-type = swap
The whole config explains pretty much what we've discovered by using all the other commands. :)

Root rights are fine. I didn't mentioned because I thought you may know a few things about GNU/Linux. Configuration files that are installed with a package may use root as owner. Immutable system is a different story, but editing files owned by root is fine. To change this file just use sudo with your preferred text editor, or what you can find in SteamDeck.
sudo vim path/to/zram-generator.conf sudo vi ... sudo nano ... sudo emacs ...
Tip: for vi/vim, to make sure it saves the file even it might only have read rights (I don't know), you need to type :wq!, with the "bang" (exclamation mark) at the end.

In SteamDeck Desktop Mode, because it's KDE, you should find KWrite as a text editor, which can open files and ask for elevation when you try to save a file owned by other users, similar to Windows.

Later Edit: A little more explanations on the rights. /etc is the usual place configuration files of system applications are installed, the configs that are not local to a user. That's why even writing anything to /etc requires root elevation. It's pretty much like the Program Files or, even better, ProgramData in Windows. So even if you make another conf file there and let Valve's config alone, you will still need to use either the root user when creating and/or editing the file or sudo command using a "sudoers"/"wheel" user (I am speaking about default systems here, going down the rabbit whole, there can be users that can use sudo, but they are limited to which commands they can use sudo with - for example, this might be useful for a service application that runs with its own user and needs some access to a list of commands that require elevated rights).
Last edited by Pepe; Jan 30 @ 10:37am
KVass Feb 2 @ 8:07am 
Originally posted by Pepe:
Originally posted by KVass:
Nope, the steam os does not give me the rights to change the config. There is no desire to directly understand root rights. So I guess I'll have to wait for a couple of updates. But I found a zram generator file. Here's what's written in the file in full, if you're interested
(If needed, i wrote some comment to) #comment -*- mode:sh; indent-tabs-mode: nill; sh-basic-offset: 2; -*- #vim: et sts=2 sw=2 [zram0] zram-size = ram/2 compression-algorithm = zstd swap-priority = 100 fs-type = swap
The whole config explains pretty much what we've discovered by using all the other commands. :)

Root rights are fine. I didn't mentioned because I thought you may know a few things about GNU/Linux. Configuration files that are installed with a package may use root as owner. Immutable system is a different story, but editing files owned by root is fine. To change this file just use sudo with your preferred text editor, or what you can find in SteamDeck.
sudo vim path/to/zram-generator.conf sudo vi ... sudo nano ... sudo emacs ...
Tip: for vi/vim, to make sure it saves the file even it might only have read rights (I don't know), you need to type :wq!, with the "bang" (exclamation mark) at the end.

In SteamDeck Desktop Mode, because it's KDE, you should find KWrite as a text editor, which can open files and ask for elevation when you try to save a file owned by other users, similar to Windows.

Later Edit: A little more explanations on the rights. /etc is the usual place configuration files of system applications are installed, the configs that are not local to a user. That's why even writing anything to /etc requires root elevation. It's pretty much like the Program Files or, even better, ProgramData in Windows. So even if you make another conf file there and let Valve's config alone, you will still need to use either the root user when creating and/or editing the file or sudo command using a "sudoers"/"wheel" user (I am speaking about default systems here, going down the rabbit whole, there can be users that can use sudo, but they are limited to which commands they can use sudo with - for example, this might be useful for a service application that runs with its own user and needs some access to a list of commands that require elevated rights).
I mean, that file place in /usr/lib/systemd/zram-generator.conf. And give no permission to change it. In any text editor. I wonder, maybe i should create second zram-generator in /etc directory?

Edit: i create file in etc. with 200 priority, and (idk what is this but copy paste "fs-type = swap" from zram0 file). So, now in lsblk | grep zram its zram0 and zram1. But command swapon -s shows only /dev/zram1 (with 100 priority(why(?)) and swap file. So, i did it? Or this is something i don't understand.

Pss. Another problem that I'm trying to outline is that the deck has stopped taking up more memory in applications where 16GB of RAM is not enough. Let's say earlier, the deck could take memory from a swap file as much as 20 GB in total. Now he does not go beyond the borders. I also think, why is that? Because of the -2 priority?
Last edited by KVass; Feb 2 @ 11:00am
Pepe Feb 2 @ 2:16pm 
Originally posted by KVass:
Originally posted by Pepe:
The whole config explains pretty much what we've discovered by using all the other commands. :)

Root rights are fine. I didn't mentioned because I thought you may know a few things about GNU/Linux. Configuration files that are installed with a package may use root as owner. Immutable system is a different story, but editing files owned by root is fine. To change this file just use sudo with your preferred text editor, or what you can find in SteamDeck.
sudo vim path/to/zram-generator.conf sudo vi ... sudo nano ... sudo emacs ...
Tip: for vi/vim, to make sure it saves the file even it might only have read rights (I don't know), you need to type :wq!, with the "bang" (exclamation mark) at the end.

In SteamDeck Desktop Mode, because it's KDE, you should find KWrite as a text editor, which can open files and ask for elevation when you try to save a file owned by other users, similar to Windows.

Later Edit: A little more explanations on the rights. /etc is the usual place configuration files of system applications are installed, the configs that are not local to a user. That's why even writing anything to /etc requires root elevation. It's pretty much like the Program Files or, even better, ProgramData in Windows. So even if you make another conf file there and let Valve's config alone, you will still need to use either the root user when creating and/or editing the file or sudo command using a "sudoers"/"wheel" user (I am speaking about default systems here, going down the rabbit whole, there can be users that can use sudo, but they are limited to which commands they can use sudo with - for example, this might be useful for a service application that runs with its own user and needs some access to a list of commands that require elevated rights).
I mean, that file place in /usr/lib/systemd/zram-generator.conf. And give no permission to change it. In any text editor. I wonder, maybe i should create second zram-generator in /etc directory?

Edit: i create file in etc. with 200 priority, and (idk what is this but copy paste "fs-type = swap" from zram0 file). So, now in lsblk | grep zram its zram0 and zram1. But command swapon -s shows only /dev/zram1 (with 100 priority(why(?)) and swap file. So, i did it? Or this is something i don't understand.

When you didn't posted the config path, I assumed it was in /etc. If it's in /usr, it makes sense it doesn't work being edited. As mentioned in one of my posts. Immutable distros (I've mentioned Fedora) keep /usr and root (/ locked with os-tree. Of course, there's a hack to edit that, but I don't want to mention hacks, neither for editing not for freezing any files.

I don't know why zram0 disappeared or why the priority is set to 100.

Also, you don't need fs-type, by default it's swap for zram.
fs-type=
Specifies how the device shall be formatted. The default is ext2 if mount-point is specified, and swap otherwise.
I've posted some links. Please click on them and read the documentation if you don't understand what an option, a parameter means.

Sorry, but I think you're post is missing some info. I can't just see the whole picture from the fragments. Please post the conf files with their paths and all the outputs on the following commands.
ls -l /usr/lib/systemd/zram-generator.conf cat /usr/lib/systemd/zram-generator.conf ls -l <your_etc_conf_path> cat <your_etc_conf_path> free -wh swapon zramctl

Also, make sure you rebooted the Steam Deck or reloaded the service (forgot to mention them). Reload & Start without reboot.
systemctl daemon-reload systemctl start /dev/zram1
I guess you did something as you said zram1 appeared.

Originally posted by KVass:

Pss. Another problem that I'm trying to outline is that the deck has stopped taking up more memory in applications where 16GB of RAM is not enough. Let's say earlier, the deck could take memory from a swap file as much as 20 GB in total. Now he does not go beyond the borders. I also think, why is that? Because of the -2 priority?
In Kernel, prio is defined as int, so it should be able to take even lower negative numbers, yet man swapon talks about valid values from -1 to 32767.
-p, --priority priority Specify the priority of the swap device. priority is a value between -1 and 32767. Higher numbers indicate higher priority. See swapon(2) for a full description of swap priorities. Add pri=value to the option field of /etc/fstab for use with swapon -a. When no priority is defined, it defaults to -1.
That being said, the man page might be obsolete or trying to keep users on a positive path. In your previous posts, the swap from the swap file appeared both in the swapon and free commands. So it is still used, if needed. Otherwise, it wouldn't show up.

Now, I don't want to go into the details of the system memory used by applications and swap, but there are two distinct things. Apps don't know about swap, and apps run only in system virtual memory, not in swap. Thanks Microsoft for calling everything "virtual memory". What I can only guess is that the zram is getting a little full, and the minimum system memory to be used by a certain app is just too small to run a big bunch of it, maybe the app just has very big sets of data that just don't fit in. There's also the possibility that the app itself is checking how much memory is available and just quits by default.

Swap is NOT RAM (or system memory, or real accessible virtual memory for the apps).


Anyway, please post the outputs. Also, I was thinking, you could try to create the conf file in /etc with zram0 instead of zram1 as definition. I haven't tested, but maybe zram-generator will overwrite the parameters, keeping the newest options defined for zram0. This way you would end up with just one zram with the wanted parameters.

Later Edit: Yes, it's working.
sudo swapoff /dev/zram1 sudo swapoff /dev/zram0 sudo zramctl --reset /dev/zram1 sudo zramctl --reset /dev/zram0 swapon -s (should be empty) zramctl (should be empty) sudo su -c 'printf "[zram0] zram-size = 4096 compression-algorithm = lzo-rle swap-priority = 200" > /etc/systemd/zram-generator.conf' sudo systemctl daemon-reload swapon -s Filename Type Size Used Priority /dev/zram0 partition 4194300 0 200 (you should see the swap file as well) zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 lzo-rle 4G 4K 69B 20K 8 [SWAP] # I didn't need to do service start on my PC, but, if you don't see # anything in swapon and zramctl, just force a service start systemctl start /dev/zram0

Later Edit 2: First off, always post the outputs so I can see what's going on. Last post, you said you ran lsblk and swapon, but not zramctl.

Secondly, if everything looks OK, tell me how does SD feel? Snappier than with the previous zram definition? Snappier than without zram at all? Please do some tests with games that fit the memory limitation. Give me some output of free -hw, swapon -s and zramctl while playing. I want to see how much zram is actually occupied. Then, we'll look at the apps that don't start. Maybe they'll start now, maybe. Or just shrink the zram a bit (3584, 3072)? Just save everything you do in a file and post it here.
Last edited by Pepe; Feb 2 @ 3:41pm
KVass Feb 5 @ 6:10am 
Originally posted by Pepe:
Originally posted by KVass:
I mean, that file place in /usr/lib/systemd/zram-generator.conf. And give no permission to change it. In any text editor. I wonder, maybe i should create second zram-generator in /etc directory?

Edit: i create file in etc. with 200 priority, and (idk what is this but copy paste "fs-type = swap" from zram0 file). So, now in lsblk | grep zram its zram0 and zram1. But command swapon -s shows only /dev/zram1 (with 100 priority(why(?)) and swap file. So, i did it? Or this is something i don't understand.

When you didn't posted the config path, I assumed it was in /etc. If it's in /usr, it makes sense it doesn't work being edited. As mentioned in one of my posts. Immutable distros (I've mentioned Fedora) keep /usr and root (/ locked with os-tree. Of course, there's a hack to edit that, but I don't want to mention hacks, neither for editing not for freezing any files.

I don't know why zram0 disappeared or why the priority is set to 100.

Also, you don't need fs-type, by default it's swap for zram.
fs-type=
Specifies how the device shall be formatted. The default is ext2 if mount-point is specified, and swap otherwise.
I've posted some links. Please click on them and read the documentation if you don't understand what an option, a parameter means.

Sorry, but I think you're post is missing some info. I can't just see the whole picture from the fragments. Please post the conf files with their paths and all the outputs on the following commands.
ls -l /usr/lib/systemd/zram-generator.conf cat /usr/lib/systemd/zram-generator.conf ls -l <your_etc_conf_path> cat <your_etc_conf_path> free -wh swapon zramctl

Also, make sure you rebooted the Steam Deck or reloaded the service (forgot to mention them). Reload & Start without reboot.
systemctl daemon-reload systemctl start /dev/zram1
I guess you did something as you said zram1 appeared.

Originally posted by KVass:

Pss. Another problem that I'm trying to outline is that the deck has stopped taking up more memory in applications where 16GB of RAM is not enough. Let's say earlier, the deck could take memory from a swap file as much as 20 GB in total. Now he does not go beyond the borders. I also think, why is that? Because of the -2 priority?
In Kernel, prio is defined as int, so it should be able to take even lower negative numbers, yet man swapon talks about valid values from -1 to 32767.
-p, --priority priority Specify the priority of the swap device. priority is a value between -1 and 32767. Higher numbers indicate higher priority. See swapon(2) for a full description of swap priorities. Add pri=value to the option field of /etc/fstab for use with swapon -a. When no priority is defined, it defaults to -1.
That being said, the man page might be obsolete or trying to keep users on a positive path. In your previous posts, the swap from the swap file appeared both in the swapon and free commands. So it is still used, if needed. Otherwise, it wouldn't show up.

Now, I don't want to go into the details of the system memory used by applications and swap, but there are two distinct things. Apps don't know about swap, and apps run only in system virtual memory, not in swap. Thanks Microsoft for calling everything "virtual memory". What I can only guess is that the zram is getting a little full, and the minimum system memory to be used by a certain app is just too small to run a big bunch of it, maybe the app just has very big sets of data that just don't fit in. There's also the possibility that the app itself is checking how much memory is available and just quits by default.

Swap is NOT RAM (or system memory, or real accessible virtual memory for the apps).


Anyway, please post the outputs. Also, I was thinking, you could try to create the conf file in /etc with zram0 instead of zram1 as definition. I haven't tested, but maybe zram-generator will overwrite the parameters, keeping the newest options defined for zram0. This way you would end up with just one zram with the wanted parameters.

Later Edit: Yes, it's working.
sudo swapoff /dev/zram1 sudo swapoff /dev/zram0 sudo zramctl --reset /dev/zram1 sudo zramctl --reset /dev/zram0 swapon -s (should be empty) zramctl (should be empty) sudo su -c 'printf "[zram0] zram-size = 4096 compression-algorithm = lzo-rle swap-priority = 200" > /etc/systemd/zram-generator.conf' sudo systemctl daemon-reload swapon -s Filename Type Size Used Priority /dev/zram0 partition 4194300 0 200 (you should see the swap file as well) zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 lzo-rle 4G 4K 69B 20K 8 [SWAP] # I didn't need to do service start on my PC, but, if you don't see # anything in swapon and zramctl, just force a service start systemctl start /dev/zram0

Later Edit 2: First off, always post the outputs so I can see what's going on. Last post, you said you ran lsblk and swapon, but not zramctl.

Secondly, if everything looks OK, tell me how does SD feel? Snappier than with the previous zram definition? Snappier than without zram at all? Please do some tests with games that fit the memory limitation. Give me some output of free -hw, swapon -s and zramctl while playing. I want to see how much zram is actually occupied. Then, we'll look at the apps that don't start. Maybe they'll start now, maybe. Or just shrink the zram a bit (3584, 3072)? Just save everything you do in a file and post it here.
I can't check everything anytime soon, but I've checked something. Indeed, zram1 works instead of zram0, it seems that when deleting a file from zram1, the stock zram config turned out to be slightly worse. To my surprise, the most important thing I saw was that when zram was turned off altogether and only the swap file remained, the performance in Hogwarts legacy was simply terrible, second statters. It turns out that zram really improves the situation (but it's strange why it seemed to me that before, when there was only a swap file, the performance was good).
Ps. I will try to disable the swap file completely in the near future, leaving only zram.
Pss. When I was playing Hogwarts, the memory was used like this: with 1GB of swap and 4GB of zram, both were filled up almost immediately after starting the level. Having increased the swap file to 16GB, of course, not all of it was filled. But by disabling zram, the swap was used for 4-6 GB and each filling with data was accompanied by the strongest statters.(actually, it's worth saying that I don't know how to track what's happening in real time, so I just minimized game window to enter commands into the console)

Sry, I can't check all the commands thoroughly yet. I'll try to do it soon.
Last edited by KVass; Feb 5 @ 6:18am
< >
Showing 1-13 of 13 comments
Per page: 1530 50

Date Posted: Jan 11 @ 7:34am
Posts: 13