• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Compcache userinit.sh tutorial for Cyanogen 367

Search This thread

h.nocturna

Senior Member
Oct 8, 2008
1,116
110
I would like to know .... I have one ext3 partition only for running app2sd. Do I need to create another ext partition for running swap partition??? Previously I just use Swapper to run a file swap ....
Yes, you need to use the linux-swap partition to use the backing swap, but as overpower indicated, you need to write the command as backing_swap first if you want to use it. It should look like:

ramzswap.ko backing_swap=/dev/block/mmcblk0p3 memlimit=24000;
 
May 9, 2008
36
0
Yes, you need to use the linux-swap partition to use the backing swap, but as overpower indicated, you need to write the command as backing_swap first if you want to use it. It should look like:

ramzswap.ko backing_swap=/dev/block/mmcblk0p3 memlimit=24000;
Cool ... Thanks!

One stupid question - how can I create a linux swap partition on my phone/SD card? In Paragon Partition Manager I only find ext2 and ext3 :(
 

h.nocturna

Senior Member
Oct 8, 2008
1,116
110
Cool ... Thanks!

One stupid question - how can I create a linux swap partition on my phone/SD card? In Paragon Partition Manager I only find ext2 and ext3 :(
If you flash the new cyanogen's recovery image, there's a tutorial to do it from the command line, don't worry, its realllly easy. Just look under the JACHero thread under developers thread and the instructions to partition each partition is there. :D Good luck.
 
May 9, 2008
36
0
If you flash the new cyanogen's recovery image, there's a tutorial to do it from the command line, don't worry, its realllly easy. Just look under the JACHero thread under developers thread and the instructions to partition each partition is there. :D Good luck.
Thanks a lot!

I check Paragon again and found that actually I oversaw the "linux swap" option! I think I will go ahead with Paragon because I am afraid that command line partitioning will format my existing partition (which saves LOTS of application data and any restoration is a VERY PAINFUL process T.T .....)
 
May 9, 2008
36
0
Um .... finally have some clues. I use "parted" and "print" and check that I have the swap partition available, but in /etc/fstab no mmcblkop3 is there. Only mmcblkop1 and mmcblkop2 ....

What is the line I am supposed to add to make my swap partition active?
 

tman7510

Senior Member
Jul 28, 2009
233
4
Virginia
The free command gives all 000 for swap

I followed the instructions and copied the userinit.sh to /system/sd. chmodded the file to 755 but after checking status I still have all 0 0 0 for swap. So I followed these instructions

mkswap /dev/block/mmcblk0p3

4. Enable the swap partition

swapon /dev/block/mmcblk0p3

5. Change the swappiness. I'm using 20

echo 20 > /proc/sys/vm/swappiness

6. Run 'free' to see that its enabled
and I get non zero results but 0 in the used. So I run sh /system/sd/userinit.sh and I get "Disabling swap /dev/block/mmcblk0p3" and have all zeros in swap again. cat /proc/swaps give me nothing and cat /proc/ramzswap tells me no such file. I'm using jasherai's script and I'm running the latest cyanogen stable build 3.6.8.1. Any ideas on what I am doing wrong
 

ttabbal

Senior Member
Jul 1, 2009
2,076
723
Samsung Galaxy S21 Ultra
I followed the instructions and copied the userinit.sh to /system/sd. chmodded the file to 755 but after checking status I still have all 0 0 0 for swap. So I followed these instructions

mkswap /dev/block/mmcblk0p3

4. Enable the swap partition

swapon /dev/block/mmcblk0p3

5. Change the swappiness. I'm using 20

echo 20 > /proc/sys/vm/swappiness

6. Run 'free' to see that its enabled
and I get non zero results but 0 in the used. So I run sh /system/sd/userinit.sh and I get "Disabling swap /dev/block/mmcblk0p3" and have all zeros in swap again. cat /proc/swaps give me nothing and cat /proc/ramzswap tells me no such file. I'm using jasherai's script and I'm running the latest cyanogen stable build 3.6.8.1. Any ideas on what I am doing wrong

Ok, so you can use a standard swap partition. What userinit.sh are you running? I need a copy or a link to the one you downloaded. It sounds to me like you aren't loading the compcache module or it's failing for some reason.

It's normal for swaps that have just been added to have zero used. You have to use the computer for a while for it to decide to swap things. Particularly with 20 swappiness.
 

ttabbal

Senior Member
Jul 1, 2009
2,076
723
Samsung Galaxy S21 Ultra
Do i need to add

to my userinit.sh or just adding

in the right place will enable it.

If I dont need to run the top 2 command in the script then do i need to run them atleast once or compcache will enable the swap automagically.


OK, just try this userinit.sh. Rename to remove .txt before using it. You don't need to replace your existing script, just copy it to /system/sd (rename it if you don't want to replace your existing script, or backup the one you have).

Code:
mount -o remount,rw /system
(copy the file you downloaded from this post to /system/sd/userinit.sh You can also use adb push from your computer.) 
cd /system/sd
chmod 755 userinit.sh
rm -r userinit.d
./userinit.sh 
touch /system/sd/userinit.d/etc/use_compcache
touch /system/sd/userinit.d/etc/use_compcache_backing
./userinit.sh start
./userinit.sh status

Cut and paste any errors. If you have it, you can use adb shell to make it easy to copy and paste. I use ssh, but you have to install that manually as well, so adb is easier.

This is working for me on CM 3.9.1 and I've used it since about CM 3.6.8. The commands above will set up compcache with a backing swap. You will only see one swap partition in /proc/swaps. That's normal.

Note that you only need to do mkswap once unless you change the partitions for some reason. It's like formatting your ext drive. It doesn't need to be done in your scripts or anything like that.
 

Attachments

  • userinit.sh.txt
    5.8 KB · Views: 65

tman7510

Senior Member
Jul 28, 2009
233
4
Virginia
Ok, so you can use a standard swap partition. What userinit.sh are you running? I need a copy or a link to the one you downloaded. It sounds to me like you aren't loading the compcache module or it's failing for some reason.

It's normal for swaps that have just been added to have zero used. You have to use the computer for a while for it to decide to swap things. Particularly with 20 swappiness.
I solved my problem by reading the script. You can find the script I'm using at the bottom of page 21
 
Last edited:

My_Name_Is_Neo

Senior Member
Oct 20, 2008
85
2
OK, just try this userinit.sh. Rename to remove .txt before using it. You don't need to replace your existing script, just copy it to /system/sd (rename it if you don't want to replace your existing script, or backup the one you have).

