Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,734,168 Members 50,667 Now Online
XDA Developers Android and Mobile Development Forum

[MOD]user configurable userinit.sh V0.1.5.3 for CM. [UPDATED 9/05]

Tip us?
 
huanyu
Old
(Last edited by huanyu; 7th September 2009 at 02:47 AM.)
#1  
Senior Member - OP
Thanks Meter 13
Posts: 124
Join Date: Apr 2009
Default [MOD]user configurable userinit.sh V0.1.5.3 for CM. [UPDATED 9/05]

The purpose of this script to allow user to define their own set of configuration in a easier way. You can play with the parameters (user.conf)
to find out what suits you best.
Please check the third post for change log and rom compatibility list
Code:
  echo "Usage:"
  echo "/system/sd/userinit.sh [-s|-c config.file|-i]"
  echo 
  echo "Default:"
  echo "Sets system configuration based on the paratermers"
  echo "that listed in /system/sd/user.conf"
  echo 
  echo "  -s: check configuration status and cross" 
  echo "      verifiction with user configurations "
  echo "  -c config.file: use user parameters that defined"
  echo "                  in config.file "
  echo "  -i: Current system settings and info "
Install using ADB:
Code:
adb push userinit.sh /system/sd
adb shell chmod 755 /system/sd/userinit.sh
adb push user.conf /system/sd
adb shell chmod 755 /system/sd/user.conf
adb shell reboot
Install using terminal emulator
download the file and unzip it to your sdcard
Code:
su
mount -o remount,rw /dev/block/mtdblock3 /system
cp /sdcard/userinit.sh /system/sd
cp /sdcard/user.conf /system/sd
chmod 755 /system/sd/user.conf
chmod 755 /system/sd/userinit.sh
reboot
testing via ADB
Code:
adb shell sh /system/sd/userinit.sh -s
testing via terminal emulator
Code:
su
sh /system/sd/userinit.sh -s

Expected output for compcache 0.5
Code:
=== CompCache status ===
CompCache version 0.5
Compcache enabled
CompCache: DiskSize 32768(system) 32768(user)
CompCache: cc_swappiness - 30(system) 30(user)

=== CompCache status output ===
DiskSize:          32768 kB
NumReads:              1
NumWrites:            11
FailedReads:           0
FailedWrites:          0
InvalidIO:             0
PagesDiscard:          0
ZeroPages:             1
GoodCompress:         70 %
NoCompress:            0 %
PagesStored:          10
PagesUsed:             4
OrigDataSize:         40 kB
ComprDataSize:        10 kB
MemUsedTotal:         16 kB
the (system) beside the number means the value is gather from system and user means from user.conf

example out for compcache 0.6+
Code:
=== CompCache status ===
CompCache version 0.6+
Compcache enabled
CompCache: DiskSize 32768(system) 32768(user)
CompCache: cc_swappiness - 30(system) 30(user)

=== CompCache status output ===
DiskSize:          32768 kB
NumReads:              1
NumWrites:             3
FailedReads:           0
FailedWrites:          0
InvalidIO:             0
PagesDiscard:          0
ZeroPages:             0
GoodCompress:        100 %
NoCompress:            0 %
PagesStored:           3
PagesUsed:             1
OrigDataSize:         12 kB
ComprDataSize:         0 kB
MemUsedTotal:          4 kB
This is the default user.conf. By default, the 32MB of compcache is enabled.
Code:
# General parameters
general{
apps2sd=0	# this is useless here, require a modified a2sd script
CONF_FILE="/system/sd/user.conf"	#location of user.conf
media2sd=1	# moves the medias to sd if /system/sd/media exists
permission_fix=0 # perform permission fix at start up (this parameter sets to 0 after script is executed)
odex_auto=0	# perform auto create or del odex for applications installed or removed within 3 days
odex_apk=0	# creates odex for apk that does not have odex yet (this parameter sets to 0 after script is executed)
odex_all=0	# creates odexes for all apks (this parameter sets to 0 after script is executed)
}

#compcache related parameters
compcache{
compcache_en=1	# enable(1) or disable(0) compcache
cc_disksize=32	# Ram swap disksize - any number between 1 to 95 should work; default is 1/4 of the RAM (24)
cc_memlimit=16	# Limit the memory usage for backing swap (cc .5x known issue-defaults to 15% of total RAM)
cc_backingswap_en=0	# enable(1) or disable(0) backing swap
cc_backingswap=/dev/block/mmcblk0p3 # pointing to the backingswap partition device, swap
cc_swappiness= # default 60
}

#create swap file for compcache or linux swap
swap_file{
swap_file_en=0	# set to 1 to create swap file
				# set to 0 to del the swap file
linux_swap_file_size=32	# swap file size in MB
linux_swap_file=/system/sd/swap.file	# pointing to the swap file location ( must be /system/sd/)
}


#Linux swap parameters
#
# linux swap can only be enabled if cc_backingswap_en is set to "0"
#
linux_swap{
linux_swap_en=0	# enable(1) or disable(0) linux swap
linux_swap_partition=/dev/block/mmcblk0p3 # swap partition device
swappiness=30 # default 60
}

#virtual memory 
sys_vm{
sys_vm_en=0	# enable(1) or disable(0) virtual memory configurations
page_cluster=0	# default 3, (0 since CM3.9.6+)
laptop_mode=0	# default 0
dirty_expire_centisecs=3000	# default 3000
dirty_writeback_centisecs=500	# default 500
dirty_background_ratio=5	# default 5
dirty_ratio=10	# default 10
}

#cpu clock
proc_cpu{
proc_cpu_en=0	# enable(1) or disable(0) user cpu configurations
# freqency options
# 19200
# 122880
# 128000
# 245760
# 384000
# 528000
scaling_min_freq=245760	# default 245760
scaling_max_freq=528000	# default 528000
sampling_rate=2000000	# default 2000000 depending on kernel version
powersave_bias=200	# default 0,  (200 since CM3.9.6+ )
up_threshold=40	 # default 40, percent cpu usage before going up a speed step
}

# custom shell commands, these commands run last
custom_shells{
#echo "Hello!!!" # example
#echo "You can create your own cmmands here" # example
}
To enable linux swap
Code:
linux_swap_en=1
To enable virtual memory configurations
Code:
sys_vm_en=1
To enable CPU related configurations
Code:
proc_cpu_en=1

some sample configurations
Quote:
To use only linux-swap
-set compcache=0
-set cc_backingswap_en=0
-set linux_swap_en=1

To use only compcache without backing_swap
-set compcache=1
-set cc_backingswap_en=0
-set linux_swap_en=0
-set cc_disksize=32 (32*1024 = 32768kb = 32MB)
-set cc_memlimit=0

To use compcache with backing_swap
-set compcache=1
-set cc_backingswap_en=1
-set linux_swap_en=0
-set cc_disksize=0
-set cc_memlimit=8

To use compcache with linux swap
-set compcache=1
-set cc_backingswap_en=0
-set cc_disksize=32
-set cc_memlimit=0
-set linux_swap_en=1

originally posted by uwonsum

To use compcache + backingswap with swap file
-set swap_file_en=1
-set linux_swap_file_size=32
-set linux_swap_file=/system/sd/swap.file
-set cc_memlimit=8
-set cc_backingswap=/system/sd/swap.file

To use compcache with linux swap file * Does not work
-set swap_file_en=1
-set linux_swap_file_size=32
-set linux_swap_file=/system/sd/swap.file
-set compcache=1
-set cc_backingswap_en=0
-set cc_disksize=32
-set linux_swap_en=1
-set linux_swap_partition=/system/sd/swap.file
Equivalent user.conf settings to CM 3.9.10+ compcache default settings
Code:
compcache_en=1
cc_disksize=24
cc_backingswap_en=0
Please do not use notepad to edit the user.conf or userinit.sh because you could end up some funny error due to format differences between unix and windows. A good example of unix format compatible editor for windows is notepad++

If you had any problem with the script please post the error log. This way its much easier to identify the problem

If there any other parameters/configurations that you wish to add, msg me! I will try to add them when i got time.
Attached Files
File Type: zip userinit_V0.1.3.7.zip - [Click for QR Code] (4.4 KB, 1185 views)
File Type: zip userinit_V0.1.4.zip - [Click for QR Code] (4.8 KB, 474 views)
File Type: zip userinit_V0.1.4.1.zip - [Click for QR Code] (4.9 KB, 1026 views)
File Type: zip userinit_V0.1.5.2.zip - [Click for QR Code] (6.4 KB, 200 views)
File Type: zip userinit_V0.1.5.3.zip - [Click for QR Code] (6.4 KB, 4922 views)
 
