this does not work for me even doing this before:
In fact, the result is the following:
[root@sfos ~]# zramctl -s $((2*1024*1024*1024)) /dev/zram0
zramctl: /dev/zram0: failed to reset: Device or resource busy
[root@sfos ~]# echo 1 > /proc/sys/vm/drop_caches; swapoff -av; free
swapoff /dev/zram0
total used free shared buff/cache available
Mem: 3643472 1100024 2353380 12844 190068 2485908
Swap: 1048572 289588 758984
In particular this is the error:
[root@sfos ~]# echo 1 > /proc/sys/vm/drop_caches; swapoff /dev/block/zram0
swapoff: /dev/block/zram0: swapoff failed: Interrupted system call
and checking with dmesg -Hw
there is constant flux of these messages:
[ +0.000071] Freezing of tasks aborted after 0.030 seconds
[ +0.000083] OOM killer enabled.
[ +0.000002] Restarting tasks ... done.
[ +0.015447] PM: PM: suspend exit 2023-06-29 09:30:30.916913689 UTC
[ +0.000004] PM: suspend exit
[ +0.004559] binder: 2749:2749 transaction failed 29189/-22, size 32-0 line 3096
[ +0.045540] ## mmc1: mmc_gpio_set_uim2_en: gpio=101 value=1
[ +0.070757] PM: PM: suspend entry 2023-06-29 09:30:31.037763337 UTC
[ +0.000016] PM: suspend entry (deep)
[ +0.000009] PM: Syncing filesystems ... done.
[ +0.008866] Freezing user space processes ...
[ +0.035409] PM: Wakeup pending, aborting suspend
UPDATE #1
I think that, it was this line to create the problem:
echo 1 > /proc/sys/vm/drop_caches
which starts a drop that will keep longer than supposed to be and interfere with swapoff
command which probably does not need it because it should have its own internal specific calls about cache dropping.
UPDATE #2
Anyway chianging the size of the swap size at running system time does not seem a immediate procedure (not so much, at least). In fact, this functions fails in this aim even when succeed for each command:
zram_set_size() {
declare -i mb=${1:-1024}
swapusage() { free -m | grep -i swap | tr -s ' ' | sed "s,0 0 0,off,"; }
swapusage; swapoff -v /dev/zram0; swapusage
echo
echo "The zram size at boot is set in $(ls -1 /vendor/etc/fstab.pdx20?):"
sed -i "s|\(^/dev/block/zram0.*size\)=[0-9]*,max|\\1="$((mb*1024*1024))",max|" \
/vendor/etc/fstab.pdx20?
grep zram /vendor/etc/fstab.pdx20? | tr -s ' '
echo
swapusage; swapon -v /dev/zram0; swapusage
}