4

I need a ramdisk who handle transparent realtime compression on write and decompression on read.

Example : I use /dev/shm, or I create a new tmpfs, mount it writeable and compressed.

I wrote and read about 500 Mb - 1 GB of text files. The files' content is not fixed, every few seconds the files are updated.

So squashfs / zramswap seems not to fit my goal.

I wonder about fusecompress or other solutions.

1 Answer 1

3

It seems it is possible to use zram without swap.

This script create a ram disk, maximum ram usage is 256 Mbyte. You can run it with sudo or put the script in /etc/init.d/

#!/bin/bash

modprobe zram num_devices=1 
# max ram usage = 256 Mbytes
echo 256M > /sys/block/zram0/disksize
mke2fs -q -m 0 -b 4096 -O sparse_super -L zram /dev/zram0
mount -o relatime,noexec,nosuid /dev/zram0 /mnt/zram
# eof
4
  • kernel.org/doc/Documentation/blockdev/zram.txt The value can be either in bytes or you can use mem suffixes. Example: echo 512M > /sys/block/zram0/disksize
    – Massimo
    Commented Dec 29, 2015 at 11:20
  • What is the purpose of mentioned mount options? Commented Oct 9, 2017 at 12:11
  • modprobe zram just do nothing when zram module is already loaded. Commented Oct 9, 2017 at 12:18
  • As written might not free memory after files are deleted (on my system I encountered the issue), need to run fstrim to make memory available again. discard mount option might be doing same "automatically", now I'm testing it. Cheers and thanks. Commented Nov 11, 2022 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .