SmartPack / SmartPack-Kernel-Manager

Source code of SmartPack-Kernel Manager, the Ultimate Tool to Manage your Kernel
https://play.google.com/store/apps/details?id=com.smartpack.kernelmanager.pro
GNU General Public License v3.0
639 stars 71 forks source link

Zram algorithm switch not work apply on boot #80

Open mhtvsSFrpHdE opened 3 years ago

mhtvsSFrpHdE commented 3 years ago

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 commented 3 years ago

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

Plus swappiness will not apply on boot.

mhtvsSFrpHdE commented 3 years ago

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.

sunilpaulmathew commented 3 years ago

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.

mhtvsSFrpHdE commented 3 years ago

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.