SmartPack-Kernel-Manager icon indicating copy to clipboard operation
SmartPack-Kernel-Manager copied to clipboard

Zram algorithm switch not work apply on boot

Open mhtvsSFrpHdE opened this issue 4 years ago • 4 comments

I can switch the option from app interface, from lzo to lz4, but when reboot, zram algorithm keeps use lzo.

I try echo 'lz4' > /sys/block/zram0/comp_algoritjm, no error, but cat it after echo, it remains [lzo] lz4.

However, if I do this in app interface, it will successfully change to lz4 and cat as lzo [lz4].

Turn on Shell mode apply on boot did not solve this. I think there are strange difference between UI apply and boot apply.

Using Google Play 13.5 version, Android 10 AOSP.

mhtvsSFrpHdE avatar Sep 25 '20 05:09 mhtvsSFrpHdE

Change zram size and apply on boot will work, just the one zram algorithm.

Plus swappiness will not apply on boot.

mhtvsSFrpHdE avatar Sep 25 '20 05:09 mhtvsSFrpHdE

Did some internet search and got these

# Remove swap first
swapoff /dev/block/zram0

# Request reset zram0
echo 1 > /sys/block/zram0/reset

# Apply lz4
echo lz4 > /sys/block/zram0/comp_algorithm

# Write size again after reset
echo 1073741824 > /sys/block/zram0/disksize

# Make swap online in final
mkswap /dev/block/zram0
swapon /dev/block/zram0

The thing is you need to wait the zram0 fully swapoff, after that to request a reset.

Once reset, we can apply lz4.

Then the problem is a reset would cause everything back to the system factory settings. I've checked your script and found your reset is after echo lz4, so system will not response echo lz4.

Before mkswap and swapon, need to set size. If no size provided, mkswap will fail to run. So if user not changing zram size you need to record that value and write back, or it will not auto use system factory settings, just fails.

I think there's a lot logic to process them correctly, good luck to you! Perhaps you could let people to use hand write sh script to do this. And mark as won't fix, then reference them a tutorial or to this issue.

mhtvsSFrpHdE avatar Sep 25 '20 06:09 mhtvsSFrpHdE

Did some internet search and got these

# Remove swap first
swapoff /dev/block/zram0

# Request reset zram0
echo 1 > /sys/block/zram0/reset

# Apply lz4
echo lz4 > /sys/block/zram0/comp_algorithm

# Write size again after reset
echo 1073741824 > /sys/block/zram0/disksize

# Make swap online in final
mkswap /dev/block/zram0
swapon /dev/block/zram0

The thing is you need to wait the zram0 fully swapoff, after that to request a reset.

Once reset, we can apply lz4.

Then the problem is a reset would cause everything back to the system factory settings. I've checked your script and found your reset is after echo lz4, so system will not response echo lz4.

Before mkswap and swapon, need to set size. If no size provided, mkswap will fail to run. So if user not changing zram size you need to record that value and write back, or it will not auto use system factory settings, just fails.

I think there's a lot logic to process them correctly, good luck to you! Perhaps you could let people to use hand write sh script to do this. And mark as won't fix, then reference them a tutorial or to this issue.

Thanks for raising the issue and providing details. As I understand, changing zRAM algo requires disksize to be set to 0. It will be done when applying from app UI. However, this strategy was not working while applying settings on boot. I have to seriously look on it.

sunilpaulmathew avatar Sep 25 '20 06:09 sunilpaulmathew

Screenshot_20200925-145358 If these command are executed from top to bottom and one by one, you've got the idea. The echo lz4 was the first command being executed.

Most Android device already have a zram instance running by default after boot, so system will ignore this request.

Move it after reset command will fix the problem... But you need to find a value to restore zram size, in case if user haven't touch the size drag bar but only changing algorithm.

Here I think rather than a drag bar, a text input will more accurate as a addition suggest.

mhtvsSFrpHdE avatar Sep 25 '20 07:09 mhtvsSFrpHdE