SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
swapinzram allows you to set up a swap space in RAM instead of or in addition to swap partitions and/or swap files. Expected benefits:
1. Way faster than swapping on any mass storage device.
2. Do not contribute to wear out devices like USB sticks, SD cards or MMC drives.
3. Increases your usable RAM size, as the files are compressed.
These benefits should be more important if you have a small RAM and/or the swap file or partition is on a flash drive like those mentioned above, and when you run something using a lot of RAM. Raspberry Pi users are welcome! The cost is just a small overhead for compression/decompression, with a ratio benefit/cost in terms of performances way greater than 1.
The swap space can be created or removed at any time, just running as root "swapinzram start" or "swapinzram stop" and configured editing the file /etc/swapinzram.conf. To know more, read after installation: /usr/doc/swapinzram-1/README
Caveats:
1. Tested on Slackware current, not on Slackware 14.2 (but should work there, let me know any issue).
2. If you use a huge kernel, set in /etc/swapinzram.conf COMPRESSION_ALGORITHM to anything other than zstd, like e.g. lzo-rle, cf. this request for -current.
3. Don't hibernate the machine while swap in zram is active.
Don't be afraid to test (and this is just a shell script so it's easy to check what it does), the most important issue that you could come across, I think, is a deadlock needing a hard reboot (I have not seen one reported using zram, though).
Feedback is more than welcome, of course!
Last edited by Didier Spaier; 11-26-2020 at 11:39 AM.
@Didier would you explain why such idea? Reason for?
I do have a similar zram script active on a 10 years old Thinkpad since some days, so far no issues.
I do hibernate to ram without problems, maybe it was luck ;-)
The overall performance feels better, i now have generel less IO, i think because some swapping also takes place even if not all ram is in use.
When on load(e.g. compiling something), the destop is not slowed down much anymore.
Compiling is also faster when it comes to swapping.
Maybe it's even beneficial for the battery, since IO is more expensive than compress to ram.
I use swapfiles(no partition) since years, and like the idea of swap in Ram even more.
@Didier: Why do you want to replace zramctl in your script? Since it's in util-linux it's almost always available.
Maybe lzo-rle is just good enough, and no change needed for the kernel? https://www.phoronix.com/scan.php?pa...Better-Perform
@Didier would you explain why such idea? Reason for?
I brief, the purpose its to allow Linux users to get the best of their hardware: speed up the execution of programs and maximize the life span of some kinds of drives (mostly cheap flash drives) subject to wearing out.
@Didier: Why do you want to replace zramctl in your script? Since it's in util-linux it's almost always available.
Maybe lzo-rle is just good enough, and no change needed for the kernel? https://www.phoronix.com/scan.php?pa...Better-Perform
Yes zramctl is almost always available, but it's not really needed just to provide information that can be get directly reading /sys. Also if the driver is updated (which happened recently adding the backend storage and also zstd) we won't need to wait zramct to be updated to draw benefit of the new features (man zramctl mentions neither at time of writing).
I have read the article on Phoronix, but when Michael Larbel wrote it zstd was not yet available for zram. For what I have read zlo-rle could be a little faster than zstd for compression/decompression but zstd offers a better compression ratio. This can interesting esp. if you have few RAM. Anyway, this can be set in the config file. And the change in the kernel wouldn't cost much time to Pat, I think - until he gets rid of the huge kernel
I am not convinced to use only ZRAM as swap - perhaps two swap devices - the second one on hd - with priority set to use ZRAM in first place. I am not quite sure it is possible.
I am not convinced to use only ZRAM as swap - perhaps two swap devices - the second one on hd - with priority set to use ZRAM in first place. I am not quite sure it is possible.
Even with a higher priority on zram, it may happen that zram get's full with later unused data, and the slow swap comes in use again.
Didier did also for that case request a kernelconfig change, for me it seems a bit weird to configure.
So for me it's simpler to just have "fast" swap.
As long it's a matter of "chmod +/-x /etc/rc.d/rc.zramswap", and have swap in /etc/fstab or not, everyone may decide as one wish.
I've been using zram for a long time. The only once zram exhaused because of running aMule compiled with wxGTK3, as linux would not like to kill process if no other choices. Since then I've been using earlyoom and zram both.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.