File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,22 @@ define_zram() {
3131 sudo swapon /dev/zram0
3232 echo " $zram_size " | sudo tee /etc/zram_config > /dev/null
3333 echo " ZRAM created and activated. Configuration saved."
34+
35+ if ! grep -q " /etc/rc.local" /etc/rc.local; then
36+ echo " #!/bin/bash" | sudo tee /etc/rc.local > /dev/null
37+ sudo chmod +x /etc/rc.local
38+ fi
39+ sudo sed -i ' /exit 0/d' /etc/rc.local
40+ sudo bash -c ' cat <<EOL >> /etc/rc.local
41+ if [[ -f /etc/zram_config ]]; then
42+ zram_size=\$(cat /etc/zram_config)
43+ modprobe zram
44+ echo \$((zram_size * 1024 * 1024)) > /sys/block/zram0/disksize
45+ mkswap /dev/zram0
46+ swapon /dev/zram0
47+ fi
48+ exit 0
49+ EOL'
3450 else
3551 echo " Invalid size entered. Please enter a numeric value in MB."
3652 fi
@@ -53,13 +69,15 @@ delete_zram() {
5369 sudo swapoff /dev/zram0
5470 sudo modprobe -r zram
5571 sudo rm -f /etc/zram_config
72+ sudo sed -i ' /zram_config/,+5d' /etc/rc.local
5673 echo " ZRAM removed and configuration deleted."
5774}
5875
5976install_prerequisites
6077
6178restore_zram
6279
80+ # Menu for user interaction
6381while true ; do
6482 echo " Choose an option:"
6583 echo " 1 - Create ZRAM"
You can’t perform that action at this time.
0 commit comments