Benutzer:Rdiez/Linux zram

Aus /dev/tal
Wechseln zu: Navigation, Suche
Warning sign
Dies sind die persönlichen Benutzerseiten von rdiez, bitte nicht verändern! Ausnahmen sind nur einfache Sprachkorrekturen wie Tippfehler, falsche Präpositionen oder Ähnliches. Alles andere bitte nur dem Benutzer melden!


Linux zram

zram is a Linux block device that lives in RAM and compresses any data written to it.

When created, a zram device advertises its nominal capacity as empty space but allocates no actual memory. You can then create a filesystem on the zram device and use it as a RAM disk. As data is gradually written to it, zram will allocate as much kernel memory as necessary to hold the compressed data.

Compressing data takes CPU time, but can be faster than writing to a physical hard disk. If the data happens to not compress well, zram will allocate as much RAM as all the original data. If that is always the case, then it is best to use an uncompressed RAM disk like ramdisk, ramfs or tmpfs.

zram does not support the TRIM command, which is typically used with SSD disks. Therefore, zram will not free allocated memory even if all files are deleted. It's a little weird, because zram's predecessor project compcache does have this feature.

Availability

zram was considered stable as of Linux kernel version 3.14, released in March 2014. Ubuntu 14.04 has kernel version 3.13 and its zram is still considered experimental, although it had already enjoyed widespread usage then.

The version planned for kernel 3.15 supports the alternative compression algorithm LZ4, in addition to the default LZO. zram does NOT attempt to recompress the data in the background if the CPU is idle.

Using zram as Swap Device

Using zram as a swap device is an interesting idea. I have not found on the Internet many performance tests yet, but most people who have tried it report an increased performance for standard office tasks, especially if the computer has little RAM. That seems like a contradiction at first, because zram uses RAM itself, making a scarce resource even scarcer.