Compcache userinit.sh tutorial for Cyanogen 367

Search This thread

AustinKnight45

Senior Member
Jan 11, 2009
704
21
Austin
c:\media /system/sd worked for me i have all my ringtones an do have look at me sound twice in notifications but that's it

o and dream them twice in ringtones
 
Last edited:

scrappyabs2

Senior Member
Feb 24, 2009
172
0
Repeat steps for after each flash?

Is it necessary to repeat these procedures every time you flash a new build?
 

glock30

Senior Member
Feb 3, 2009
135
4
So Cal
If you want to skip on messing with your media files, you can use the instructions in the earlier compcache thread. After a little homework I found other threads that have info on starting the auto swap by editing the a2sd script.
 

nurre

Senior Member
Jul 6, 2007
191
9
Good, it is working fine then. I believe that the 24mb is pre-compiled by Cyanogen and is not user configurable right now.

You'd be wrong, it uses 25% of memory by default, you can modify it on insmod.

# insmod ramzswap.ko disksize_kb=90000 for example.

I'd also recomend toying with swappiness, compcache would want very different swapiness compared to what you'd use with a slow block device.

//edit, I also dont see why you put the media information in there, as it has nothing to do with the topic of getting compcache working and could be a completely seperate script.

//edit, also worth mentioning that busybox'es swapon doesn't include priority, so having swap + compcache will use swap at the same time as using compcache, more than likely slowing you down. You need a different insmod or swapon command to use the swap as backup, and I can't remember the syntax off hand.
 
Last edited:

nurre

Senior Member
Jul 6, 2007
191
9
Does anyone happen to know the terminal commands for this?:confused:

They are in the very simple script, this is what I use atm:

Code:
#!/system/bin/sh

insmod /system/modules/lib/modules/2.6.29-cm/compcache/xvmalloc.ko;
insmod /system/modules/lib/modules/2.6.29-cm/compcache/ramzswap.ko disksize_kb=32000;
mknod /dev/ramzswap0 b 253 0;
echo 100 > /proc/sys/vm/swappiness;
swapon /dev/ramzswap0;

exit;
 

nicholasbithell

Senior Member
May 12, 2009
97
0
They are in the very simple script, this is what I use atm:

Code:
#!/system/bin/sh

insmod /system/modules/lib/modules/2.6.29-cm/compcache/xvmalloc.ko;
insmod /system/modules/lib/modules/2.6.29-cm/compcache/ramzswap.ko disksize_kb=32000;
mknod /dev/ramzswap0 b 253 0;
echo 100 > /proc/sys/vm/swappiness;
swapon /dev/ramzswap0;

exit;

I just dont understand how to go about getting this installed! ahhh I don't have ADB as I cannot get it working on my mac so I need console or terminal commands if that is at all possible! is any one working on a "ramzswap" app?
 

nurre

Senior Member
Jul 6, 2007
191
9
I just dont understand how to go about getting this installed! ahhh I don't have ADB as I cannot get it working on my mac so I need console or terminal commands if that is at all possible! is any one working on a "ramzswap" app?

Look in the first post.

adb push = copy file to someplace on the filesystem.
adb shell = a shell command

