How to enable zram as swap device in android linux kernel ? Is there any way create zram before init process ? kernelcmdline or kernel config.
As per zram.txt no default way.
Here is the answer (from Android build zram):
Enable zram in kernel config as built in module.
Add the below line in your fstab file
/dev/block/zram0 none swap defaults zramsize=size in bytes,swapprio=swap partition priority
zramsize is mandatory and indicates how much uncompressed memory you want the zram area to hold. Compression ratios in the 30-50% range are usually observed.
swapprio is optional and not needed if you don't have more than one swap area.
In init.rc add the following line:
swapon_all /fstab.X