November 2011


Some Android devices, which have little internal memory or when download data and application data fills the cache area, will issue “insufficient space” warning.  A quick workaround would be to move device cache and/or application caches to SD card.

It is assumed that the device is already rooted and a way to run commands on the device is available. i.e “Terminal Emulator” app, Android ADB.  The technique explained in this post (Symbolic Linking) will not work on SD cards formatted with FAT/NTFS.

Basically, the idea is to create a cache folder on SD card, remove the cache folder on internal memory and then link the internal folder to the folder on SD card so SD card space is used.

To move the cache folder

umount /cache
mount -o rw,remount -t rootfs rootfs /
rmdir /cache
mkdir /sdcard/cache
ln -s /sdcard/cache /cache

Browser Cache

cd /data/data/com.android.browser/cache
rm -R webviewCache
mkdir /sdcard/cache/webviewCache
ln -s /sdcard/cache/webviewCache webviewCache

Google Maps

cd /data/data/com.google.android.apps.maps
rm -R files
mkdir /sdcard/cache/files/maps
ln -s /sdcard/cache/files/maps files

Google StreetView

cd /data/data/com.google.android.street
rm -R cache
mkdir /sdcard/cache/streetCache
ln -s /sdcard/cache/streetCache cache

Market Cache

cd /data/data/com.android.vending
rm -R cache
mkdir /sdcard/cache/marketCache
ln -s /sdcard/cache/marketCache cache

imeem Cache

cd /data/data/com.imeem.gynoid
rm -R cache
mkdir /sdcard/cache/imeemCache
ln -s /sdcard/cache/imeemCache cache

Tunewiki Cache

cd /data/data/com.tunewiki.lyricplayer.android/cache
rm -R webviewCache
mkdir /sdcard/cache/tunewikiCache
ln -s /sdcard/cache/tunewikiCache webviewCache

Steel Browser Cache

cd /data/data/com.kolbysoft.steel/cache
rm -R webviewCache
mkdir /sdcard/cache/steelCache
ln -s /sdcard/cache/steelCache webviewCache

OR

cd /data/data/com.kolbysoft.steel
mkdir cache
cd cache
mkdir /sdcard/cache/steelCache
ln -s /sdcard/cache/steelCache webviewCache

MeetMe Cache

cd /data/data/com.stylem.meetme
rm -R cache
mkdir /sdcard/cache/meetmeCache
ln -s /sdcard/cache/meetmeCache cache

MySpace

cd /data/data/com.myspace.android
mkdir /system/sd/cache/files/myspace
rm -R files
ln -s /sdcard/cache/files/myspace files

Gmail

cd /data/data/com.google.android.gm/cache
rm -R webviewCache
ln -s /sdcard/cache/webviewCache webviewCache

Voice Search

cd /data/data/com.google.android.voicesearch/cache
rm -R webviewCache
ln -s /sdcard/cache/webviewCache webviewCache

My Maps Editor

cd /data/data/com.google.android.apps.mymaps/cache
rm -R webviewCache
ln -s /sdcard/cache/webviewCache webviewCache

Credits:

Thanks to birdman81484 for imeemm, Tunewiki, Steel Browser, MeetMe, MySpace cache folders

Advertisements

A daemon is an application or a script running as a background process. A traditional way of handling daemons on *nix systems is using rcx.d scripts. However, Solaris 10 uses SMF to control services instead of startup/shutdown scripts. Typically, SMF uses a manifest file, which describes the service, to control the service. A manifest file contains information about services name, dependency, commands to start and stop and human readable name. Here is a sample manifest file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='REPLACE_BUNDLE-NAME'>
	<!-- Service name can occur 0 or 1 time -->
	<service name='REPLACE_SERVICE-NAME' type='service' version='1'>

		<!-- Can occur 0 or 1 time -->
		<create_default_instance enabled='false' />

		<!-- Can occur 0 or 1 time -->
		<single_instance />

		<!-- Can occur 0 or more times -->
		<dependency name='network' grouping='require_all'
			restart_on='none' type='service'>
			<service_fmri value='svc:/milestone/network:default' />
		</dependency>

		<!-- Can occur 0 or more times -->
		<exec_method type='method' name='start'
			exec='/lib/svc/method/REPLACE_SCRIPT start' timeout_seconds='REPLACE_DURATION' />
		<exec_method type='method' name='stop'
			exec='/lib/svc/method/REPLACE_SCRIPT stop' timeout_seconds='REPLACE_DURATION' />
		<exec_method type='method' name='restart'
			exec='/lib/svc/method/REPLACE_SCRIPT restart' timeout_seconds='REPLACE_DURATION' />

		<!-- Can occur 0 or more times -->
		<instance name='REPLACE_INSTANCE-1' enabled='REPLACE_DEFAULT_STATE (true/false)'>
			<!-- Can occur 0 or 1 time -->
			<method_context>
				<method_credential user='REPLACE_USER-1' group='REPLACE_GROUP-1' />
			</method_context>

			<!-- Can occur 0 or more times -->
			<property_group name='REPLACE_PROPERTY-GROUP' type='application'>
				<propval name='REPLACE_PROPERTY-1' type='astring' value='REPLACE_VALUE-1' />
				<propval name='REPLACE_PROPERTY-2' type='astring' value='REPLACE_VALUE-2' />
			</property_group>
		</instance>
		<!-- Can occur 0 or more times -->
		<instance name='REPLACE_INSTANCE-2' enabled='REPLACE_DEFAULT_STATE (true/false)'>

			<!-- Can occur 0 or 1 time -->
			<method_context>
				<method_credential user='REPLACE_USER-2' group='REPLACE_GROUP-2' />
			</method_context>

			<!-- Can occur 0 or more times -->
			<property_group name='REPLACE_PROPERTY-GROUP' type='application'>
				<propval name='REPLACE_PROPERTY-1' type='astring' value='REPLACE_VALUE-3' />
				<propval name='REPLACE_PROPERTY-2' type='astring' value='REPLACE_VALUE' />
			</property_group>
		</instance>
		<!-- Can occur 0 or 1 time -->
		<stability value='Evolving' />

		<!-- Can occur 0 or 1 time -->
		<template>
			<common_name>
				<loctext xml:lang='C'>
					REPLACE HUMAN READABLE NAME
				</loctext>
			</common_name>
			<documentation>
				<manpage title='REPLACE_MANPAGE' section='REPLACE_SECTION' />
				<doc_link name='REPLACE_DOC' uri='REPLACE_URI' />
			</documentation>
		</template>
	</service>