All you need to do is put the userinit.sh on your /system/sd (that's a extX partition), although you'd need to modify it (for example use mine) if you wanna skip the media part.
 

nurre

Senior Member
Jul 6, 2007
191
9
Oh, and another thing people dont seem to understand.

24mb compcache != 24mb swap.

Very very far from it. 24mb compcache uses 24mb memory to give you 24mb of compressed memory. On my phone I'm seeing 3:1 compression ratio atleast.

meaning 24mb compcache = ( 24mb * 3) - 24mb (the 24 mb memory it uses to give you this) = 48mb "free" memory.

Please note that using a 90mb compcache size might seem like a good idea based on this it isn't. Linux considers compcache swap, it will pull data out of swap and into active memory before using it. If it could use it directly it might be pretty awsome for this usage.
 

innerspace

Senior Member
Jun 23, 2009
392
7
@nurre

I think you may be right about busybox, not educated enough to be sure but:

This is my compcache info:

cat /proc/ramzswap
DiskSize: 24468 kB
NumReads: 11379
NumWrites: 11753
FailedReads: 0
FailedWrites: 0
InvalidIO: 0
PagesDiscard: 0
ZeroPages: 270
GoodCompress: 71 %
NoCompress: 7 %
PagesStored: 5846
PagesUsed: 2226
OrigDataSize: 23384 kB
ComprDataSize: 8464 kB
MemUsedTotal: 8904 kB

and yes, approx 3/1 compression ratio

and at the same time:

free
total used free shared buffers
Mem: 97876 96540 1336 0 284
Swap: 24464 21232 3232
Total: 122340 117772 4568

so I'm unsure what this means, is swap running before or after compcache, or are they running side by side? I'd think if compcache is knocking 24MB of data down to about *MB that I'd still have another 16MB of available ramzswap available, and that my linux-swap wouldn't be active.

Is this correct?
 

nurre

Senior Member
Jul 6, 2007
191
9
free will report wrong data for compcache, if you wanna know how much is going to a swapfile/compcache you can check /proc/swaps
 

innerspace

Senior Member
Jun 23, 2009
392
7
ok... so then...

so:

cat /proc/swaps
Filename Type Size Used Priority

/dev/ramzswap0 partition 24464 24436 -1

is basically saying only compcache is active, and I'm assuming if the following is correct:

cat /proc/ramzswap
DiskSize: 24468 kB
NumReads: 15556
NumWrites: 14136
FailedReads: 0
FailedWrites: 0
InvalidIO: 0
PagesDiscard: 0
ZeroPages: 290
GoodCompress: 70 %
NoCompress: 7 %
PagesStored: 5826
PagesUsed: 2274
OrigDataSize: 23304 kB
ComprDataSize: 8714 kB
MemUsedTotal: 9096 kB
#

The system has acquired the entire 24MB of compcache, compressing 23304kB of data down to 8714kB and using a total of 9096 kB of the 24Mb ramzswap file. And android isn't ever activating the backup swapfile at all, or at least not under an idle state.
 

nurre

Senior Member
Jul 6, 2007
191
9
Correct, your swap partition is not enabled, and no it's not deactivated on idle.
 

innerspace

Senior Member
Jun 23, 2009
392
7
and then that leads me to think...

that if the compcache ever got to the point where

cat /proc/ramzswap
DiskSize: 24468 kB

OrigDataSize: ~70000 kB
ComprDataSize: ~24000 kB
MemUsedTotal: ~24000+ kB

then android would start writing to the linux-swap partition (which I have configured to 24MB) until compcache no longer needed it.

correct?
 

Mikey

Retired Senior Moderator
Oct 10, 2007
6,262
1,743
Wheaton, Il
Google Pixel Fold
All you need to do is put the userinit.sh on your /system/sd (that's a extX partition), although you'd need to modify it (for example use mine) if you wanna skip the media part.

After seeing like 5 scripts for this, which one is yours??
I keep my media on fat32 partition :)

EDIT: I'm guessing this script?
Code:
#!/system/bin/sh

insmod /system/modules/lib/modules/2.6.29-cm/compcache/xvmalloc.ko;
insmod /system/modules/lib/modules/2.6.29-cm/compcache/ramzswap.ko disksize_kb=32000;
mknod /dev/ramzswap0 b 253 0;
echo 100 > /proc/sys/vm/swappiness;
swapon /dev/ramzswap0;

exit;
with these commands:
Code:
Rename it to userinit.sh
create a directory c:\userinit
copy userinit.sh to c:\userinit
open CMD prompt
adb push c:\userinit\userinit.sh /system/sd
adb shell chmod 755 /system/sd/userinit.sh (not sure if needed being safe)
adb shell reboot
 
Last edited:

jubeh

Senior Member
Mar 15, 2009
1,264
20
what i wonder, though, is where do i put userinit.sh if i don't use apps2sd or a swap partition or any of the sort (i like being able to hot swap my sd card)
I'm guessing /etc, am i right?
 

Saiboogu

Senior Member
Apr 28, 2009
305
5
Frostburg MD
what i wonder, though, is where do i put userinit.sh if i don't use apps2sd or a swap partition or any of the sort (i like being able to hot swap my sd card)
I'm guessing /etc, am i right?

I've wondered this too, since I have another rooted G1 in the house (non A2SD). I believe this would work --

I haven't tested this, just a theory
Code:
su
mount -o remount,rw /dev/block/mtdblock3 /system
cd /system
mkdir sd
copy /sdcard/userinit.sh sd/userinit.sh
chmod 755 sd/userinit.sh

And since you don't have extra partitions on your card, want to get rid of all the other junk in the standard userinit script floating around.. so just try this:

Code:
#!/system/bin/sh

insmod /system/modules/lib/modules/2.6.29-cm/compcache/xvmalloc.ko;
insmod /system/modules/lib/modules/2.6.29-cm/compcache/ramzswap.ko disksize_kb=32000;
mknod /dev/ramzswap0 b 253 0;
echo 100 > /proc/sys/vm/swappiness;
swapon /dev/ramzswap0;

exit;
 

bkmo

Senior Member
Jun 25, 2008
1,890
226
10° 5' 59" North, 84° 16' 84" West
After seeing like 5 scripts for this, which one is yours??
I keep my media on fat32 partition :)