pistol4413
Old
#2  
pistol4413's Avatar
Senior Member
Thanks Meter 0
Posts: 579
Join Date: May 2009
Location: Philadelphia
Which version of CM will this work for? The stable ones of the experimental also
HTC One S
Cyanogenmod


 
huanyu
Old
(Last edited by huanyu; 7th September 2009 at 02:48 AM.)
#3  
Senior Member - OP
Thanks Meter 13
Posts: 124
Join Date: Apr 2009
If you upgrade from V0.1.1 to V0.1.3+ make sure you reboot your phone after install.

ROM compatibility list report by users
CM 3.6.8.1 tested by Me
CM 3.9.2 tested by MrBlueEyez
CM 3.9.3 tested by Me *requires couple lines of hacking to a2sd , Detailed instruction please see http://forum.xda-developers.com/show...9&postcount=36
CM 3.9.4 tested by sacredsoul, ShatBag1105
CM 3.9.5 tested by ShatBag1105, me
CM 3.9.6 tested by sacredsoul, uwonsum
CM 3.9.7 tested by uwonsum

Known issues
To work with CM3.9.3, couple lines of hacking to a2sd is required, Detailed instruction please see http://forum.xda-developers.com/show...9&postcount=36

~ CC backingswap with swapfile does not work

Application upgrade or reinstall may causing force close as the odex file is incompatible. Please rerun the script to create the new odex.


Change log

version 0.1.5.3
* fix missing cc_swappinessmissing in user.conf

version 0.1.5.2
* fix && error at line 649


version 0.1.5.1
* auto rebuilds the odex if the application is reinstalled or upgraded
* removes odexes if application is uninstalled

version 0.1.5
* fix permission for applications
* rebuild/create odexes
* custom user shell command support in user.conf


version 0.1.4.1
* Fix linux swappiness overwrites cc_swappiness value
* Fix duplication of mkswap for swap file
* Fix status output function turns off swap file/partition

version 0.1.4
* add userinit.sh symbolic link to system/bin/userinit
* support swap file for linux swap

version 0.1.3.7
* enables user configuration output with minor output tweaks
* fix typo in user.conf

version 0.1.3.6
* fix blank proc_cpu status output
* disable user configuration output

version 0.1.3.5
* disable sys_vm and proc_cpu by default
* some minor output tweaks

version 0.1.3.3
* Add up_threshold suggested by smeat @ #202
* Turn off Compcache/linux swap when compcache_en/linux_swap_en is set to 0
* Linux swap swappiness error message fix

Changes in v0.1.3.2
* auto detection for compcache version which means cc_version is no longer required. Detection method provided by uwonsum

Changes in v0.1.3.1
* Display cc_version for status check

Changes in v0.1.3
* support compcache version 0.6, make sure you set cc_version=0.6 in your user.conf file
* fix unable to remove kernel module errors
* fix compcache status check error
I haven't personally test the script with CM 3.9.6 yet.

Changes in v0.1.1
* fix file not found issue when the script is not executed from "/" directory
* -i only display the system information instead setting the parameters before display it

Changes in v0.1
* introduce cc_swappiness (replacement of compcache swappiness in user.conf) to fix swappiness overwrite issues.
* Fix backing swap issues
* Fix "cat /proc/ramzswap0" report not found issues
* Fix compcache detection error
thanks to uwonsum for pointing out these issues
 
pistol4413
Old
(Last edited by pistol4413; 31st July 2009 at 04:31 PM.)
#4  
pistol4413's Avatar
Senior Member
Thanks Meter 0
Posts: 579
Join Date: May 2009
Location: Philadelphia
I used the file from the thread for 3.6.7. whould u say urs is better. Even with my g1 overclocked and with compcache and it still lags little bit. Seedy for the find question u clearly state that its for 3.6.8.1. Was his wondering if it works with the experimental becuase not haveing compcache is a deal breaker.

Edit: are you sure about the experimental version because he said he is using a new kernal. S
HTC One S
Cyanogenmod


 
MrBlueEyez
Old
#5  
MrBlueEyez's Avatar
Member
Thanks Meter 0
Posts: 67
Join Date: Jul 2009
Location: Rotterdam
Tried the script and my Android on CM 3.9.2 works smoothly. Checked with free on Terminal, seems to swap nicelly. What i don't get is the configuration... I downloaded the userinit.sh and user.conf, pushed to /system/sd and did the chmod stuff...

