Since I don't use my laptop's CD-drive I want to put a small (8 GB) SSD into the CD-drive slot (I'll use a caddy similar to this one). I want to use compressed btrfs on the SSD and put all the data on the big HDD. I want to avoid unnecessary spin-ups. I want the system to be fast... I want to minimize wearing of the SSD.

What tricks are there to use a compressed ramdisk wisely (using but not overusing it)? How to enable it? What values are sensible?

Also see this post (I split my questions up).

  • You should note that you'll probably lose hibernation support with this.
    – Oli
    Jun 14 '11 at 15:03
  • 1
    Doesn't work anyway...
    – turbo
    Jun 14 '11 at 15:07

For Natty and up just use zramswap. I've already baked sane defaults and automatic setup in there. In fact, it adapts to your system automatically and I really doubt you'll achieve better results by manual setup.

  • Thanks for the link, I stumbled upon it before. It's seems to be just a packaged upstart script as well. EDIT: ah it just noticed that you made it ;P
    – turbo
    Oct 20 '11 at 8:59
  • Now there's zram-config. I have filed a bug against it because it fails at system start in Precise Beta here but it works as expected: sudo service zram-config start creates one zram swap for each processor core.
    – turbo
    Mar 16 '12 at 13:42
  • Autostart of zram-config in precise works now.
    – turbo
    May 22 '12 at 15:17
  • Gotta merge the two, neither of them is perfect but I hope that together we'll make something great.
    – Shnatsel
    Jun 1 '12 at 7:29

Update: In Natty it doesn't work that way.See this question.

I'll answer my question myself, but for now just for Lucid (10.04) since that's what I'm on right now. The speed gains are really astonishing. Whenever ram became scarce on my system (2 GB, shared graphics, some programs in background, big chromium session) my laptop started to swap often. Just that swapping usually meant near complete standstill (mouse stutters, greyed out apps etc). vm.swappiness is at 100 so swap is used before it's too late, but stil I had minute long waits till the laptop responded again.

tl;dr: When the PC starts swapping the speed stays the same. Nice!

To try it: do sudo modprobe ramzswap disksize_kb=524288 memlimit_kb=196608 This creates a 512 MB compressed swap with a limit on used ram of 192 MB. Note that the ram will only be eaten when the swapfile is actually used. Do sudo swapon /dev/ramzswap0 to enable it. Open several tabs or several ram heavy apps (OOo, gimp, blender) and watch free -m and sudo swapon -s. Your ramzswap should show up and get filled at no noticable speedloss.

To enable it permanently: do sudo nano /etc/initramfs-tools/initramfs.conf and search for COMPCACHE_SIZE="" and replace it with COMPCACHE_SIZE="512 M" or whatever size of uncompressed swap you wish to have. For example "30 %" is also possible. Profit.

I didn't find a way to enable compcache/ramzswap in /etc/fstab which is strange.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.