EDIT: I'm guessing this script?
Code:
#!/system/bin/sh

insmod /system/modules/lib/modules/2.6.29-cm/compcache/xvmalloc.ko;
insmod /system/modules/lib/modules/2.6.29-cm/compcache/ramzswap.ko disksize_kb=32000;
mknod /dev/ramzswap0 b 253 0;
echo 100 > /proc/sys/vm/swappiness;
swapon /dev/ramzswap0;

exit;
with these commands:
Code:
Rename it to userinit.sh
create a directory c:\userinit
copy userinit.sh to c:\userinit
open CMD prompt
adb push c:\userinit\userinit.sh /system/sd
adb shell chmod 755 /system/sd/userinit.sh (not sure if needed being safe)
adb shell reboot

I edited the post and replaced the script with the one you are quoting. The script will not do anything to audio files now, you will need to have them on your card.
 

bkmo

Senior Member
Jun 25, 2008
1,890
226
10° 5' 59" North, 84° 16' 84" West
I've wondered this too, since I have another rooted G1 in the house (non A2SD). I believe this would work --

I haven't tested this, just a theory
Code:
su
mount -o remount,rw /dev/block/mtdblock3 /system
cd /system
mkdir sd
copy /sdcard/userinit.sh sd/userinit.sh
chmod 755 sd/userinit.sh

And since you don't have extra partitions on your card, want to get rid of all the other junk in the standard userinit script floating around.. so just try this:

Code:
#!/system/bin/sh

insmod /system/modules/lib/modules/2.6.29-cm/compcache/xvmalloc.ko;
insmod /system/modules/lib/modules/2.6.29-cm/compcache/ramzswap.ko disksize_kb=32000;
mknod /dev/ramzswap0 b 253 0;
echo 100 > /proc/sys/vm/swappiness;
swapon /dev/ramzswap0;

exit;

I was thinking of this myself while dozing of this AM. "What if you don't want aps2sd" because if you add the partition, the aps2sd script will move your apps there. This looks like it will work just fine for aps2sd. I also modified the post and userinit.sh script removing any of the move audio stuff.
Edit: the only con i can think of in doing it this way is that you will have to redo it after every update. System gets formatted during an update.
 
Last edited:

MortICi

Senior Member
Jun 9, 2009
191
0
Im not sure if you want to use 100 for the swapiness...

But ill test it out.

This works on jacHEROski as well 1.4C, just have to copy two of the modules over to the system.
 
Last edited: