@@ -59,73 +59,72 @@ num_devices parameter is optional and tells zram how many devices should be
59
59
pre-created. Default: 1.
60
60
61
61
2) Set max number of compression streams
62
- Regardless the value passed to this attribute, ZRAM will always
63
- allocate multiple compression streams - one per online CPUs - thus
64
- allowing several concurrent compression operations. The number of
65
- allocated compression streams goes down when some of the CPUs
66
- become offline. There is no single-compression-stream mode anymore,
67
- unless you are running a UP system or has only 1 CPU online.
68
-
69
- To find out how many streams are currently available:
62
+ Regardless the value passed to this attribute, ZRAM will always
63
+ allocate multiple compression streams - one per online CPUs - thus
64
+ allowing several concurrent compression operations. The number of
65
+ allocated compression streams goes down when some of the CPUs
66
+ become offline. There is no single-compression-stream mode anymore,
67
+ unless you are running a UP system or has only 1 CPU online.
68
+
69
+ To find out how many streams are currently available:
70
70
cat /sys/block/zram0/max_comp_streams
71
71
72
72
3) Select compression algorithm
73
- Using comp_algorithm device attribute one can see available and
74
- currently selected (shown in square brackets) compression algorithms,
75
- change selected compression algorithm (once the device is initialised
76
- there is no way to change compression algorithm).
73
+ Using comp_algorithm device attribute one can see available and
74
+ currently selected (shown in square brackets) compression algorithms,
75
+ change selected compression algorithm (once the device is initialised
76
+ there is no way to change compression algorithm).
77
77
78
- Examples:
78
+ Examples:
79
79
#show supported compression algorithms
80
80
cat /sys/block/zram0/comp_algorithm
81
81
lzo [lz4]
82
82
83
83
#select lzo compression algorithm
84
84
echo lzo > /sys/block/zram0/comp_algorithm
85
85
86
- For the time being, the `comp_algorithm' content does not necessarily
87
- show every compression algorithm supported by the kernel. We keep this
88
- list primarily to simplify device configuration and one can configure
89
- a new device with a compression algorithm that is not listed in
90
- `comp_algorithm'. The thing is that, internally, ZRAM uses Crypto API
91
- and, if some of the algorithms were built as modules, it's impossible
92
- to list all of them using, for instance, /proc/crypto or any other
93
- method. This, however, has an advantage of permitting the usage of
94
- custom crypto compression modules (implementing S/W or H/W
95
- compression).
86
+ For the time being, the `comp_algorithm' content does not necessarily
87
+ show every compression algorithm supported by the kernel. We keep this
88
+ list primarily to simplify device configuration and one can configure
89
+ a new device with a compression algorithm that is not listed in
90
+ `comp_algorithm'. The thing is that, internally, ZRAM uses Crypto API
91
+ and, if some of the algorithms were built as modules, it's impossible
92
+ to list all of them using, for instance, /proc/crypto or any other
93
+ method. This, however, has an advantage of permitting the usage of
94
+ custom crypto compression modules (implementing S/W or H/W compression).
96
95
97
96
4) Set Disksize
98
- Set disk size by writing the value to sysfs node 'disksize'.
99
- The value can be either in bytes or you can use mem suffixes.
100
- Examples:
101
- # Initialize /dev/zram0 with 50MB disksize
102
- echo $((50*1024*1024)) > /sys/block/zram0/disksize
97
+ Set disk size by writing the value to sysfs node 'disksize'.
98
+ The value can be either in bytes or you can use mem suffixes.
99
+ Examples:
100
+ # Initialize /dev/zram0 with 50MB disksize
101
+ echo $((50*1024*1024)) > /sys/block/zram0/disksize
103
102
104
- # Using mem suffixes
105
- echo 256K > /sys/block/zram0/disksize
106
- echo 512M > /sys/block/zram0/disksize
107
- echo 1G > /sys/block/zram0/disksize
103
+ # Using mem suffixes
104
+ echo 256K > /sys/block/zram0/disksize
105
+ echo 512M > /sys/block/zram0/disksize
106
+ echo 1G > /sys/block/zram0/disksize
108
107
109
108
Note:
110
109
There is little point creating a zram of greater than twice the size of memory
111
110
since we expect a 2:1 compression ratio. Note that zram uses about 0.1% of the
112
111
size of the disk when not in use so a huge zram is wasteful.
113
112
114
113
5) Set memory limit: Optional
115
- Set memory limit by writing the value to sysfs node 'mem_limit'.
116
- The value can be either in bytes or you can use mem suffixes.
117
- In addition, you could change the value in runtime.
118
- Examples:
119
- # limit /dev/zram0 with 50MB memory
120
- echo $((50*1024*1024)) > /sys/block/zram0/mem_limit
121
-
122
- # Using mem suffixes
123
- echo 256K > /sys/block/zram0/mem_limit
124
- echo 512M > /sys/block/zram0/mem_limit
125
- echo 1G > /sys/block/zram0/mem_limit
126
-
127
- # To disable memory limit
128
- echo 0 > /sys/block/zram0/mem_limit
114
+ Set memory limit by writing the value to sysfs node 'mem_limit'.
115
+ The value can be either in bytes or you can use mem suffixes.
116
+ In addition, you could change the value in runtime.
117
+ Examples:
118
+ # limit /dev/zram0 with 50MB memory
119
+ echo $((50*1024*1024)) > /sys/block/zram0/mem_limit
120
+
121
+ # Using mem suffixes
122
+ echo 256K > /sys/block/zram0/mem_limit
123
+ echo 512M > /sys/block/zram0/mem_limit
124
+ echo 1G > /sys/block/zram0/mem_limit
125
+
126
+ # To disable memory limit
127
+ echo 0 > /sys/block/zram0/mem_limit
129
128
130
129
6) Activate:
131
130
mkswap /dev/zram0
0 commit comments