@@ -125,15 +125,46 @@ function enable_modules_raspbiantools() {
125
125
done
126
126
}
127
127
128
+ function enable_zram_raspbiantools() {
129
+ if [[ " $__os_id " == " Raspbian" ]] || [[ " $__os_id " == " Debian" ]]; then
130
+ aptInstall zram-tools
131
+ # Use 50% of the current memory for ZRAM
132
+ local percent=" 50"
133
+ iniConfig " =" " " " /etc/default/zramswap"
134
+ # Raspbian Buster uses keyword PERCENTAGE
135
+ iniSet " PERCENTAGE" " $percent "
136
+ # Debian Bullseye/Bookworm use keyword PERCENT
137
+ iniSet " PERCENT" " $percent "
138
+ # Use zstd compression algorithm if kernel supports it
139
+ [[ -f /sys/class/block/zram0/comp_algorithm ]] && [[ " $( cat /sys/class/block/zram0/comp_algorithm) " == * zstd* ]] && iniSet " ALGO" " zstd"
140
+ service zramswap stop
141
+ service zramswap start
142
+ elif [[ " $__os_id " == " Ubuntu" ]]; then
143
+ aptInstall zram-config
144
+ # Ubuntu has a automatic zram configuration
145
+ fi
146
+ }
147
+
148
+ function disable_zram_raspbiantools() {
149
+ if [[ " $__os_id " == " Raspbian" ]] || [[ " $__os_id " == " Debian" ]]; then
150
+ apt remove -y zram-tools
151
+ elif [[ " $__os_id " == " Ubuntu" ]]; then
152
+ apt remove -y zram-config
153
+ fi
154
+ }
155
+
128
156
function gui_raspbiantools() {
129
157
while true ; do
158
+ local zram_status=" Enable"
159
+ [[ $( cat /proc/swaps) == * zram* ]] && zram_status=" Disable"
130
160
local cmd=(dialog --backtitle " $__backtitle " --menu " Choose an option" 22 76 16)
131
161
local options=(
132
162
1 " Upgrade Raspbian packages"
133
163
2 " Install Pixel desktop environment"
134
164
3 " Remove some unneeded packages (pulseaudio / cups / wolfram)"
135
165
4 " Disable screen blanker"
136
166
5 " Enable needed kernel module uinput"
167
+ 6 " $zram_status compressed memory (ZRAM)"
137
168
)
138
169
local choice=$( " ${cmd[@]} " " ${options[@]} " 2>&1 > /dev/tty)
139
170
if [[ -n " $choice " ]]; then
@@ -155,6 +186,9 @@ function gui_raspbiantools() {
155
186
5)
156
187
rp_callModule " $md_id " enable_modules
157
188
;;
189
+ 6)
190
+ [[ " $zram_status " == " Enable" ]] && rp_callModule " $md_id " enable_zram || rp_callModule " $md_id " disable_zram
191
+ ;;
158
192
esac
159
193
else
160
194
break
0 commit comments