I tried enabling ZRam on my debian 12.8 KDE 64 bits desktop computer (Dell Otiplex op3020 CFF). Installation was succesful. I cooul see zramswap service status as active. But on reboot, I see a message - [FAILED] - Failed to start zramswap.service - Linux zramswap setup. I am not sure what is causing this. On login, I tried to check the service status. Here is the output -
Code: Select all
ganeshp@aga-op3020:~$ systemctl status zramswap.service
× zramswap.service - Linux zramswap setup
Loaded: loaded (/lib/systemd/system/zramswap.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sun 2024-12-08 11:28:14 IST; 5min ago
Docs: man:zramswap(8)
Process: 866 ExecStart=/usr/sbin/zramswap start (code=exited, status=1/FAILURE)
Main PID: 866 (code=exited, status=1/FAILURE)
CPU: 9ms
Dec 08 11:28:14 aga-op3020 systemd[1]: Starting zramswap.service - Linux zramswap setup...
Dec 08 11:28:14 aga-op3020 root[869]: Starting Zram
Dec 08 11:28:14 aga-op3020 zramswap[869]: <13>Dec 8 11:28:14 root: Starting Zram
Dec 08 11:28:14 aga-op3020 zramswap[866]: /usr/sbin/zramswap: line 53: echo: write error: Device or resource busy
Dec 08 11:28:14 aga-op3020 root[896]: Error: setting compression algo to zstd
Dec 08 11:28:14 aga-op3020 zramswap[896]: <13>Dec 8 11:28:14 root: Error: setting compression algo to zstd
Dec 08 11:28:14 aga-op3020 systemd[1]: zramswap.service: Main process exited, code=exited, status=1/FAILURE
Dec 08 11:28:14 aga-op3020 systemd[1]: zramswap.service: Failed with result 'exit-code'.
Dec 08 11:28:14 aga-op3020 systemd[1]: Failed to start zramswap.service - Linux zramswap setup.
ganeshp@aga-op3020:~$ sudo systemctl restart zramswap.service
Job for zramswap.service failed because the control process exited with error code.
See "systemctl status zramswap.service" and "journalctl -xeu zramswap.service" for details.
ganeshp@aga-op3020:~$ sudo journalctl -xeu zramswap.service
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit zramswap.service has finished with a failure.
░░
░░ The job identifier is 2215 and the job result is failed.
Dec 08 11:35:03 aga-op3020 systemd[1]: Starting zramswap.service - Linux zramswap setup...
░░ Subject: A start job for unit zramswap.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit zramswap.service has begun execution.
░░
░░ The job identifier is 2344.
Dec 08 11:35:03 aga-op3020 zramswap[2954]: /usr/sbin/zramswap: line 53: echo: write error: Device or resource busy
Dec 08 11:35:03 aga-op3020 root[2958]: Error: setting compression algo to zstd
Dec 08 11:35:03 aga-op3020 zramswap[2958]: <13>Dec 8 11:35:03 root: Error: setting compression algo to zstd
Dec 08 11:35:03 aga-op3020 systemd[1]: zramswap.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ An ExecStart= process belonging to unit zramswap.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Dec 08 11:35:03 aga-op3020 systemd[1]: zramswap.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit zramswap.service has entered the 'failed' state with result 'exit-code'.
Dec 08 11:35:03 aga-op3020 systemd[1]: Failed to start zramswap.service - Linux zramswap setup.
░░ Subject: A start job for unit zramswap.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit zramswap.service has finished with a failure.
░░
░░ The job identifier is 2344 and the job result is failed.
I had refered to documentation available at https://wiki.debian.org/ZRam and some other online material to configure ZRam. Here is the bash script I had used to install and configure -
Code: Select all
#!/bin/bash
function enable_zram_swap()
{
# for more details on the below please visit url https://wiki.debian.org/ZRam
local myResponse
printf "\n\nDo you want to install and enable ZRam on your computer? If yes, please disable any other forms of swap and rerun this option. (y/n) : "
read -r -n 1 myResponse
# validate user input
if [[ "$myResponse" != 'y' ]]
then
cancel_function_message
return 1
fi
printf "\n\nAttempting to install zram-tools.\n\n"
apt update
apt install zram-tools -y
printf "\n\nEnter swappiness for ZRam swap. Default value is 60 : "
read -r -n 3 myResponse
# if invalid valueentered, then assign 60 default value
check_valid_number "$myResponse" || myResponse=60
# configure zram
printf "ALGO=zstd\nPERCENT=%s\n" "$myResponse" | tee -a /etc/default/zramswap
systemctl restart zramswap || return
# refer to Debian documentation for details.
printf "\n\nAttempting to install insserv.\n\n"
apt install insserv -y
insserv zramswap
# install systemd-zram-generator
printf "\n\nAttempting to install systemd-zram-generator.\n\n"
apt install systemd-zram-generator -y
# reload the deamon
systemctl daemon-reload
systemctl start /dev/zram0 || return
systemctl enable --now zramswap
# display the zram status
printf "\n\nZRam enabled successfully. Showing the ZRam status.\n\n"
zramctl || return
printf "\n showing output of lsblk.\n"
lsblk
printf "\n\n"
return 0
}
enable_zram_swap
Code: Select all
ganeshp@aga-op3020:~$ sudo insserv zramswap
insserv: zramswap: No such file or directory
ganeshp@aga-op3020:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 953.9G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 1.9G 0 part /boot
└─sda3 8:3 0 951.5G 0 part
└─sda3_crypt 253:0 0 951.5G 0 crypt
├─aga--vg-lv--home 253:1 0 107.9G 0 lvm /home
├─aga--vg-lv--root 253:2 0 139.7G 0 lvm /
└─aga--vg-lv--data 253:3 0 703.8G 0 lvm /data
zram0 252:0 0 4G 0 disk [SWAP]
ganeshp@aga-op3020:~$ sudo swapon --show
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 4G 0B 100
Regards
Ganesh