Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using ZRAM as a backing block device for /tmp filesystem in the following manner:

echo 8000000000 > /sys/block/zram0/disksize
mkfs.ext4 -O dir_nlink,extent,extra_isize,flex_bg,^has_journal,uninit_bg -m0 \
          -b 4096 -L "zram0" /dev/zram0
mount -o barrier=0,commit=240,noatime,nodev,nosuid /dev/zram0 /tmp
chmod aogu+rwx /tmp

It works out reasonably well for me - however, there is an issue here - when files are removed, they are not zero'ed, so the ZRAM does not remote the compressed pages. Obviously running

dd if=/dev/zero of=/tmp/ZERO bs=1M count={free-space-some-rest}; rm /tmp/ZERO

clears it up in the ZRAM - it gets notified of zero-pages and shrinks the store.

How can I get ext4 to zero used pages on delete? Also, any other suggestions on how to optimize it?

share|improve this question
up vote 1 down vote accepted

Try enabling the discard mount option for an Ext4 filesystem and running a recent Linux kernel. This is used for SSDs mainly, to tell the controller which blocks are now unused and ready for re-use.

Compcache/zram should have support for discarding blocks in recent revisions, based on this and this post.

share|improve this answer
I don't think it works - there is still some good amount of RAM trimmed when zeroing it forcibly - but perhaps it does, I guess more testing needs to be done. – qdot Sep 24 '12 at 19:03
One of the final comments in that thread had answered the question for me :) – qdot Dec 14 '12 at 15:48
@qdot Could you answer the question here at as well? – user239558 Jun 19 '13 at 9:45

You must log in to answer this question.

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