Search This Blog

Showing posts with label mobile phone. Show all posts
Showing posts with label mobile phone. Show all posts

Configuring zRAM on the Sony Xperia Play with FreeXperia Zeus

If you have unlocked your Xperia Play and installed FreeXperia (+CyanogenMod  9.1) then you will quickly discover that enabling zRAM via the Performance settings has no effect whatsoever.





















I have reported this as a bug but the project team seem more interested in burying their head in the sand so you won't get any help at all from them. I even asked for help on the +FreeXperia +Google+ page but I gave up on asking for any help from anyone there a long time ago.

The provided Linux kernel definitely does have zRAM enabled.

# ll /dev/block/zram*
brw-------    1 root         root          253,   0 Sep 10 13:10 /dev/block/zram0

The problem lies within the UI to configure it. No scripts seem to be created or executed so either the option is a stub or it is simply broken.

Initially I decided to use SetXperia which, again, proves that the kernel part is fine, but SetXperia remains in RAM all the time, and even in the notification area. I just don't see the point in that.

It can't be that difficult to enable zRAM, right?

Using the Ubuntu zram-config package it was fairly easy to work out what was needed and hence create a script.

#!/system/bin/sh

SWAPPINESS="35"
TAG="zram-config"

log -p i -t $TAG "Setting vm.swappiness to $SWAPPINESS"
logwrapper sysctl -w vm.swappiness=$SWAPPINESS
log -p i -t $TAG "Done."

log -p i -t $TAG "Setting up zram"
echo 75497472 > /sys/block/zram0/disksize
logwrapper mkswap /dev/block/zram0
logwrapper swapon /dev/block/zram0
log -p i -t $TAG "Done."

log -p i -t $TAG "All done."

I dropped this script into /data/local/userinit.d/zram-config (remember to set +x on the script).

All the log and logwrapper stuff is obviously to send details to the log. It probably doesn't work as the script is run before Android is loaded. Indeed, I've never seen anything using logcat unless it's run manually. They are not needed for the script to work.

vm.swappiness is set to 60 by default. You shouldn't change that unless you know what you're doing. In my case sysctl -w vm.swappiness=35 does this. I could not find a config file for sysctl (such as /etc/sysctl.conf) as is the case for most Linux distributions.

The Ubuntu script sets up the amount of zRAM based on the amount of RAM and creates separate devices based on the number of cores, which makes sense because it's a generic script to be used on a vast array of machines including, recently, mobile platforms. There's no real need to do that unless you plan on dropping the script on a variety of different devices. You should decide for yourself how much zRAM you want to configure.

echo 75497472 > /sys/block/zram0/disksize sets my zRAM device to 75 MB.

mkswap /dev/block/zram0 sets up the device as a swap device, as you would with any normal swap.

swapon /dev/block/zram0 enables the swap.

This can, of course, be used with any device that has zRAM enabled in the kernel.

# uname -a
Linux localhost 2.6.32.9-FXP #1 PREEMPT Fri Apr 19 17:37:58 EEST 2013 armv7l GNU/Linux

I recommend installing ZRAM Status from the Play Store so that you can see that your zRAM is being used, along with some interesting, nerdy statistics.




Remember that you will need to reboot your device (or run the script manually) to enable zRAM the first time.

Start the Android media scanner from the command line

If you're like me, and let's hope for your sake that you're not, you find it much easier to run an SSH server on your Android device than using something like adb or USB Mass Storage or any of the other crap out there.

With SSH I can simply and easily check logcat, netstat, issue commands, copy files and generally bugger about.

Sometimes you have moved quite a lot of files around and you need your media scanner to launch to update its database. This can be done via the CLI.

BT SmartTalk

I have previously written about how impressed I am by BT's roll out of their 21CN network. I never thought for a second they could impress me even further but they have! I do believe this now makes me a BT fanboi, but I'm cool with that because I'll be an adult soon.

Whilst messing around on the Internet and checking my telephone usage I stumbled across BT SmartTalk. SmartTalk is not new technology. It is basically a VoIP service operated by BT where your calls are routed over the Internet and you are billed to your BT bill. This means you can bill your landline at landline rates, and not have to pay the ridiculous charges mobile operators get away with (such as charging for 0800, higher charges for 0844, 0845, etc.) and even call back to the UK at UK standard call rates so long as you have an Internet connection. And it's free!

In Australia and want to call home? Got a plan that gives you free calls to landlines? It won't cost a penny!

My profile on StackExchange