zram.txt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. zram: Compressed RAM based block devices
  2. ----------------------------------------
  3. Project home: http://compcache.googlecode.com/
  4. * Introduction
  5. The zram module creates RAM based block devices named /dev/zram<id>
  6. (<id> = 0, 1, ...). Pages written to these disks are compressed and stored
  7. in memory itself. These disks allow very fast I/O and compression provides
  8. good amounts of memory savings. Some of the usecases include /tmp storage,
  9. use as swap disks, various caches under /var and maybe many more :)
  10. Statistics for individual zram devices are exported through sysfs nodes at
  11. /sys/block/zram<id>/
  12. * Usage
  13. Following shows a typical sequence of steps for using zram.
  14. 1) Load Module:
  15. modprobe zram num_devices=4
  16. This creates 4 devices: /dev/zram{0,1,2,3}
  17. (num_devices parameter is optional. Default: 1)
  18. 2) Set Disksize (Optional):
  19. Set disk size by writing the value to sysfs node 'disksize'
  20. (in bytes). If disksize is not given, default value of 25%
  21. of RAM is used.
  22. # Initialize /dev/zram0 with 50MB disksize
  23. echo $((50*1024*1024)) > /sys/block/zram0/disksize
  24. NOTE: disksize cannot be changed if the disk contains any
  25. data. So, for such a disk, you need to issue 'reset' (see below)
  26. before you can change its disksize.
  27. 3) Activate:
  28. mkswap /dev/zram0
  29. swapon /dev/zram0
  30. mkfs.ext4 /dev/zram1
  31. mount /dev/zram1 /tmp
  32. 4) Stats:
  33. Per-device statistics are exported as various nodes under
  34. /sys/block/zram<id>/
  35. disksize
  36. num_reads
  37. num_writes
  38. invalid_io
  39. notify_free
  40. discard
  41. zero_pages
  42. orig_data_size
  43. compr_data_size
  44. mem_used_total
  45. 5) Deactivate:
  46. swapoff /dev/zram0
  47. umount /dev/zram1
  48. 6) Reset:
  49. Write any positive value to 'reset' sysfs node
  50. echo 1 > /sys/block/zram0/reset
  51. echo 1 > /sys/block/zram1/reset
  52. (This frees all the memory allocated for the given device).
  53. Please report any problems at:
  54. - Mailing list: linux-mm-cc at laptop dot org
  55. - Issue tracker: http://code.google.com/p/compcache/issues/list
  56. Nitin Gupta
  57. ngupta@vflare.org