• Announcements

    • Reminder - MoDaCo position on illegal content   07/30/15

      ILLEGAL CONTENT I'd like to just reaffirm MoDaCo's position regarding piracy and illegal content in the light of some recent questions / postings. Posts will be censored by myself or my moderation team if the contain or link to: Illegal / pirated / cracked software or sites that host such softwareNintendo emulators / ROMs or sites hosting them (in light of Nintendo's legal stance)CUSTOM ROMS You may discuss and post links to custom device ROMs on MoDaCo, provided the following rules are adhered to: ROMs must not contain any illegal 3rd party software (this includes trial versions included without permission)ROMs must give full credit to the original authorISSUES If you have any issues with this policy, please contact PaulOBrien directly via PM.
    • Reminder: Selling items on the forum directly is not allowed   07/30/15

      Please note that selling items on the forum directly is not allowed by the forum rules. There is a forum for eBay auctions whereby you can list the items on eBay and link to them there. This is the ONLY forum for this type of activity. You may also advertise links to the eBay forum in your signature. Please note that selling directly in contravention of these rules will result in a warning / suspension / ban.
Sign in to follow this  
Followers 0

[CM10.1] Using swap without repartitioning

6 posts in this topic

Posted · Report post

ZTE Blade 3 has a plenty of space on /data partition, so i decided

to not to repartition my SD card, instead i use a file on /data as swap partition.

Sometimes the swap seems to help, at least i have less out-of-memory cases...

So here is the trick.

First you have to make a swapfile (you can do it on your SD card as well),

use adb shell and su to become root (to have access to /data/local)


# dd if=/dev/zero of=/data/local/swapfile bs=1048576 count=400 #400MB

# mkswap /data/local/swapfile

Then you have to write a script which enables the swap during boot, lets use userinit.sh for the filename, and (adb) push it to /data/local this script will be called automatically by the CyanogenMod init.d at the boot.
#!/system/bin/sh

L="log -p i -t swap"

SWAPFILE=/data/local/swapfile


$L "Activating SWAP ..."

if [ -f $SWAPFILE ];

then

/system/xbin/swapon $SWAPFILE

$L "SWAP activated."

else

$L "SWAP not activated. ($SWAPFILE not exists)"

fi
Finally lets add an executable bit to the script (adb shell and su again) (and you can start it manually right now, so no need for reboot)

# chmod 0777 /data/local/userinit.sh

# /data/local/userinit.sh

And now you can check if it it succeed:

# free -m | grep Swap										

Swap:	 409596	 42176	 367420

I tried with this CyanogenMod build, but this trick may works with the other CMs too:

http://www.modaco.co...01-android-422/

0

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks much, seems to work fine with cm10 :D

0

Share this post


Link to post
Share on other sites

Posted · Report post

don't you think this will reduce the lifespan of the built-in flash memory? since it's not (easily) replaceable, i'm worried about wearing it out faster with all the constant read-writes..

0

Share this post


Link to post
Share on other sites

Posted · Report post

don't you think this will reduce the lifespan of the built-in flash memory? since it's not (easily) replaceable, i'm worried about wearing it out faster with all the constant read-writes..

Of course it will reduce it more than without it.

0

Share this post


Link to post
Share on other sites

Posted (edited) · Report post

I did it with minor changes, like this:

 

First you have to make a swapfile (you can do it on your SD card as well),
use adb shell and su to become root (to have access to /data/local)
# dd if=/dev/zero of=/cache/swapfile bs=1048576 count=200
# mkswap /cache/swapfile
Then you have to write a script which enables the swap during boot,
lets use userinit.sh for the filename, and (adb) push it to /data/local
this script will be called automatically by the CyanogenMod init.d at the boot.
#!/system/bin/sh
L="log -p i -t swap"
SWAPFILE=/cache/swapfile

$L
"Activating SWAP ..."
if [ -f $SWAPFILE ];
then
/system/xbin/swapon $SWAPFILE
$L
"SWAP activated."
else
$L "SWAP not activated. ($SWAPFILE not exists)"
fi
Finally lets add an executable bit to the script (adb shell and su again)
(and you can start it manually right now, so no need for reboot)
# chmod 0777 /data/local/userinit.sh
# /data/local/userinit.sh

 

And, at the last step I got this: https://drive.google.com/file/d/0B68upf_9I8KaNXNXSHpkS3l0cnc/edit?usp=sharing

Can anyone help pls?

Edited by shadowprince94
0

Share this post


Link to post
Share on other sites

Posted · Report post

Same problem:

sh: userinit.sh: not found

 

or
 

127|root@atlas40:/data/local # sh userinit.sh
sh userinit.sh
: not found[4]:
userinit.sh[13]: syntax error: 'fi' unexpected

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

MoDaCo is part of the MoDaCo.network, © Paul O'Brien 2002-2015. MoDaCo uses IntelliTxt technology.