Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 1 | zram: Compressed RAM based block devices |
| 2 | ---------------------------------------- |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 3 | |
| 4 | Project home: http://compcache.googlecode.com/ |
| 5 | |
| 6 | * Introduction |
| 7 | |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 8 | The zram module creates RAM based block devices: /dev/ramX (X = 0, 1, ...). |
| 9 | Pages written to these disks are compressed and stored in memory itself. |
| 10 | These disks allow very fast I/O and compression provides good amounts of |
| 11 | memory savings. |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 12 | |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 13 | See project home for use cases, performance numbers and a lot more. |
| 14 | |
| 15 | Individual zram devices are configured and initialized using zramconfig |
| 16 | userspace utility as shown in examples below. See zramconfig man page for |
| 17 | more details. |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 18 | |
| 19 | * Usage |
| 20 | |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 21 | Following shows a typical sequence of steps for using zram. |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 22 | |
| 23 | 1) Load Modules: |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 24 | modprobe zram num_devices=4 |
| 25 | This creates 4 (uninitialized) devices: /dev/zram{0,1,2,3} |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 26 | (num_devices parameter is optional. Default: 1) |
| 27 | |
| 28 | 2) Initialize: |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 29 | Use zramconfig utility to configure and initialize individual |
| 30 | zram devices. For example: |
| 31 | zramconfig /dev/zram0 --init # uses default value of disksize_kb |
| 32 | zramconfig /dev/zram1 --disksize_kb=102400 # 100MB /dev/zram1 |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 33 | |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 34 | *See zramconfig man page for more details and examples* |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 35 | |
| 36 | 3) Activate: |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 37 | mkswap /dev/zram0 |
| 38 | swapon /dev/zram0 |
| 39 | |
| 40 | mkfs.ext4 /dev/zram1 |
| 41 | mount /dev/zram1 /tmp |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 42 | |
| 43 | 4) Stats: |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 44 | zramconfig /dev/zram0 --stats |
| 45 | zramconfig /dev/zram1 --stats |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 46 | |
| 47 | 5) Deactivate: |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 48 | swapoff /dev/zram0 |
| 49 | umount /dev/zram1 |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 50 | |
| 51 | 6) Reset: |
Nitin Gupta | 00ac9ba | 2010-06-01 13:31:26 +0530 | [diff] [blame] | 52 | zramconfig /dev/zram0 --reset |
| 53 | zramconfig /dev/zram1 --reset |
| 54 | (This frees memory allocated for the given device). |
Nitin Gupta | 47f9afb | 2009-09-22 10:26:54 +0530 | [diff] [blame] | 55 | |
| 56 | |
| 57 | Please report any problems at: |
| 58 | - Mailing list: linux-mm-cc at laptop dot org |
| 59 | - Issue tracker: http://code.google.com/p/compcache/issues/list |
| 60 | |
| 61 | Nitin Gupta |
| 62 | ngupta@vflare.org |