Do i have to change my user.conf to change the configuration? And what configuration works best for 3.9.2?

Nice work though! Finally after 5 months i had the guts to root and update SPL, recovery and mod my phone. Want to get the best out of it!
Phone: Samsung Galaxy S Plus // Mod: BroodROM RC4 {edit}
 
fridlack
Old
(Last edited by fridlack; 31st July 2009 at 05:02 PM.)
#6  
fridlack's Avatar
Senior Member
Thanks Meter 85
Posts: 638
Join Date: May 2009
Location: Gava, Barcelona
Ok, with the file in this post you have a compcache actived in swap partition without swap in CM ROM, thats correct?

And fixt the clock of CPU in MAX=528 and MIN=245, if i want to manage CPU status with set CPU what lines must to delete?

I only want to activate compcache in my 32mb swap partition, no swap, no CPU overcloack...

Thanks for your help and sorry for my english
 
pychobj2001
Old
#7  
Senior Member
Thanks Meter 14
Posts: 373
Join Date: Nov 2007
Location: Rockford
For some reason this is the only one that word on the experimental builds...the others didn't work well even tho it said good compress 74 percent all the time..i would go to "tunewiki" cause that thing is the biggest memory hog, play some music see if it would load fast and then press back to go to the playlist...w/ compcache and swap off it would just go to a black screen and ask to wait or force close...but when the userinit stuff worked it would play stuff fast and go to the playlist without a hitch and no wait time...aka no killing the task in the background because of low memory....hurray..my compcache is working again..it might have had something to do w/ a .conf file...the others didn't have that file....hmmm, anyways thanks huanyu for this and whoever started playing w/ compcache in the first place!!! ha...
Current Phone and Tablet: LG G3: Stock 4.4.2 / Nexus 10: Slimrom 4.4.4

Previous Phones w/ Favorite Roms:
Nexus 5: Slimrom 4.4.4 / Nexus 4: Carbon / SGS3: ROM Carbon 4.2.1 / SGSII: ROM - AOKP 4.1 / G2X: ROM - AOKP 4.1 / Vibrant: AOKP 4.1 / G1: ROM - 2.3.4 - COS-DS / Juno: ROM - WM6.5
 
uwonsum
Old
(Last edited by uwonsum; 1st August 2009 at 01:16 AM.)
#8  
uwonsum's Avatar
Senior Member
Thanks Meter 0
Posts: 203
Join Date: Jul 2008
Quote:
Originally Posted by huanyu View Post
The purpose of this script to allow user to define their own set of configuration in a easier way. You can play with the parameters (user.conf)
to find out what suits you best.

I have only test it with stable version of CM 3.6.8.1.

the by default, the 32MB of compcache is enabled. It should just work after you push the files to /system/sd

If there any other parameters that you wish to add, msg me! I will try to add them when i got time.
Very very nice, you basically re-wrote the whole thing from your original. Great work and thanks!

edit: The minimum usable cpu frequency is 128000, anything lower will cause the phone to freeze once power plug is removed.
here the available options:
19200
122880
128000
245760
384000
528000
 
alapapa
Old
#9  
alapapa's Avatar
Senior Member
Thanks Meter 7
Posts: 453
Join Date: Dec 2007
I don't get it...what's the point of a config file for a config file?
I can help you become more human

 
meental
Old
(Last edited by meental; 1st August 2009 at 01:43 AM.)
#10  
Member
Thanks Meter 4
Posts: 37
Join Date: May 2007
Location: san diego
jus to clairify to test it the command should be

Quote:
adb shell /system/sd/userinit.sh -s
instead of

Quote:
adb shell chmod 755 /system/sd/userinit.sh -s

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

How to Root the Sony Xperia Z2 – XDA Developer TV

In this episode,XDA Developer TV Producer TK shows you how to root your Sony Xperia … more

TWRP Now Available for the LG G Watch and Samsung Gear Live

Over the past week or so, we’ve talkedquite a bit about the first … more

Slate Calendar Helps You Organize Your Life

Without calendars in some form or another, most of our lives would be utter chaos. Unless you are … more

Shane Francis to Talk Android, Robotics, and Vision at XDA:DevCon 2014

Our international xda:devcon 14in Manchester, UK on the weekend of … more