</service_bundle>

Example
Lets create a daemon for x11vnc to better unstand the process

  1. Create “/var/svc/manifest/system/x11vnc.xml” with following content

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
    <service_bundle type='manifest' name='x11vnc'>
    	<service name='system/x11vnc' type='service' version='1'>
    		<create_default_instance enabled='true' />
    		<single_instance />
    		<dependency name='milestone' grouping='require_all'
    			restart_on='none' type='service'>
    			<service_fmri value='svc:/milestone/multi-user-server' />
    		</dependency>
    		<exec_method type='method' name='start'
    			exec='/lib/svc/method/x11vnc start' timeout_seconds='60' />
    		<exec_method type='method' name='restart'
    			exec='/lib/svc/method/x11vnc restart' timeout_seconds='60' />
    		<exec_method type='method' name='stop'
    			exec='/lib/svc/method/x11vnc stop' timeout_seconds='60' />
    		<method_context>
    			<method_credential user='vncuser' group='vncgroup' />
    		</method_context>
    		<property_group name='x11vnc' type='application'>
    			<!-- This is for illustration purposes only, x11vnc doesn't have such
    				properties -->
    			<propval name='log' type='astring' value='/var/log/x11vnc.log' />
    			<propval name='log-level' type='astring' value='debug' />
    		</property_group>
    		<stability value='Evolving' />
    		<template>
    			<common_name>
    				<loctext xml:lang='C'>X11VNC Server</loctext>
    			</common_name>
    			<documentation>
    				<manpage title='x11vnc' section='1M' />
    				<doc_linkname = x11vnc_faq '
    					uri='http://www.karlrunge.com/x11vnc/faq.html#faq' />
    			</documentation>
    		</template>
    	</service>
    </service_bundle>
  2. Create “/lib/svc/method/x11vncd” with following content

    #!/sbin/sh
    #
    # Copyright (c) 1995, 1997-1999 by Sun Microsystems, Inc.
    # All rights reserved.
    #
    #ident "@(#)x11vnc 1.14 06/11/17 SMI"
    VNC_CMD="/usr/local/bin/x11vnc"
    #VNC_CMD="$VNC_CMD -geometry 1280x1024"
    #VNC_CMD="$VNC_CMD -unixpw"
    VNC_CMD="$VNC_CMD -ncache 10"
    VNC_CMD="$VNC_CMD -display :0"
    VNC_CMD="$VNC_CMD -noshm"
    VNC_CMD="$VNC_CMD -shared"
    VNC_CMD="$VNC_CMD -forever"
    VNC_CMD="$VNC_CMD -bg"
    VNC_CMD="$VNC_CMD -o /var/log/x11vnc.log"
    
    case $1 in
    	start)
    	    echo "Starting X11VNC..."
    	    $VNC_CMD & > /dev/null
    	    if[$? -gt 0]; then
    	        echo "VNC couldn't be started"
    	    else
    	        echo "VNC started"
    	    fi
    	;;
    	
    	restart)
    	   $0 stop
    	   sleep 1
    	   $0 start
    	;;
    	
    	stop)
    	   echo "Stopping X11VNC..."
    	   /usr/bin/pkill -x -u 0 x11vnc
    	   if[$? -gt 0]; then
    	       echo "VNC couldn't be stoped"
    	   else
    	       echo "VNC stoped"
    	   fi
        ;;
        
        *)
            echo "Usage: $0 {start | restart | stop}"
        ;;
    esac
    
    exit 0
  3. Change permissions on both files to be 555

    bash-2.05$ chmod 555 /var/svc/manifest/system/x11vnc.xml
    bash-2.05$ chmod 555 /lib/svc/method/x11vncd
  4. Validate the manifest file

    bash-2.05$ svccfg validate /var/svc/manifest/system/x11vnc.xml
  5. Import the manifest file

    bash-2.05$ svccfg import /var/svc/manifest/system/x11vnc.xml
  6. Check the state of the deamon

    bash-2.05$ svcs -x x11vnc
  7. Enable the daemon

    bash-2.05$ svcadm enable x11vnc
  8. Check the state of the deamon

    bash-2.05$  svcs -x x11vnc
    svc:/system/x11vnc:default (X11VNC Server)
     State: online since Thu Nov 17 18:12:48 2011
       See: /var/svc/log/system-x11vnc:default.log
    Impact: None.
  9. If the daemon is in maintenance mode check the log, resolve issues. In above command the log file would be at “/var/svc/log/system-x11vnc:default.log

  10. Restart the daemon
    bash-2.05$ svcadm clear x11vnc