Giter VIP home page Giter VIP logo

zram-swap's Introduction

zram-swap

Simple zram swap setup + teardown script for modern systemd Linux systems

https://github.com/foundObjects/zram-swap

Why?

There are dozens of zram swap scripts out there, but most of them are overly complicated and do things that haven't been neccessary since linux 3.X or have massive logic errors in their swap size calculations. This script is simple and reliable, modern and easy to configure.

Installation

git clone https://github.com/foundObjects/zram-swap.git
cd zram-swap && sudo ./install.sh

Usage

zram-swap.service will be started automatically after installation and during each subsequent boot. The default allocation creates a zram device that should use around half of physical memory when completely full.

The default configuration using lz4 should work well for most people. lzo may provide slightly better RAM utilization at a cost of slightly more expensive decompression. zstd should provide better compression than lz* and still be moderately fast on most machines. On very modern kernels the best overall choice is probably lzo-rle.

Edit /etc/default/zram-swap if you'd like to change compression algorithms or swap allocation and then restart zram-swap with systemctl restart zram-swap.service.

Run zramctl during use to monitor swap compression and real memory usage.

Debugging

Start zram-swap.sh with zram-swap.sh -x (start|stop) to view the debug trace and determine what's going wrong.

To dump the full execution trace during service start/stop edit /etc/systemd/systemd/zram-swap.service and add -x to the following two lines:

ExecStart=/usr/local/sbin/zram-swap.sh -x init
ExecStop=/usr/local/sbin/zram-swap.sh -x  end

Compatibility

This should run on pretty much any recent (4.0+? kernel) Linux system using systemd. If anyone wants to try it on something really old and let me know how far back compatibility goes I'm interested, but I don't have any legacy systems to test on at the moment.

The script will also work on non-systemd Linux without issue and I welcome PRs supporting SysVinit.

zram-swap's People

Contributors

foundobjects avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.