Code:
mount -o remount,rw /system
(copy the file you downloaded from this post to /system/sd/userinit.sh You can also use adb push from your computer.) 
cd /system/sd
chmod 755 userinit.sh
rm -r userinit.d
./userinit.sh 
touch /system/sd/userinit.d/etc/use_compcache
touch /system/sd/userinit.d/etc/use_compcache_backing
./userinit.sh start
./userinit.sh status

Cut and paste any errors. If you have it, you can use adb shell to make it easy to copy and paste. I use ssh, but you have to install that manually as well, so adb is easier.

This is working for me on CM 3.9.1 and I've used it since about CM 3.6.8. The commands above will set up compcache with a backing swap. You will only see one swap partition in /proc/swaps. That's normal.

Note that you only need to do mkswap once unless you change the partitions for some reason. It's like formatting your ext drive. It doesn't need to be done in your scripts or anything like that.

Ok.. i understood you script. rather than creating a conf file which i saw a few pages back you create files with appropriate names to know what to do in the script.
My question is what is the Media symlinking function doing. i know it is moving media to sd & symlinking, but why? To create space for compcache disk image? If i've aready moved my apps & dalvik cache to sd, then why is there a need to move more stuff out?
Oh is it because it needs more space on system partition and not data partition. if thats the case then can we tell the compcache to create its ramdisk in data partition instead.
did i make nay sense :p
 

overpower

Senior Member
Sep 15, 2008
60
0
Ok.. i understood you script. rather than creating a conf file which i saw a few pages back you create files with appropriate names to know what to do in the script.
My question is what is the Media symlinking function doing. i know it is moving media to sd & symlinking, but why? To create space for compcache disk image? If i've aready moved my apps & dalvik cache to sd, then why is there a need to move more stuff out?
Oh is it because it needs more space on system partition and not data partition. if thats the case then can we tell the compcache to create its ramdisk in data partition instead.
did i make nay sense :p

The medialink function removes the standard /system/media and replaces it with the /system/sd/media. The purpose of that is mod authors may not populate a full ringtone/notification/ui sound directly, and some people prefer to use what they've collected on their ext3 partition.

It's not a space issue but a settings saving issue.

It was included because it was in the first userinit.sh scripts and some people found it useful. Since it was moved to an uncalled function, it doesn't affect anyone who doesn't know about it.
 
May 9, 2008
36
0
using Rom 3.6.8.1 but compcache fails to start

I flash the 3.6.8.1 rom (without any themes) and followed the procedures to enable compcache but failed ....

I try typing the commands in userinit.sh line by one and I got an error after typing swapon - "Cannot stat /dev/ramzswap0" ....

What happen???? Anything I missed???
 

wesbalmer

Senior Member
Oct 22, 2008
426
34
Los Angeles, CA
www.rawc.net
Just got a replacement G1 after my Touchscreen died on the first one. Never had a problem using compcache before, but now for some reason I cannot get it to work. I'm pretty sure I've done this all right. I was reading through the userinit, and I can't seem to cd or cat the modules that the script calls for. I cann't even pull them, I get the same 'no such file or directory' error. Any ideas?
Running 3.9.2, 1.4 recovery, 1.33.2005 SPL

Correctly partitioned.

I wonder if someone who comes from a previous build has these modules, I started freshly new today, barely got my replacement. And flashed straight to 3.9.2 after rooting