-
-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zram swap is not enabled after boot #6511
Comments
Persitant workaround on reboot:
|
Hmm, looks like the udev rule does not work in your case. Can you check the two files: cat /etc/sysctl.d/98-dietpi-zram-swap.conf
cat /etc/udev/rules.d/98-dietpi-zram-swap.rules The first is to enforce the kernel module to be loaded, hence this should make the Little note on your workaround, until we have this fixed: You may want to add Is udev reporting any errors? journalctl -u systemd-udevd |
Hi MichaIng,
You're right, errors are present on udev:
Regards |
In addition, I have errors too on a DietPi v8.19.1 PI3B (Debian 11.7) with zram swap enabled:
but zram swap is active:
|
Ah sorry, this is the first file I mean (wrong copy&paste): cat /etc/modules-load.d/dietpi-zram-swap.conf However, the issue can be seen in udev logs.
The exit code 1 seems to be used for any error, so without the exact output, not sure what is wrong. But I guess the The root@VM-Bookworm:~# /sbin/swapon test; echo $?
swapon: cannot open test: No such file or directory
255 Hmm, that everything is executed twice makes me think that this is the problem: Two concurrent attempts to setup the swap space, breaking each other. |
Bingo, assuring that it runs once only, by checking that the disk size is still zero, solves the double execution. But Now I see the actual issue: systemd/systemd#23054 So here is how to solve the issue: mkdir /etc/systemd/system/systemd-udevd.service.d
echo -e '[Service]\nSystemCallFilter=@swap' > /etc/systemd/system/systemd-udevd.service.d/dietpi-zram.conf And the more cosmetic change to avoid the doubled execution: echo 'SUBSYSTEM=="block", KERNEL=="zram0", ACTION=="add", ATTR{disksize}=="0", ATTR{disksize}="256M", RUN+="/bin/chmod 0600 /dev/zram0", RUN+="/sbin/mkswap /dev/zram0", RUN+="/sbin/swapon /dev/zram0"' > /etc/udev/rules.d/98-dietpi-zram-swap.rules |
- DietPi-Set_swapfile | Resolved an issue on Bookworm systems where zram swap space was not enabled automatically on boot due to missing syscall permissions. Many thanks to @magicfoxt-magicfox for reporting this issue: #6511
Fixed with: 55019bb |
Thanks for your job ;) Note the sysctl swappiness is not correcty set and later forced to 1 in /etc/sysctl.d/dietpi.conf, I propose this patch:
|
You are right about the swappiness 😮. We create a config to set it to 50, but it is alphanumerically ordered before the default config file, so is overridden with the default 1. This file needs to be renamed to However, a swappiness of 1 is not "false", but it makes sense to make more/earlier use of a zram swap compared to a disk swap file. EDIT: I should have read more carefully. Indeed the |
Required Information
Linux DietPi0 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux
Additional Information (if applicable)
Steps to reproduce
Expected behaviour
An enabled zram swap
Actual behaviour
zram swap is not enabled after each reboot
free
total used free shared buff/cache available
Mem: 488696 40260 373288 1640 87948 448436
Swap: 0 0 0
Extra details
journalctl -xe
...
Jul 29 18:08:53 DietPi0 systemd[1]: Started systemd-udevd.service - Rule-based Manager for Device Events and Files.
Subject: A start job for unit systemd-udevd.service has finished successfully
Defined-By: systemd
Support: https://www.debian.org/support
A start job for unit systemd-udevd.service has finished successfully.
The job identifier is 11.
Jul 29 18:08:54 DietPi0 kernel: zram0: detected capacity change from 0 to 487424
Jul 29 18:08:54 DietPi0 (udev-worker)[135]: zram0: Process 'chmod 0600 /dev/zram0' failed with exit code 1.
Jul 29 18:08:54 DietPi0 (udev-worker)[135]: zram0: Process '/sbin/swapon /dev/zram0' failed with exit code 255.
Jul 29 18:08:54 DietPi0 (udev-worker)[136]: zram0: /etc/udev/rules.d/98-dietpi-zram-swap.rules:1 Failed to write ATTR{/sys/devices/virtual/block/zram0/disksize}, ignoring: Device or resource busy
Jul 29 18:08:54 DietPi0 kernel: zram: Cannot change disksize for initialized device
Jul 29 18:08:54 DietPi0 (udev-worker)[136]: zram0: Process 'chmod 0600 /dev/zram0' failed with exit code 1.
Jul 29 18:08:55 DietPi0 (udev-worker)[136]: zram0: Process '/sbin/swapon /dev/zram0' failed with exit code 255.
Workaround
/boot/dietpi/func/dietpi-set_swapfile 1 zram
dietpi-set_swapfile
─────────────────────────────────────────────────────
Mode: Applying 1 zram
[ INFO ] DietPi-Set_swapfile | Disabling and deleting all existing swap files
[ OK ] DietPi-Set_swapfile | swapoff -a
removed '/etc/modules-load.d/dietpi-zram-swap.conf'
removed '/etc/udev/rules.d/98-dietpi-zram-swap.rules'
[ OK ] DietPi-Set_swapfile | Generating new swap space
[ INFO ] DietPi-Set_swapfile | Size = 238 MiB
[ INFO ] DietPi-Set_swapfile | Path = /dev/zram0
[ OK ] DietPi-Set_swapfile | eval echo 1 > /sys/block/zram0/reset
[ OK ] DietPi-Set_swapfile | eval echo '238M' > /sys/block/zram0/disksize
[ OK ] DietPi-Set_swapfile | chmod 0600 /dev/zram0
[ OK ] DietPi-Set_swapfile | mkswap /dev/zram0
[ OK ] DietPi-Set_swapfile | swapon /dev/zram0
[ OK ] DietPi-Set_swapfile | eval echo 'zram' > /etc/modules-load.d/dietpi-zram-swap.conf
[ OK ] DietPi-Set_swapfile | eval echo 'SUBSYSTEM=="block", KERNEL=="zram0", ACTION=="add", ATTR{disksize}="238M", RUN+="chmod 0600 /dev/zram0", RUN+="/sbin/mkswap /dev/zram0", RUN+="/sbin/swapon /dev/zram0"' > /etc/udev/rules.d/98-dietpi-zram-swap.rules
[ OK ] DietPi-Set_swapfile | eval echo 'swappiness=50' > /etc/sysctl.d/98-dietpi-zram-swap.conf
[ OK ] DietPi-Set_swapfile | Desired setting in /boot/dietpi.txt was already set: AUTO_SETUP_SWAPFILE_SIZE=238
[ OK ] DietPi-Set_swapfile | Desired setting in /boot/dietpi.txt was already set: AUTO_SETUP_SWAPFILE_LOCATION=zram
[ INFO ] DietPi-Set_swapfile | Setting /tmp tmpfs size: 357 MiB
[ OK ] DietPi-Set_swapfile | Desired setting in /etc/fstab was already set: tmpfs /tmp tmpfs size=357M,noatime,lazytime,nodev,nosuid,mode=1777
[ OK ] DietPi-Set_swapfile | systemctl daemon-reload
[ OK ] DietPi-Set_swapfile | mount -o remount /tmp
free
total used free shared buff/cache available
Mem: 488696 39508 373932 1640 88056 449188
Swap: 243708 0 243708
The text was updated successfully, but these errors were encountered: