Dual Boot Atrix CM9 (emmc) and CM7 (sdcard) - Atrix 4G Android Development

Recently I became interested in dual booting my Atrix, mainly for the fun of it, and because I like the convenience of quickly reverting to a different ROM without having to restore it from backup. I would also like to evaluate the performance of my system with sdcard in the loop among other things.
From my web research, it appears that multiple attempts at dual booting the Atrix have been made without much success. I have heard of SafeStrap, but I'm the kind of person who wants to know what’s happening inside the black box. So I decided to try my hand by flashing CM9 to internal memory and CM7 to my Patriot 16GB Class 4 micro-SD card. I did all of this on Ubuntu 11.10 using GParted, Android SDK and several Perl and Bourne shell scripts that I either customized or created.
I probably could have done this on Windows (which for example has Atrix USB drivers whereas Ubuntu does not) and perhaps be able to use available space on my 10GB emmc to host additional ROMs. But in spite of the lack of drivers, I felt more comfortable having a full-up, dedicated *nix-based OS on hand to support the experiment.
I decided to to push a stable ROM to sdcard (in this case, CM7.2 RC1), one that runs well without any patches --- because a stock recovery tool wouldn't recognize it.
The experiment was successful as I now enjoy my 3GB CM7 build running from SD card with stable browser, keyboard and camera. And I can still use Joker's Kitchen Sink to explore some of the many possible ROM configurations without touching the CM7 build.
YouTube video (3:38) showing reboots from one ROM to the other: http://www.youtube.com/watch?v=31TPyAguQ60
Preliminaries (Ubuntu)
GParted and Perl installed
Android SDK for Linux (i386) installed http://developer.android.com/sdk/index.html
I download testsign.zip from http://forum.xda-developers.com/showthread.php?t=551711 , copy to Ubuntu <android-sdk-linux/tools> directory and extract zip there. This creates a testsign subfolder with testsign.jar file inside.
Atrix Filesystem Analysis
I boot my phone to CWM 5.0.2.0, open an Ubuntu terminal, get root (sudo -s), run adb shell and invoke the “edify” and “df” commands to view the current filesystem:
~ # edify
recovery filesystem table
=========================
0 /tmp ramdisk (null) (null)
1 /boot emmc /dev/block/mmcblk0p11 (null)
2 /cache ext3 /dev/block/mmcblk0p15 (null)
3 /data ext3 /dev/block/mmcblk0p16 (null)
4 /sdcard vfat /dev/block/mmcblk1p1 (null)
5 /emmc vfat /dev/block/mmcblk0p18 (null)
6 /system ext3 /dev/block/mmcblk0p12 (null)
7 /recovery emmc /dev/block/mmcblk0p10 (null)
8 /osh ext3 /dev/block/mmcblk0p13 (null)
9 /preinstall ext3 /dev/block/mmcblk0p17 (null)
~ # df -a
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 417804 32 417772 0% /dev
devpts 0 0 0 0% /dev/pts
proc 0 0 0 0% /proc
sysfs 0 0 0 0% /sys
/dev/block/mmcblk0p15 645056 69020 543268 11% /cache
/dev/block/mmcblk0p16 2064208 129052 1830300 7% /data
/dev/block/mmcblk0p12 322516 238496 84020 74% /system​
SD Card Partitioning
Next I get root on Ubuntu, connect SD card to PC, ensure SD card adapter switch is set to read/write, run GParted and shrink the vfat (fat32) partition to allow room for /system, /cache and /data in that order. Then I create these partitions as ext4 with sizes reasonably consistent with the existing filesystem on emmc.
Note: GParted did not see my internal (emmc) card, and it prefixed the sdcard partitions as “/dev/mmcblk0” instead of “/dev/mmcblk1”.
Now I exit GParted, pull sdcard from PC and reinsert into phone. Then I boot to CWM, connect phone to PC, enter adb shell and verify the new sdcard partition map using the onboard “parted” tool:
~ # parted /dev/block/mmcblk1
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: SD SU16G (sd/mmc)
Disk /dev/block/mmcblk1: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 4194kB 10.7GB 10.7GB primary fat32 lba
2 10.7GB 11.1GB 346MB primary ext4
3 11.1GB 11.8GB 692MB primary ext4
4 11.8GB 14.0GB 2217MB primary ext4
quit
~#​
Clone CM7 to SD Card
Presently I have CM7.2 RC1 installed in emmc, and I want to clone this ROM to sdcard. But I first ensure that my phone is adequately charged, especially if I will be in CWM for a long time. My experience is that CWM can drain the battery, even when phone is connected to a powered USB hub.
I boot to CWM 5.0.2.0, open Ubuntu terminal on PC, get root (sudo -s), run adb shell and mount the new CM7 sdcard partitions.
Then I clone ROM to sdcard. (I did this over ADB, though in retrospect I probably could have done it more quickly with terminal emulator.)
~ # dd if=/dev/block/mmcblk0p12 of=/dev/block/mmcblk1p2
655360+0 records in
655360+0 records out
335544320 bytes (320.0MB) copied, 140.786369 seconds, 2.3MB/s
~ # dd if=/dev/block/mmcblk0p15 of=/dev/block/mmcblk1p3
1310720+0 records in
1310720+0 records out
671088640 bytes (640.0MB) copied, 282.791984 seconds, 2.3MB/s
~ # dd if=/dev/block/mmcblk0p16 of=/dev/block/mmcblk1p4
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.0GB) copied, 898.662170 seconds, 2.3MB/s​
Since the data partition is fairly large, I ending up using the “cat” command, which cut the transfer time to about 6 minutes….
~ # cat /dev/block/mmcblk0p16 > /dev/block/mmcblk1p4​
Flash CM9 to Internal Memory
Now I push Joker CM9 beta 0.6.0 zip to sdcard and install via CWM...
[email protected]:~/Desktop# adb push beta-0.6.0-cm-9.0.0-RC0-olympus-UNOFFICIAL-signed.zip /sdcard/Download
1286 KB/s (125162795 bytes in 95.013s)
[email protected]:~/Desktop#​
Modify CM7 Ramdisk, Re-pack ROM Zip and Re-sign
Now I modify ramdisk in the CM7 boot.img to mount the sdcard /system, /cache and /data partitions at boot time. To help streamline the mod, I wrote custom Perl scripts based on the ones linked here:
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
My Perl script “unpack-romzip.pl” actually starts with a baseline ROM, extracts boot.img and then p****s out kernel and ramdisk directory from boot.img. Here is the script in action...
[email protected]:~/Desktop# ./unpack-romzip.pl update-cm-7.2.0-RC1-olympus+gapps.zip
Extract boot.img from update-cm-7.2.0-RC1-olympus+gapps.zip
Archive: update-cm-7.2.0-RC1-olympus+gapps.zip
inflating: boot.img
Rename boot.img to update-cm-7.2.0-RC1-olympus+gapps.img
kernel written to update-cm-7.2.0-RC1-olympus+gapps.img-kernel
ramdisk written to update-cm-7.2.0-RC1-olympus+gapps.img-ramdisk.cpio.gz
Extract ramdisk zip to directory: update-cm-7.2.0-RC1-olympus+gapps.img-ramdisk
513 blocks
Delete intermediate file: update-cm-7.2.0-RC1-olympus+gapps.img-ramdisk.cpio.gz​
Results...
-rw-r--r-- 1 root root 2574336 2012-05-03 19:12 update-cm-7.2.0-RC1-olympus+gapps.img-kernel
drwxr-xr-x 8 root root 4096 2012-05-03 19:12 update-cm-7.2.0-RC1-olympus+gapps.img-ramdisk​
In this experiment, the only ramdisk file I will modify is init.olympus.rc: I do so by commenting out the /system, /cache and /data mount commands for the emmc partitions and creating equivalent mount commands for the sdcard partitions...
# mount ext4 /dev/block/mmcblk0p12 /system noatime nodiratime wait ro barrier=1
# mount ext4 /dev/block/mmcblk0p16 /data nosuid nodev noatime nodiratime wait barrier=1 noauto_da_alloc
# mount ext4 /dev/block/mmcblk0p15 /cache nosuid nodev noatime nodiratime wait barrier=1 noauto_da_alloc
mount ext4 /dev/block/mmcblk1p2 /system noatime nodiratime wait ro barrier=1
mount ext4 /dev/block/mmcblk1p4 /data nosuid nodev noatime nodiratime wait barrier=1 noauto_da_alloc
mount ext4 /dev/block/mmcblk1p3 /cache nosuid nodev noatime nodiratime wait barrier=1 noauto_da_alloc​
Now I back out of ramdisk and run my other Perl script: repack-romzip.pl, which combines ramdisk and kernel to obtain a new boot image and then generates a repacked ROM zip. Here is the script in action...
[email protected]:~/Desktop# ./repack-romzip.pl update-cm-7.2.0-RC1-olympus+gapps.zip
Repack Android boot image from kernel file and ramdisk directory and roll into new ROM zip
Run cpio and gzip on ramdisk directory
514 blocks
Make boot image from kernel file and ramdisk cpio zip
Updated boot.img...
-rw-r--r-- 1 root root 2725888 2012-05-03 19:20 update-cm-7.2.0-RC1-olympus+gapps-repack.img
Copy update-cm-7.2.0-RC1-olympus+gapps.zip to update-cm-7.2.0-RC1-olympus+gapps-repack.zip
Add updated boot.img to update-cm-7.2.0-RC1-olympus+gapps-repack.zip
updating: boot.img
zip warning: Local Entry CRC does not match CD: boot.img
(deflated 0%)​
I am almost ready to re-sign my CM7 ROM zip. But I first need to modify its updater-script to mount /system to /dev/block/mmcblk1p2 (sdcard) instead of /dev/block/mmcblk0p12 (emmc). So I edit the updater-script and change:
format("ext4", "EMMC", "/dev/block/mmcblk0p12");
mount("ext4", "EMMC", "/dev/block/mmcblk0p12", "/system");​
to
format("ext4", "EMMC", "/dev/block/mmcblk1p2");
mount("ext4", "EMMC", "/dev/block/mmcblk1p2", "/system");​
Now I invoke the java command below to re-sign the CM7 zip:
[email protected]:~/Desktop# java -classpath ~/android-sdk-linux/tools/testsign/testsign.jar testsign update-cm-7.2.0-RC1-olympus+gapps-repack.zip update-cm-7.2.0-RC1-olympus+gapps-repack-signed.zip
[email protected]:~/Desktop# ls -ld *.zip
-rw-rw-r-- 1 robert robert 125162795 2012-05-03 18:05 beta-0.6.0-cm-9.0.0-RC0-olympus-UNOFFICIAL-signed.zip
-rw-r--r-- 1 root root 105000424 2012-05-03 19:23 update-cm-7.2.0-RC1-olympus+gapps-repack-signed.zip
-rw-r--r-- 1 root root 104987732 2012-05-03 19:20 update-cm-7.2.0-RC1-olympus+gapps-repack.zip
-rw------- 1 robert robert 104999357 2012-05-01 20:10 update-cm-7.2.0-RC1-olympus+gapps.zip​
Then I transfer the re-signed zip to sdcard/Download, reboot to CWM and install.
Test Results
I do some preliminary testing by attempting to boot CM9 from Joker's CM9 1.0GHz v4 boot image file:
[email protected]:~/Desktop# fastboot boot cm9-1.0-atrixv4-boot.img
downloading 'boot.img'...
OKAY [ 0.204s]
booting...
OKAY [ 0.002s]
finished. total time: 0.206s​
Success. Now I try CM7...
[email protected]:~/Desktop# fastboot boot update-cm-7.2.0-RC1-olympus+gapps-repack.img
downloading 'boot.img'...
OKAY [ 0.182s]
booting...
OKAY [ 0.002s]
finished. total time: 0.185s​
And to my delight, CM7 boots
Finally I install Script Manager and push my custom boot-rom.sh to sdcard/Boot. This script offers four options: Current ROM (default), CM9, CM7 or CWM recovery. Rebooting to the other ROM is just a few keystrokes away, though I must configure Script Manager to run boot-rom.sh as superuser (press SU button on configuration screen).
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Elapsed times…
Execution of boot-rom.sh on CM7 to CM9 welcome screen: 44 sec.
Execution of boot-rom.sh on CM9 to CM7 welcome screen: 45 sec.
Conclusions and Thoughts
My Atrix dual boot capability offers an efficient means to circumvent instabilities in CM9 by providing a stable CM7 ROM to run from my sdcard. Of course there are limitations here in that a stock recovery won't recognize my CM7 build. But I'm fine with that since I probably won't patch.
I think it would be kind of interesting to push identical ROMs on emmc and sdcard and compare performance. I heard from a fellow engineer that Class 16 cards are now available.
It would also be interesting to explore refinements like multiple-boot from emmc and various forms of automation.
This is a work in progress and I appreciate your constructive feedback.
YouTube video (3:38) showing reboots from one ROM to the other: http://www.youtube.com/watch?v=31TPyAguQ60
Credits
jokersax11 @ xda, ghost_og @ xda,
Photon Dev Team, Atrix Dev Team
Koush
Other credits embedded in this post

Holy. ****.
Sent from my MB860 using XDA

Wow thanks for the info. I wanted to give this a try but I had a question. If I partition my sdcard to the specs you provided, can I flash your resigned cm7 zip and it would flash it to my sdcard. If that is possible, could you post the modified cm7?

Wow....waiting is coming.......

Something you could look into is moving the apps to SD and let each rom build its own dalvik cache. Then you can keep your apps between both builds
Sent from my MB855 using XDA

I think you better get into developing roms, because it sounds like you have an amazing amount of knowledge with this technology. Something I can only hope to achieve, lol.
I think you should make a full length 45 min youtube clip to explain everything, but I know that's not gonna happen, so see how much you can cram into 5 minutes! lol
Nice job man, outstanding progression!

Blur ROM with WebTop and CM9
Is it possible to switch between Blur based ROM with WebTop and CM9?

#!/system/bin/sh
mount -o remount,rw /dev/block/mmcblk0p1 /system//挂载/system为可写
busybox md5sum -cs /system/boot/md5 && CHANGE=0 || CHANGE=1//判断boot.img是否更新
echo $CHANGE
if [ "$CHANGE" = "1" ]
then
cat /dev/block/mmcblk0p5 > /data/boot1.img
busybox md5sum /system/build.prop > /system/boot/md5
echo "Creat new boot done!"
fi
if [ -e /data/boot2.img ]//判断另外的系统是否更新boot.img
then
busybox mv /data/boot2.img /system/boot/boot2.img
echo "Backup new boot done!"
fi
cat /system/boot/boot2.img > /dev/block/mmcblk0p5
fdisk /dev/block/mmcblk0 < /system/bin/fdisk1.sh
///////////////////同fixuid
mkdir /data/lib
chmod 0777 /data/lib
cat /data/system/packages.xml | grep 'package name="'| awk -F"\"" '{print $2}' > /data/packages.list
awk -F" " '{print "rm /data/data/"$1"/lib"}' /data/packages.list > /data/cx.sh
cat /system/bin/noshare|while read fname
do
echo "rm $fname-2/lib" >>/data/cx.sh
done
awk -F" " '{print "mkdir /data/lib/"$1}' /data/packages.list >> /data/cx.sh
awk -F" " '{print "mv /data/data/"$1"/lib/ /data/lib/"$1"/"}' /data/packages.list >> /data/cx.sh
busybox chown -R 1000.1000 /data/lib
awk -F" " '{print "rm -R /data/data/"$1"/lib"}' /data/packages.list >> /data/cx.sh
cat /system/bin/noshare|while read fname
do
echo "rm -R $fname-2/lib" >>/data/cx.sh
done
chmod 0777 /data/cx.sh
/data/cx.sh
////////////////////////////////////////////////////移动第二系统数据为主数据
cat /system/bin/noshare|while read fname
do
mv $fname "$fname-1"
mv "$fname-2" $fname
done
cat /data/noshare|while read fname//移动不需要共享的数据
do
mv $fname "$fname-1"
mv "$fname-2" $fname
done
echo "Move data done!"
/////////////////////////同fixuid
awk -F" " '{print "ln -s /data/lib/"$1" /data/data/"$1"/lib"}' /data/packages.list > /data/cx.sh
cat /data/system/packages.xml | grep 'package name=\"'| awk -F"\"" '{print $2" "$18}' | awk -F" " '{print "busybox chown -R "$2"."$2" /data/data/"$1}' >> /data/cx.sh
chmod 0777 /data/cx.sh
/data/cx.sh
echo "Move UID done!"
reboot

kingme__hu said:
#!/system/bin/sh
mount -o remount,rw /dev/block/mmcblk0p1 /system//挂载/system为可写
busybox md5sum -cs /system/boot/md5 && CHANGE=0 || CHANGE=1//判断boot.img是否更新
echo $CHANGE
if [ "$CHANGE" = "1" ]
then
cat /dev/block/mmcblk0p5 > /data/boot1.img
busybox md5sum /system/build.prop > /system/boot/md5
echo "Creat new boot done!"
fi
if [ -e /data/boot2.img ]//判断另外的系统是否更新boot.img
then
busybox mv /data/boot2.img /system/boot/boot2.img
echo "Backup new boot done!"
fi
cat /system/boot/boot2.img > /dev/block/mmcblk0p5
fdisk /dev/block/mmcblk0 < /system/bin/fdisk1.sh
///////////////////同fixuid
mkdir /data/lib
chmod 0777 /data/lib
cat /data/system/packages.xml | grep 'package name="'| awk -F"\"" '{print $2}' > /data/packages.list
awk -F" " '{print "rm /data/data/"$1"/lib"}' /data/packages.list > /data/cx.sh
cat /system/bin/noshare|while read fname
do
echo "rm $fname-2/lib" >>/data/cx.sh
done
awk -F" " '{print "mkdir /data/lib/"$1}' /data/packages.list >> /data/cx.sh
awk -F" " '{print "mv /data/data/"$1"/lib/ /data/lib/"$1"/"}' /data/packages.list >> /data/cx.sh
busybox chown -R 1000.1000 /data/lib
awk -F" " '{print "rm -R /data/data/"$1"/lib"}' /data/packages.list >> /data/cx.sh
cat /system/bin/noshare|while read fname
do
echo "rm -R $fname-2/lib" >>/data/cx.sh
done
chmod 0777 /data/cx.sh
/data/cx.sh
////////////////////////////////////////////////////移动第二系统数据为主数据
cat /system/bin/noshare|while read fname
do
mv $fname "$fname-1"
mv "$fname-2" $fname
done
cat /data/noshare|while read fname//移动不需要共享的数据
do
mv $fname "$fname-1"
mv "$fname-2" $fname
done
echo "Move data done!"
/////////////////////////同fixuid
awk -F" " '{print "ln -s /data/lib/"$1" /data/data/"$1"/lib"}' /data/packages.list > /data/cx.sh
cat /data/system/packages.xml | grep 'package name=\"'| awk -F"\"" '{print $2" "$18}' | awk -F" " '{print "busybox chown -R "$2"."$2" /data/data/"$1}' >> /data/cx.sh
chmod 0777 /data/cx.sh
/data/cx.sh
echo "Move UID done!"
reboot
Click to expand...
Click to collapse
What's this? I don't... I... can't comprehend...
Anyone able to make an auto script to help beginners and confused people like me? I can't follow through half of the OP's instructions.... not used to using SDK and terminal/ADB.

Woooow!! This is epic dude! I could have a Blur rom on my sd and a custom rom on my internal, to keep webtop functionality when i want! A Windows guide would be prettt awesome!
Sent from my MB860 using XDA

Amazing!
This is amazing!! Thanks a lot for your work!
This could make things MUCH easier for me when testing both CM9 and CM7 Neutrino.
I hope this project matures by the time my exams finish, like as Jokersax11 said, the ability to save dalvik cache would be awesome.
Massive thumbs up from me here

This really is some fantastic development! I am beyond impressed. You my friend should join the league of developer jedi's.
Fantastic work!
Now, if this could only somehow be transformed into a zip...LOL

J-Roc said:
This really is some fantastic development! I am beyond impressed. You my friend should join the league of developer jedi's.
Fantastic work!
Now, if this could only somehow be transformed into a zip...LOL
Click to expand...
Click to collapse
+1 for the ZIP and making this easier to use for the Ordinary good people like Some of Us
Amazing work ! Keep up

Thanks to your guide I've made it to cloning to sdcard all with windows. Will post back with tutorial if I can finish the job. Thank you for your amazing work!

Maybe you can work together with BootManager dev to support Atrix...

Dude, you're awesome. I think this is the final little push I needed to get me computer set up to dual boot Ubuntu and windows definitely going to be worth it now. Thanks for the work

KH_Lionheart said:
Dude, you're awesome. I think this is the final little push I needed to get me computer set up to dual boot Ubuntu and windows definitely going to be worth it now. Thanks for the work
Click to expand...
Click to collapse
You are quite welcome!

YouTube video (3:38) demonstrating reboot from one ROM to the other: http://www.youtube.com/watch?v=31TPyAguQ60

Sweet!
Seeing as how you had this on the back burner, I am SO glad you got those kernel building issues squashed. Awesome job man!

J-Roc said:
This really is some fantastic development! I am beyond impressed. You my friend should join the league of developer jedi's.
Fantastic work!
Now, if this could only somehow be transformed into a zip...LOL
Click to expand...
Click to collapse
tasadar said:
+1 for the ZIP and making this easier to use for the Ordinary good people like Some of Us
Amazing work ! Keep up
Click to expand...
Click to collapse
Here's the problem: I needed GApps on CM7 to provide the tools needed to support my experiment. However, Google has requested that copyrighted material be removed from CM7. So while I was able to streamline the integration of GApps with CM7, I could not provide the ROM, only the procedure. See http://forum.xda-developers.com/showthread.php?p=25588129#post25588129.
IDK, maybe Google will soften up a bit...?

Related

[SOLVED]help creating persistent swap partition.

I am using CyanogenMod v3.6.8.1 and I decided I wanted a swap partition.
I partitioned my 2GB SD with a 32MB swap partition and formatted using gparted.
From the shell (using adb) I remounted /dev/block/mtdblock3 with rw and edited /system/etc/fstab and added a line for the swap. Here is what the entire file looks like now:
Code:
/dev/block/mtdblock3 /system yaffs2 rw
/dev/block/mtdblock4 /cache yaffs2 rw
/dev/block/mtdblock5 /data yaffs2 rw
/dev/block/mmcblk0p1 /sdcard vfat rw
/dev/block/mmcblk0p2 /system/sd auto rw
/dev/block/mmcblk0p3 none swap sw
/system/modules/modules.sqf /system/modules squashfs ro,loop
/system/xbin/xbin.sqf /system/xbin squashfs ro,loop
I can turn on the swap with 'swapon -a' which works and shows up in /proc/swaps and with the 'free' command, but upon boot, swap isn't activating.
I'm not really familiar with the android init scripts, so I'm not sure how I can enable the swap automatically upon boot. Any advice would be appreciated.
Okay I fixed it.
I downloaded one of Drizzy's roms that I know use swap, extracted, and searched for 'swap' in all the files. I found it in /system/bin/a2sd at the end. Here is what's there:
Code:
if [ -n /dev/block/mmcblk0p3 ];
then
mkswap /dev/block/mmcblk0p3;
fi;
if [ -e /dev/block/mmcblk0p3 ];
then
echo 30 > /proc/sys/vm/swappiness;
swapon /dev/block/mmcblk0p3;
fi;
The first if doesn't make sense to me as it's a string test which will always be true, so I got rid of it and just kept the test for the file existing, but I changed it to -b to be a little more specific (to see if it's a block device), and I commented out the swappiness change to leave it at default.
Im using same rom and i woild love to do this but is there any other way as im totally unfamiliar with adb
turboyo said:
Im using same rom and i woild love to do this but is there any other way as im totally unfamiliar with adb
Click to expand...
Click to collapse
I just used adb because I can use the copy/paste function of my gnome terminal and it's easier than using the shell on the phone itself.
Here is what is needed:
Get into a root shell, either on the phone or using adb.
Code:
mount -t yaffs2 -o rw,remount /dev/block/mtdblock3 /system
vi /system/bin/a2sd
press capital G which will take you to the bottom of the file
press lower case o which will open a line below your cursor for editing.
type in the following:
Code:
if [ -b /dev/block/mmcblk0p3 ];
then
echo 30 > /proc/sys/vm/swappiness;
swapon /dev/block/mmcblk0p3;
fi;
press escape to exit insert mode (I read that in the terminal emulator you have to hold the trackball and press 1 for esc)
type :wq and press enter.
exit terminal and reboot. To see if it's working, get back into a terminal and use the command 'free'
you can also do 'swapon -a' instead of specifying the swap partition itself. Note that the above example uses the third partition of the SD card as the swap.
This also assumes you have already created the swap partition and formatted it as swap.
You can omit the swappiness line to leave it at the linux default of 60.

[BRAINSTORM] Booting directly into recovery

For reference, these are my thoughts on the matter.
We have 3 ways to do this:
1. Get hold of SBL, change it and flash it
Currently impossible afaik.
2. Get an init.d bash script to reboot into recovery if key is pressed
Most likely possible taking these 2 assumptions into account:
a) Bash allows to detect a pressed key, something like this:
Code:
_key()
{
local kp
ESC=$'\e'
_KEY=
read -d '' -sn1 _KEY
case $_KEY in
"$ESC")
while read -d '' -sn1 -t1 kp
do
_KEY=$_KEY$kp
case $kp in
[a-zA-NP-Z~]) break;;
esac
done
;;
esac
printf -v "${1:-_KEY}" "%s" "$_KEY"
}
_key x
case $x in
$'\e[15~') reboot recovery ;;
esac
Replacing this key code for one of OB's.
But for this, we need assumption number 2:
b) Key codes mapping is the same for recoveries.
Now, while this is the method of the greatest chance to work, it is also fairly useless. Developers will often break the boot before the init.d scripts are ran. So, this code should be ran before. Hence, the third method.
3. Start a custom service in init.rc (@ ramdisk) that will detect pressed key
This would be the perfect solution as it can't be broken from kernel (zImage) or system changes. However, init.rc has its own programming language (android init language) and there's no way to run this kind of listener.
However, it is possible to run an external script located for example in /system/bin/. These can be both an executable compiled from c (higher chances of working) or a bash scripting like the aforementioned one (lower chances of working since android probably doesn't start a console on boot).
Code for this would be something like:
Code:
service exampleservice /system/bin/exampleservice
user exampleservice
group exampleservice
oneshot
So uh, am I missing anything?
Anyone has other ideas?
a lot of times i heared about pressing "G" and "Power" would boot into some kind of save mode... if thats true i guess its easyer to reprogramm that keycombo to do something else... so does that keycombo anything? i couldnt figure out^^
Sent from my LG-P970 using XDA App
Are others devices has the key combination code in SBL?
I wish I have enough knowledge about android system so i can help...
i04055 said:
Are others devices has the key combination code in SBL?
I wish I have enough knowledge about android system so i can help...
Click to expand...
Click to collapse
Yes there are devices heaving the key-combo in SBL if that answers your question. The "Samsung Galaxy S GT-I9000" e.g. has them there afaik. With that device it was possible flashing the SBL to add a "booting directly into recovery" key-combo...
So I don´t know why there should not be a solution to do the same to the OB but Noejn surely has good reason for telling its impossible.
But hey what about booting into recovery on every system startup and only boot into the system through the recovery? It´s a "quick & dirty" solution even if its possible but better than developing the way we do isn´t it? I´m not sure if its easier to change the startup that way than to add or modify a key-combo but maybe someone here does?
I'm sure (or hope..) someone can, but perhaps we should move this Thread to another part of the Forum so someone with the knowledge how to do this will read it.
d0n22 said:
But hey what about booting into recovery on every system startup and only boot into the system through the recovery? It´s a "quick & dirty" solution even if its possible but better than developing the way we do isn´t it? I´m not sure if its easier to change the startup that way than to add or modify a key-combo but maybe someone here does?
Click to expand...
Click to collapse
Yeah, i prefer that way if poosibble rather than nothing.
But if put it that way, when the phone get bootloop is it still posibbe to boot into recovery?
Sent from my LG-P970 using XDA App
This is how it's done on Xperia X8 phone.
The /system/bin/chargemon is usb-charge daemon that is being hijacked on boot (it's binary is replaced with this script)
Original chargemon is copied into "charger" to keep it's functionality.
Than "sleep 3" waits for any keypress, and checks the dump, if keys were pressed, it launches the recovery binary.
quite simple.
Code:
#!/system/bin/busybox sh
/system/bin/charger
cat /dev/input/event1 > /dev/keycheck&
sleep 3
kill -9 $!
if [ -s /dev/keycheck -o -f /data/local/tmp/xrecovery ]
then
rm -f /data/local/tmp/xrecovery
# remount rootfs rw
mount -o remount,rw rootfs /
# Umount MTDs
umount -l /dev/block/mtdblock1
umount -l /dev/block/mtdblock2
umount -l /dev/block/mtdblock3
# Mount recovery partition
cd /
rm -r /sbin
rm -f etc
tar -xf /system/bin/xrecovery.tar
# Umount /system
umount -l /dev/block/mtdblock0
# chroot
chroot / /init
fi
# remount rootfs rw
mount -o remount,rw rootfs /
chmod 0777 /dev -R
chown 0.2000 /dev/oncrpc -R
cd /
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/ramdisk.tar
mkdir -p /minicm
cd /minicm
tar -xf /system/bin/ramdisk.tar
# Umount /system, data and cache
umount -l /dev/block/mtdblock0
umount /dev/block/mtdblock3
umount /dev/block/mtdblock1
rmdir /system /data /cache /mnt
racht said:
This is how it's done on Xperia X8 phone.
The /system/bin/chargemon is usb-charge daemon that is being hijacked on boot (it's binary is replaced with this script)
Original chargemon is copied into "charger" to keep it's functionality.
Than "sleep 3" waits for any keypress, and checks the dump, if keys were pressed, it launches the recovery binary.
quite simple.
Code:
#!/system/bin/busybox sh
/system/bin/charger
cat /dev/input/event1 > /dev/keycheck&
sleep 3
kill -9 $!
if [ -s /dev/keycheck -o -f /data/local/tmp/xrecovery ]
then
rm -f /data/local/tmp/xrecovery
# remount rootfs rw
mount -o remount,rw rootfs /
# Umount MTDs
umount -l /dev/block/mtdblock1
umount -l /dev/block/mtdblock2
umount -l /dev/block/mtdblock3
# Mount recovery partition
cd /
rm -r /sbin
rm -f etc
tar -xf /system/bin/xrecovery.tar
# Umount /system
umount -l /dev/block/mtdblock0
# chroot
chroot / /init
fi
# remount rootfs rw
mount -o remount,rw rootfs /
chmod 0777 /dev -R
chown 0.2000 /dev/oncrpc -R
cd /
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/ramdisk.tar
mkdir -p /minicm
cd /minicm
tar -xf /system/bin/ramdisk.tar
# Umount /system, data and cache
umount -l /dev/block/mtdblock0
umount /dev/block/mtdblock3
umount /dev/block/mtdblock1
rmdir /system /data /cache /mnt
Click to expand...
Click to collapse
yeah ,from this we can see what is running before logo screen and we can mod that file
so.. is that mean we can boot to recovery mode same as x8?
racht said:
This is how it's done on Xperia X8 phone.
The /system/bin/chargemon is usb-charge daemon that is being hijacked on boot (it's binary is replaced with this script)
Original chargemon is copied into "charger" to keep it's functionality.
Than "sleep 3" waits for any keypress, and checks the dump, if keys were pressed, it launches the recovery binary.
quite simple.
Code:
#!/system/bin/busybox sh
/system/bin/charger
cat /dev/input/event1 > /dev/keycheck&
sleep 3
kill -9 $!
if [ -s /dev/keycheck -o -f /data/local/tmp/xrecovery ]
then
rm -f /data/local/tmp/xrecovery
# remount rootfs rw
mount -o remount,rw rootfs /
# Umount MTDs
umount -l /dev/block/mtdblock1
umount -l /dev/block/mtdblock2
umount -l /dev/block/mtdblock3
# Mount recovery partition
cd /
rm -r /sbin
rm -f etc
tar -xf /system/bin/xrecovery.tar
# Umount /system
umount -l /dev/block/mtdblock0
# chroot
chroot / /init
fi
# remount rootfs rw
mount -o remount,rw rootfs /
chmod 0777 /dev -R
chown 0.2000 /dev/oncrpc -R
cd /
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/ramdisk.tar
mkdir -p /minicm
cd /minicm
tar -xf /system/bin/ramdisk.tar
# Umount /system, data and cache
umount -l /dev/block/mtdblock0
umount /dev/block/mtdblock3
umount /dev/block/mtdblock1
rmdir /system /data /cache /mnt
Click to expand...
Click to collapse
soundes quite promising... have you tried it?
Can this be usefull?
http://forum.xda-developers.com/showthread.php?t=991276
Noejn have you abandoned us ? Or are u planning to take a look at this ? Would be nice if u get OB up and running
recovery
Hi,
has there been any success with booting into recovery mode?
BR,
J
logitec said:
Hi,
has there been any success with booting into recovery mode?
BR,
J
Click to expand...
Click to collapse
No,I try to boot directly into recovery through boot.img,but I get a big "error" form the LG Security Team!
Hijacking a daemon would work if Optimus Black had those binaries. I took a quick glance at a backup and I didn't see chargemon in /system/bin.
Besides, a xRecovery is limited as it's dependent on system files so a /format can't be done which isn't really that "comfy", especially when changing fs.
But yeah, better than nothing. Still, the method you described is only possible in Xperia phones, as far as I know.
I still say injecting a service on the init.rc is the way to go.
However, I can't test this now.
racht said:
This is how it's done on Xperia X8 phone.
The /system/bin/chargemon is usb-charge daemon that is being hijacked on boot (it's binary is replaced with this script)
Original chargemon is copied into "charger" to keep it's functionality.
Than "sleep 3" waits for any keypress, and checks the dump, if keys were pressed, it launches the recovery binary.
quite simple.
Code:
#!/system/bin/busybox sh
/system/bin/charger
cat /dev/input/event1 > /dev/keycheck&
sleep 3
kill -9 $!
if [ -s /dev/keycheck -o -f /data/local/tmp/xrecovery ]
then
rm -f /data/local/tmp/xrecovery
# remount rootfs rw
mount -o remount,rw rootfs /
# Umount MTDs
umount -l /dev/block/mtdblock1
umount -l /dev/block/mtdblock2
umount -l /dev/block/mtdblock3
# Mount recovery partition
cd /
rm -r /sbin
rm -f etc
tar -xf /system/bin/xrecovery.tar
# Umount /system
umount -l /dev/block/mtdblock0
# chroot
chroot / /init
fi
# remount rootfs rw
mount -o remount,rw rootfs /
chmod 0777 /dev -R
chown 0.2000 /dev/oncrpc -R
cd /
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/ramdisk.tar
mkdir -p /minicm
cd /minicm
tar -xf /system/bin/ramdisk.tar
# Umount /system, data and cache
umount -l /dev/block/mtdblock0
umount /dev/block/mtdblock3
umount /dev/block/mtdblock1
rmdir /system /data /cache /mnt
Click to expand...
Click to collapse
Good news, I'm getting close.
ok, thank you for everithing
Noejn said:
Good news, I'm getting close.
Click to expand...
Click to collapse
good news indeed^^ im working on it as well but im not feeling like getting close :-\ pls let me know what you did and how you did it as soon as its done... again thank you very much for your efforts!
Sent from my LG-P970 using XDA App
d0n22 said:
good news indeed^^ im working on it as well but im not feeling like getting close :-\ pls let me know what you did and how you did it as soon as its done... again thank you very much for your efforts!
Sent from my LG-P970 using XDA App
Click to expand...
Click to collapse
Well, I've succeed injecting the script on boot.
However, I'm getting some problems on the event0 > keycheck; I don't think at this time of boot /dev entries are up.
But I've already thought of a workaround and I'll test it tomorrow.
I´m thinking, if i compile kernel of ubuntu and install it in recovery partition, not possible then run ubuntu in native mode from sdcard with dualboot?

Re-enabling ext4 journaling in ROMs based on Stock

Hey there,
it's known that ext4 with disabled journaling is little faster than default, but it is also less reliable.
This can result in screwed up homescreens and force-closes after reboot/shutdown/battery pull.
I have successfully re-enabled journaling for system and cache partition, but it seems not to work correctly for data partition, at least for me. Can you help?
Code:
echo ..............system Partition...............
/sbin/busybox umount -l /system
/sdcard/tmp/tune2fs -O +has_journal -c 5 -i 5d -m 0 -o journal_data_ordered /dev/block/mmcblk0p1
fsck.ext4 -Dfy /dev/block/mmcblk0p1
/sbin/busybox mount -t ext4 -o nosuid,nodev,noatime,nodiratime,barrier=0,nobh,data=ordered,noauto_da_alloc /dev/block/mmcblk0p1 /system
echo ...............done...............
echo ...............cache Partition...............
/sbin/busybox umount -l /cache
/sdcard/tmp/tune2fs -O +has_journal -c 100 -i 100d -m 0 -o journal_data_writeback /dev/block/mmcblk0p2
fsck.ext4 -Dfy /dev/block/mmcblk0p2
/sbin/busybox mount -t ext4 -o nosuid,nodev,noatime,nodiratime,barrier=0,nobh,data=ordered,noauto_da_alloc /dev/block/mmcblk0p2 /cache
echo ...............done...............
echo ...............data Partition...............
/sbin/busybox umount -l /data
/sdcard/tmp/tune2fs -O +has_journal -c 5 -i 5d -m 0 -o journal_data_ordered /dev/block/mmcblk0p8
fsck.ext4 -Dfy /dev/block/mmcblk0p8
/sbin/busybox mount -t ext4 -o nosuid,nodev,noatime,nodiratime,barrier=0,nobh,data=ordered,noauto_da_alloc /dev/block/mmcblk0p8 /data
sync
echo ...............done...............
Semi-finished:
Flash journaling.zip via CWM to enable back journaling
Download
Download 'terminal emulator' from market and type the following to test if it works.
If 'has_journal' is present then journaling is enabled.
For /system
Code:
/system/bin/tune2fs -l /dev/block/mmcblk0p1 | grep features
For /cache
Code:
/system/bin/tune2fs -l /dev/block/mmcblk0p2 | grep features
For /data
Code:
/system/bin/tune2fs -l /dev/block/mmcblk0p8 | grep features
Please post feedback if it works for you (fully)!
nice good work!
Thanks!
Another easy, though more time consuming, way to re-enable journaling is to let CWM do it by a complete backup and restore.
(You can also switch between ext3 and ext4 by changing the file names in clockworkmod/backup/.../ and of course also in the nandroid.md5 file.)
Please post feedback if it works for you (especially for data partition)

[script] [init.d] aNu_d2sd - data to sdcard

Features:
- Move only 3rd-party-apps/user-apps and its data to sdcard
- System-apps data (contacs,sms etc) are pretty much intact in-case of sdcard failure or removed so your phone is not rendered useless
- Install as many apps as you like (limited by your /sd-ext size), your internal data usage will remain around 40~45mb
Mechanism in general:
- mount /sd-ext
- copy selected /data directories ( app, data, dalvik-cache etc) to /sd-ext
- bind /data directories to /sd-ext directories ( not the /data it self )
- create new directories for system-apps-data in /data
- move system-apps-data to new directories in /data and sysmlink it
Requirement:
- Init.d supported rom
- Busybox
- primary linux formated 2nd partition on sdcard
- Root: only needed if not using recovery flashable zip
Installation:
- DWYOR, remember to backup first
- NOT WORKING with device already running similar init.d script ( but it might work if its only using bind mounts ),
- disable or remove it ( mountext, mountsd, ad2sd etc), then wipe if necessary
- flash the zip from CWM/Stock recovery mode
or
- manually put it in /system/etc/init.d
- set permission: 0750
- set owner: root group: shell
Important:
- Will effectively work after the second boot.
- DO NOT remove sd-card while system is running
- Curently TESTED only on mini and young with stock gb, possibly working on any device/version
Example script usage:
Called in mountext script (modified cm7 script):
Filename: 05mountext
Code:
#!/system/bin/sh
#
# mount sd-ext partition in sdcard
# mod: use aNu_d2sd functions library script
#
# anuneanu
logI="log -p i -t mountext"
logE="log -p e -t mountext"
E2FSCK=`which e2fsck`
[ `which busybox` = "" ] && exit || BB=`which busybox`
[ "$SD_EXT_DIRECTORY" = "" ] && SD_EXT_DIRECTORY="/sd-ext"
# call aNu_d2sd function library script
. "/system/etc/init.d/99aNu_d2sd"
# find sd-ext partition
for MMC_NUM in `seq 0 9`; do
MMC_TYPE=`cat /sys/block/mmcblk$MMC_NUM/device/type`
if [ "$MMC_TYPE" = "SD" ]; then
SD_EXT_PART=/dev/block/mmcblk${MMC_NUM}p2
break
fi
done
# mount sd-ext if a valid partition was found
if [ -b "$SD_EXT_PART" ]; then
# check sd-ext filesystem
if [ -x "$E2FSCK" ]; then
$logI "checking $SD_EXT_PART for errors..."
$E2FSCK -p $SD_EXT_PART
e2fsk_exitcode=$?
else
$logE "executable e2fsck not found, assuming no filesystem errors"
e2fsk_exitcode=0
fi
# mount sd-ext partition
if [ $e2fsk_exitcode -le 2 ]; then
if [ $($BB grep -c ext4 /proc/filesystems) -ne 0 ]; then
mount_opt="-t ext4 -o noauto_da_alloc,data=ordered,commit=15,barrier=1,nouser_xattr,errors=continue,noatime,nodiratime,nosuid,nodev"
else
mount_opt="-t auto -o nosuid,nodev"
fi
$BB mount $mount_opt $SD_EXT_PART $SD_EXT_DIRECTORY
if [ $? -eq 0 ]; then
$BB chown 1000:1000 $SD_EXT_DIRECTORY
$BB chmod 0771 $SD_EXT_DIRECTORY
$logI "$SD_EXT_DIRECTORY successfully mounted"
aNu_d2sd "/data/app* /data/data /data/dalvik-cache /data/local"
else
$logE "unable to mount filesystem for $SD_EXT_DIRECTORY!"
no_sdext=1
fi
else
$logE "e2fsck returned error $e2fsk_exitcode"
$logE "unable to repair ext partition...not mounting"
no_sdext=1
fi
else
$logI "linux partition not found on sdcard"
no_sdext=1
fi
aNu_d2sd_restore $no_sdext
$BB sync
exit
Download:
Flashable zip :
updated (22-03-2013) : View attachment aNu_d2sd.zip
Source
Any response would be much appreciated, thanks
Pertamax..!!
Testing..Testing..
fendytrancers89 said:
Pertamax..!!
Testing..Testing..
Click to expand...
Click to collapse
there is typo in function file line 27 column 56, preventing it from creating system dalvik-cache.
the download file has been updated, please grab the new one.

[WIP] Swap in CM 11/12

We have started this discussion in Mentor.37's [RECOVERY]Safestrap 3.75 for unused partitions thread and I decided to create a new thread for it.
Why swap?
Since D4 is low on RAM, especially for Lollipop (CM12), idea of having the system swap out some data instead of closing all apps but the one I currently use seems appealing to me, even for the trade-out of slowing the system down a bit when loading. More comprehensive (dated, but still valid) information on whether to use swap can be gathered from this article: Why Android Swap Doesn’t Make Sense. While even its name suggests you shouldn't swap in Android, the conclusion works in favor of trying swap in my installation of Lollipop where system and background apps eat up over 75% of RAM straight after boot:
Jeffrey Blattman said:
And here’s a few counter arguments that I can imagine,
1. The native Android memory management scheme is there for apps, but not for other processes. That is, having swap allows the many processes that run to support the Linux operating system to be moved out of physical memory.
Click to expand...
Click to collapse
Also in comments there are some persuasive arguments in favor of swapping, such as not having to reload content of apps (especially browsers) after they get killed off by Android. In my use, this is crucial when I'm without Internet connection for some time.
Current status: swapping works, but I have mixed feelings on whether it helps or not. It needs more tinkering with swappiness to find the right value, CM12's default of 60 is way too high.
Script for automated install and init with swappiness parameter in post #2
@Milp's original post:
Milp said:
I placed 550mb swap files in both /webtop and /preinstall (mounted under storage), also smaller ones in cache, system and data. Swapped on all of them, it's like a brand new phone now, speed wise.
Using 40 swappiness. cm11.
I created the swap files in an app called swapper and moved them to the locations. If anyone is interested in the swapon script for smanager, i can post it here.
somehow using dd with if=/dev/null did not work and filling those files with /dev/urandom didn't let me swap on them.
I don't know if its a good test for how fast things got, but i'm now able to watch a 720p video in the desktop site of youtube in firefox with 3 addons. It plays fluently.
Hope this is the right place for it, not sure whether it deserves it's own thread.
Click to expand...
Click to collapse
My next post, summing up how I got there. I've been running the system like this for over a day, with mixed feelings about result.
Milp said:
I placed 550mb swap files in both /webtop and /preinstall (mounted under storage), also smaller ones in cache, system and data. Swapped on all of them, it's like a brand new phone now, speed wise.
Click to expand...
Click to collapse
Great idea, inspired me to this little adventure (CM12 in system slot):
Putting swap file to cache partition (as it's 1 GB and using under 30 MB) and making preinstall swap:
Code:
/ # tar -cv /cache | gzip > /sdcard/cache.tar.gz
/ # dd if=/dev/zero of=/cache/swap bs=1024 count=819200
/ # mkswap /cache/swap
/ # swapon /cache/swap
/ # mkswap /dev/block/preinstall
/ # swapon /dev/block/preinstall
Now we need to make this mapping persistent - let's use /data/local/userinit.sh (don't forget to chmod 755 userinit.sh after you create it):
Code:
#!/system/bin/sh
swapon /cache/swap
swapon /dev/block/preinstall
This should run on startup (invoked by /system/etc/init.d/90userinit). It doesn't and I don't know why (yet), so I use SManager instead.
Results:
Not much tested, but it looks like it works. I ran CG Transit (offline timetables for Czech public transport) and then Hill Climb Racing (only resource-heavy game I have installed), which would usually kill off everything else, making the timetables forget its state. This didn't happen and switching out of the game felt a bit snappier, woohoo We'll see after some time though, this may be just me REALLY wanting this to help.
Code:
/ # free
free
total used free shared buffers
Mem: 859572 845284 14288 0 3336
-/+ buffers: 841948 17624
Swap: 1441784 66716 1375068
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
@Milp what script do you use? How exactly did you create your swap files?
To revert preinstall back to ext3 if you don't want to use it as swap anymore (it's been formatted as swap by mkswap):
Code:
/ # mke2fs /dev/block/preinstall
/ # tune2fs -j /dev/block/preinstall
(following is not finished)
Using webtop as dalvik-cache (and backup in case something goes wrong after restart):
Code:
/data # mv dalvik-cache/ dalvik-cache-old
/data # mkdir dalvik-cache
/data # mount -t ext4 /dev/block/webtop /data/dalvik-cache
/data # rm -rf dalvik-cache/*
/data # cp -r dalvik-cache-old/* dalvik-cache/
/data # rm -rf dalvik-cache-old/
/data # tar -cv dalvik-cache/ | gzip > /sdcard/dalvik-cache.tar.gz
Then it's needed to be mounted when startup. My initial attempt utilizing /data/local/userinit.sh failed, will need to edit ramdisk for this to work :/ Not today.
Random info about my system for understanding why did I also move dalvik cache elsewhere:
Tip: I use SSHDroid to easily ssh to device. adb shell doesn't suit me, especially for its lack of completing paths. And to have it nice and colorful, this is my first command: su -c bash
Code:
/ # cat /proc/partitions
major minor #blocks name alias
7 0 27160 loop0
7 1 25068 loop1
7 2 22980 loop2
7 5 35516 loop5
7 6 43872 loop6
7 7 4096 loop7
179 0 15552512 mmcblk1
179 1 128 mmcblk1p1
179 2 512 mmcblk1p2
179 3 512 mmcblk1p3
179 4 1 mmcblk1p4
179 5 512 mmcblk1p5
179 6 512 mmcblk1p6
179 7 4096 mmcblk1p7 pds
179 8 512 mmcblk1p8 utags
179 9 1024 mmcblk1p9
179 10 2048 mmcblk1p10
179 11 512 mmcblk1p11
179 12 512 mmcblk1p12
179 13 4096 mmcblk1p13
179 14 8192 mmcblk1p14 boot
179 15 9216 mmcblk1p15 recovery
179 16 217088 mmcblk1p16 cdrom
179 17 512 mmcblk1p17 misc
179 18 512 mmcblk1p18 cid
179 19 4096 mmcblk1p19 kpanic
179 20 655360 mmcblk1p20 system
179 21 1048576 mmcblk1p21 cache
179 22 622592 mmcblk1p22 preinstall
179 23 1364992 mmcblk1p23 webtop
179 24 3203072 mmcblk1p24 userdata
179 25 8401792 mmcblk1p25 emstorage
179 26 128 mmcblk1p26
179 32 62367744 mmcblk0
179 33 62366720 mmcblk0p1
254 0 27160 dm-0
254 1 25068 dm-1
254 2 22980 dm-2
254 5 35516 dm-5
254 6 43872 dm-6
7 8 21936 loop8
254 7 21936 dm-7
7 9 22980 loop9
254 8 22980 dm-8
7 10 28204 loop10
254 9 28204 dm-9
7 11 40736 loop11
254 10 40736 dm-10
7 12 5224 loop12
254 11 5224 dm-11
7 13 11492 loop13
254 12 11492 dm-12
7 14 10448 loop14
254 13 10448 dm-13
7 16 42824 loop16
254 15 42824 dm-15
Code:
/data # du -sh *
4.0K adb
6.6M anr
703.4M app
4.0K app-asec
4.0K app-lib
4.0K app-private
4.0K ash_history
116.0K backup
12.0K battd
0 bugreports
0 chargeonlymode
1.0G dalvik-cache
441.6M data
288.0K dontpanic
8.0K download
20.0K drm
4.0K emt
32.0K kernelpanics
32.0K local
4.0K location
84.0K logger
20.0K lost+found
12.0K media
20.0K mediadrm
1.6M misc
8.0K panicreports
4.0M pdsdata.img
44.0K property
4.0K resource-cache
4.0K security
24.0K ssh
4.3M system
16.0K tmp
5.1M tombstones
16.0K tpapi
4.0K user
Code:
/ # df
Filesystem Size Used Free Blksize
/dev 419.7M 60.0K 419.7M 4096
/sys/fs/cgroup 419.7M 12.0K 419.7M 4096
/mnt/asec 419.7M 0.0K 419.7M 4096
/mnt/obb 419.7M 0.0K 419.7M 4096
/system 636.7M 604.2M 32.5M 1024
/data 3.0G 2.2G 798.2M 4096
/cache 1007.9M 33.4M 974.5M 4096
/pds 3.9M 1.1M 2.8M 1024
/storage/sdcard0 8.0G 2.9G 5.1G 8192
/mnt/media_rw/sdcard0 8.0G 2.9G 5.1G 8192
/mnt/secure/asec 59.5G 58.0G 1.5G 32768
/mnt/media_rw/sdcard1 59.5G 58.0G 1.5G 32768
/mnt/secure/asec 59.5G 58.0G 1.5G 32768
/mnt/media_rw/sdcard0/.android_secure 59.5G 58.0G 1.5G 32768
/storage/sdcard1 59.5G 58.0G 1.5G 32768
[asec stripped]
Milp's response showing how did he approach the swapping problem, including setting swappiness to 15:
Milp said:
Hi there, I'm using the following code. I'm using some random app to create swapfiles since dd doesn't work for me with if=/dev/null, it creates 0byte files. And swapping on a file filled with /dev/urandom doesn't seem to work. No idea how else i could go about that.
Code:
#!/system/bin/sh
echo start > /storage/sdcard0/swap.log 2>&1
echo mountstuff > /storage/sdcard0/swap.log 2>&1
umount /preinstall >> /storage/sdcard0/swap.log 2>&1
mount -o rw,remount / >> /storage/sdcard0/swap.log 2>&1
rm -r preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/webtop >> /storage/sdcard0/swap.log 2>&1
mount -o ro,remount / >> /storage/sdcard0/swap.log 2>&1
mount -t ext3 /dev/block/preinstall /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mount -t ext4 /dev/block/webtop /storage/webtop >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/webtop >> /storage/sdcard0/swap.log 2>&1
echo swappiness...15 >> /storage/sdcard0/swap.log 2>&1
echo 15 1> /proc/sys/vm/swappiness 2>> /storage/sdcard0/swap.log
echo cping... >> /storage/sdcard0/swap.log >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
mount -o remount,rw /dev/block/system /system >> /storage/sdcard0/swap.log 2>&1
swapon /system/swap.swp >> /storage/sdcard0/swap.log 2>&1
echo swappingon... >> /storage/sdcard0/swap.log 2>&1
swapon /storage/sdcard0/Swapper/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/webtop/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /data/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1[/HIDE]
This might not be too good of a batch script, but i've never before in my life made linux batch scripts, I'm happy it works. I use smanager to execute it on boot.
There is a pre-created 100mb swapfile in /storage/sdcard0/Swapper/swap.swp that gets copied to /cache/ and /storage/preinstall/, since the files there seem to get wiped regularily.
Of course swapping on sdcard0 does not work since sdcard0 does not support permissions (fat?), i was just too lazy to remove it. A logfile is generated in sdcard0 called swap.log.
Been messing around with the swappiness a lot. 30-40 swappiness really enhances multitasking but the phone seems to get slow after some time because it has to do a lot of swap io i guess. Trying 15 now.
Click to expand...
Click to collapse
In the next post I'll elaborate on the scripts and hopefully upload nice automatic scripts here You still need to use SManager to run them though.
Script for creating and running swap in /cache attached.
Whole script init.sh:
Code:
#!/system/bin/sh
date >> /data/swap/swap-init.log 2>&1
echo "Initializing swap." >> /data/swap/swap-init.log 2>&1
if [ ! -f /cache/swap ]; then # when /cache/swap is not present
echo "Swap file not found, creating it." >> /data/swap/swap-init.log 2>&1
date >> /data/swap/swap-setup.log 2>&1
echo "Creating swap file as it was not present." >> /data/swap/swap-setup.log 2>&1
echo "Space in /cache:" >> /data/swap/swap-setup.log 2>&1
df /cache >> /data/swap/swap-setup.log 2>&1
freeCache=$(busybox df -k /cache | tail -1 | awk '{ print $4 }')
let swapSize=freeCache*80/100 # count 80% of free space in /cache
echo "Creating ${swapSize} KB swap file." >> /data/swap/swap-setup.log 2>&1
dd if=/dev/zero of=/cache/swap bs=1024 count=$swapSize >> /data/swap/swap-setup.log 2>&1 # create swap file called swap in /cache that takes up 80% of its free space.
mkswap /cache/swap >> /data/swap/swap-setup.log 2>&1 # format the previously created 'swap' file for swap, just as you'd do with a partition
echo "Creation of the swap file completed." >> /data/swap/swap-setup.log 2>&1
date >> /data/swap/swap-setup.log 2>&1
fi
if [ ! -f /data/swap/swappines.txt ]; then
echo 15 1> /proc/sys/vm/swappiness 2>> /data/swap/swap-init.log # set swappiness 15
else
cat /data/swap/swappiness.txt 1> /proc/sys/vm/swappiness 2>> /data/swap/swap-init.log # set swappiness as in swappiness.txt - PUT THERE ONLY NUMS 1-99!
fi
swapon /cache/swap >> /data/swap/swap-init.log 2>&1 # use the swap file created in the installation script for swap
echo "Swap initialization done." >> /data/swap/swap-init.log 2>&1
date >> /data/swap/swap-init.log 2>&1
Usage:
Extract init.sh (and optionally swappiness.txt as well) to /data/swap/
Setup SManager to run it on boot: View attachment 3397902 (don't forget to hit the top-right SAVE button after you select Su and Boot)
Run it manually for first-time init (if you don't, the next boot will be pretty slow)
It will create the swap file on the first run, utilizing 80% of free space in the /cache partition. It's better to do step 3 - run it manually first, so it doesn't compete for system resources with other stuff starting on boot. It took me over five minutes to create the swap file on boot, compared to about two minutes when the system was already running. While creating, it eats up system resources and blocks other apps -> wait 5+ mins for it to finish. You have been warned If it fails for whatever reason, just delete the /cache/swap file and run it again. It writes a huge file (about 750M) while everything else competes for the flash memory read and write which is why it's so slow at boot.
My setup log:
Code:
Thu Jul 9 23:46:53 CEST 2015
Creating swap file as it was not present.
Space in /cache:
Filesystem Size Used Free Blksize
/cache 1007.9M 33.3M 974.6M 4096
Creating 756409 KB swap file.
756409+0 records in
756409+0 records out
774562816 bytes transferred in 301.058 secs (2572802 bytes/sec)
Creation of the swap file completed.
Thu Jul 9 23:51:59 CEST 2015
The script logs inits to /data/swap/swap-init.log and the setup (creation of the swap file) to /data/swap/swap-setup.log. It sets swappiness to 15 or whatever you have in /data/swap/swappiness.txt (if it's missing, it defaults to 15).
If you want to see whether it's done creating the swap file yet, either watch the /cache/swap file grow (i.e. over SCP) or watch the setup log grow (tail -f /data/swap/swap-setup.log in shell, wait for the "Creation of the swap file completed." text to appear and then exit tail by Ctrl+C).
If you have set your SELinux to permissive state, you can save init.sh as /data/local/userinit.sh and don't need SManager at all - it will be run by CM itself. Make sure to create the /data/swap folder though so the logs can be saved, otherwise it may exit on error.
Milp said:
Hi there, I'm using the following code. I'm using some random app to create swapfiles since dd doesn't work for me with if=/dev/null, it creates 0byte files.
Click to expand...
Click to collapse
Works with if=/dev/zero
Milp said:
And swapping on a file filled with /dev/urandom doesn't seem to work. No idea how else i could go about that.
Click to expand...
Click to collapse
Well, did you format the file for swap using mkswap?
Milp said:
Code:
#!/system/bin/sh
echo start > /storage/sdcard0/swap.log 2>&1
echo mountstuff > /storage/sdcard0/swap.log 2>&1
umount /preinstall >> /storage/sdcard0/swap.log 2>&1
mount -o rw,remount / >> /storage/sdcard0/swap.log 2>&1
rm -r preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mkdir /storage/webtop >> /storage/sdcard0/swap.log 2>&1
mount -o ro,remount / >> /storage/sdcard0/swap.log 2>&1
mount -t ext3 /dev/block/preinstall /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
mount -t ext4 /dev/block/webtop /storage/webtop >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/preinstall >> /storage/sdcard0/swap.log 2>&1
chmod 777 /storage/webtop >> /storage/sdcard0/swap.log 2>&1
echo swappiness...15 >> /storage/sdcard0/swap.log 2>&1
echo 15 1> /proc/sys/vm/swappiness 2>> /storage/sdcard0/swap.log
echo cping... >> /storage/sdcard0/swap.log >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
cp /storage/sdcard0/Swapper/swap.swp /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
chmod 666 /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/preinstall/swap.swp >> /storage/sdcard0/swap.log 2>&1
mount -o remount,rw /dev/block/system /system >> /storage/sdcard0/swap.log 2>&1
swapon /system/swap.swp >> /storage/sdcard0/swap.log 2>&1
echo swappingon... >> /storage/sdcard0/swap.log 2>&1
swapon /storage/sdcard0/Swapper/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /storage/webtop/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /data/swap.swp >> /storage/sdcard0/swap.log 2>&1
swapon /cache/swap.swp >> /storage/sdcard0/swap.log 2>&1[/HIDE]
This might not be too good of a batch script, but i've never before in my life made linux batch scripts, I'm happy it works. I use smanager to execute it on boot.
There is a pre-created 100mb swapfile in /storage/sdcard0/Swapper/swap.swp that gets copied to /cache/ and /storage/preinstall/, since the files there seem to get wiped regularily.
Click to expand...
Click to collapse
I'm not advanced in batch scripting either, but this looks fine to me for your purpose. Holy Mother of Logging though However, the first "start" won't be in the log and log gets overwritten each run - you use > (save to file) instead of >> (append to file) in first two lines.
Milp said:
Of course swapping on sdcard0 does not work since sdcard0 does not support permissions (fat?), i was just too lazy to remove it. A logfile is generated in sdcard0 called swap.log.
Click to expand...
Click to collapse
All this is quite heavy approach, may I suggest mine?
To put it into shell script format:
One-time installation:
Code:
#!/system/bin/sh
dd if=/dev/zero of=/cache/swap bs=1024 count=819200 # create 800 MB swap file called swap in /cache (this is for systems running in stock slot where there's 1GB partition for cache that's almost not used - adjust size (count=<size in KB>) for your system). I didn't experience any deletion of this. If you do like Milp did, just re-run this script.
mkswap /cache/swap # format the previously created 'swap' file for swap, just as you'd do with a partition
swapon /cache/swap # use this file as swap
umount /preinstall # not needed in CM12, it's not mounted (the folder is there though). Let's do it for legacy compatibility though :)
mkswap /dev/block/preinstall # format the whole /preinstall partition as swap so we don't have to deal with stupid deletions or mounts or whatever later
swapon /dev/block/preinstall # use preinstall as swap (this is kinda like mount for swap partition/device)
I didn't use any logging as I run these over ssh or from adb shell so I can see stdout and stderr. If you wish to, you can add Milp's >> /storage/sdcard0/swap.log 2>&1 at the end of each line before my comments:
Code:
#!/system/bin/sh
date >> /storage/sdcard0/swap-setup.log 2>&1
echo "Swap files installation started." >> /storage/sdcard0/swap-setup.log 2>&1
dd if=/dev/zero of=/cache/swap bs=1024 count=819200 >> /storage/sdcard0/swap-setup.log 2>&1 # create 800 MB swap file called swap in /cache (this is for systems running in stock slot where there's 1GB partition for cache that's almost not used - adjust size (count=<size in KB>) for your system). I didn't experience any deletion of this. If you do like Milp did, just re-run this script.
mkswap /cache/swap >> /storage/sdcard0/swap-setup.log 2>&1 # format the previously created 'swap' file for swap, just as you'd do with a partition
swapon /cache/swap >> /storage/sdcard0/swap-setup.log 2>&1 # use this file as swap
umount /preinstall >> /storage/sdcard0/swap-setup.log 2>&1 # not needed in CM12, it's not mounted (the folder is there though). Let's do it for legacy compatibility though :)
mkswap /dev/block/preinstall >> /storage/sdcard0/swap-setup.log 2>&1 # format the whole /preinstall partition as swap so we don't have to deal with stupid deletions or mounts or whatever later
swapon /dev/block/preinstall >> /storage/sdcard0/swap-setup.log 2>&1 # use preinstall as swap (this is kinda like mount for swap partition/device)
echo "Swap files installation finished." >> /storage/sdcard0/swap-setup.log 2>&1
date >> /storage/sdcard0/swap-setup.log 2>&1
Then you need this script running on boot, I use smanager as well:
Code:
#!/system/bin/sh
swapon /cache/swap # use the swap file created in the installation script for swap
swapon /dev/block/preinstall # use preinstall as swap
echo 15 > /proc/sys/vm/swappiness # set swappiness 15
Version with logs:
Code:
#!/system/bin/sh
date >> /storage/sdcard0/swap-init.log 2>&1
echo "Initializing swap." >> /storage/sdcard0/swap-init.log 2>&1
swapon /cache/swap >> /storage/sdcard0/swap-init.log 2>&1 # use the swap file created in the installation script for swap
swapon /dev/block/preinstall >> /storage/sdcard0/swap-init.log 2>&1 # use preinstall as swap
echo 15 1> /proc/sys/vm/swappiness 2>> /storage/sdcard0/swap-init.log # set swappiness 15
echo "Swap initialization done." >> /storage/sdcard0/swap-init.log 2>&1
date >> /storage/sdcard0/swap-init.log 2>&1
Milp said:
Been messing around with the swappiness a lot. 30-40 swappiness really enhances multitasking but the phone seems to get slow after some time because it has to do a lot of swap io i guess. Trying 15 now.
Click to expand...
Click to collapse
CM12's default is 60, which is way too much - after day of use I have sometimes been unable even to unlock the phone as seemingly the lock screen has been swapped away and it took several wakings of the phone before it allowed me to swipe the lockscreen up (I don't use any lock protection, just plain swipable lockscreen). It even worsened with Poweramp's custom lockscreen.
Will toy around with it for a bit in upcoming days.
I don't think I have ever gotten much over 300 MB swapped, making my current combined of almost 1,5 GB swap huge overkill. Will see after some time, but the /cache/swap file should be very sufficient and there's no need to mess up preinstall
I'm testing swap on stock 4.1.2 and I'm using app called Roehsoft Ram-Expander (I bougth this when I was xperia user). Seems to work but I'm wondering if the app is necessary.
Borchuck said:
I'm testing swap on stock 4.1.2 and I'm using app called Roehsoft Ram-Expander (I bougth this when I was xperia user). Seems to work but I'm wondering if the app is necessary.
Click to expand...
Click to collapse
Just added my scripts to post #2. It still needs a third-party app (SManager) to be run automatically though.
It seems the app you mentioned puts the swap file on the sd card, while my script puts it to internal memory to the /cache partition. If internal storage is faster than SD (haven't tested, but it probably is), then the swap file created by my script should be faster as well. On the other hand, the app is easily controllable through its UI, while my script is just a script and you need to run it by a third-party app anyways. So whatever you like more, use it
Uploaded automated script for creation and initialization of swap in /cache (to be run on startup). Please let me know if you stumble upon any error
If there's a problem with swap file creation, make sure you have busybox installed with support for df - the built-in df in my shell doesn't recognize the -k flag so it's not good for free space counting.
LuH said:
Just added my scripts to post #2. It still needs a third-party app (SManager) to be run automatically though.
It seems the app you mentioned puts the swap file on the sd card, while my script puts it to internal memory to the /cache partition. If internal storage is faster than SD (haven't tested, but it probably is), then the swap file created by my script should be faster as well. On the other hand, the app is easily controllable through its UI, while my script is just a script and you need to run it by a third-party app anyways. So whatever you like more, use it
Click to expand...
Click to collapse
Thanks for answer!
In this app you can choose swap file path and I've chose /preinstall (512 mb).
Scripts can be ran by placing them into init.d folder, am I right?
Borchuck said:
Thanks for answer!
In this app you can choose swap file path and I've chose /preinstall (512 mb).
Scripts can be ran by placing them into init.d folder, am I right?
Click to expand...
Click to collapse
In theory yes, but SELinux somehow blocks it in CM12 - that's why you need to run it using SManager instead. I have no idea what stock system does on boot.
Borchuck said:
Scripts can be ran by placing them into init.d folder, am I right?
Click to expand...
Click to collapse
Unless something has changed, init.d is disabled by default in CM11/12. I haven't checked Cm11 in a long time, nor in 12.1, though. There's an app that emulates it, as well as at least one app that tries to enable it, in the play store. The former works as it should in both KK and LP as long as you accept its limitations (scripts get run when the app autostarts, after boot), but I have no idea if the latter does.
Using /cache is a neat idea, when you're installed into the stock partitions. It's there and almost completely unused in CM12/.1, and it's not like we can usefully reallocate it or anything 'cause Motorola. Getting the webtop/preinstall stuff going is an extra step, and that space might be put to better use anyway. Though, preinstall is just about the perfect size for a swap...
The problems I see with swapping on any internal partition are 1: you're going to wear the eMMC out a lot faster writing to it all the time (though how much faster is anyone's guess), and 2: the eMMC in our phone isn't especially fast. It's not slow, but it's slower than a modern high-end SD card, and definitely slower than RAM.
I'm a little curious about how fast our device can read/write to external SD cards. A good one, with both fast read/write and good small-block performance, would be "safer" to use for swapping. If it happens to wear out, pop in a new one, good to go.
@LuH
Maybe you should use zRAM? I use it on my phone ...
Fervi
Septfox said:
The problems I see with swapping on any internal partition are 1: you're going to wear the eMMC out a lot faster writing to it all the time (though how much faster is anyone's guess),
Click to expand...
Click to collapse
Well, I've had my device for three years now so if it decides to retire, it's worked enough to earn it However, I have yet to see a phone dead because of worn out memory - it always was some radio chip in my previous ones. So 'm taking my chances I have considered the risk, just don't think it will affect me.
Septfox said:
and 2: the eMMC in our phone isn't especially fast. It's not slow, but it's slower than a modern high-end SD card, and definitely slower than RAM. I'm a little curious about how fast our device can read/write to external SD cards. A good one, with both fast read/write and good small-block performance, would be "safer" to use for swapping. If it happens to wear out, pop in a new one, good to go.
Click to expand...
Click to collapse
eMMC is of course slower than RAM, but my SD doesn't seem to outperform it - at least in big file read and writes it's about the same. I haven't found a working benchmark app for random I/O testing, but I think the onboard eMMC and my SanDisk 64GB SDXC U1 are on par in D4. Then again, I've had my SD longer than I've had my D4, originally bought it for my previous Windows Mobile 6.5 Sony Ericsson Xperia X2
Attached benchmark (usually ~600 MB write and read): SD card (SanDisk 64 GB U1) R13.56/W9,57, SD card (eMMC storage partition) R15.82/W5.31, Internal memory (eMMC /data partition) R8.90/W4.23, Custom location (eMMC /cache partition) R13.82/W4.17.
I don't get why three partitions of same eMMC flash memory chip get so different results, either it's differently managed by the system (but why give preference to media storage?), or the parts of chips are worn out differently, or the benchmarking app sucks
ferviverus said:
@LuH
Maybe you should use zRAM? I use it on my phone ...
Click to expand...
Click to collapse
I'll probably try as well, but thought I'll give swapping a try first... I heard more problems than advantages about using zRAM on D4, what's your experience?
LuH said:
Attached benchmark (usually ~600 MB write and read): SD card (SanDisk 64 GB U1) R13.56/W9,57, SD card (eMMC storage partition) R15.82/W5.31, Internal memory (eMMC /data partition) R8.90/W4.23, Custom location (eMMC /cache partition) R13.82/W4.17.
I don't get why three partitions of same eMMC flash memory chip get so different results, either it's differently managed by the system (but why give preference to media storage?), or the parts of chips are worn out differently, or the benchmarking app sucks
Click to expand...
Click to collapse
Double the write speed isn't "outperforming"? :v
Big file transfers are mostly irrelevant, small-block performance is where you need speed. You can mount both SD and internal storage in Safestrap, test there using CrystalDiskMark (which gives not only bulk transfer speeds, but 512k and 4k as well).
My results, using three passes and a 500mb test file
Internal storage
Sequential Read : 19.844 MB/s
Sequential Write : 13.899 MB/s
Random Read 512KB : 18.571 MB/s
Random Write 512KB : 10.263 MB/s
Random Read 4KB (QD=1) : 3.917 MB/s [ 956.3 IOPS]
Random Write 4KB (QD=1) : 1.770 MB/s [ 432.2 IOPS]
Random Read 4KB (QD=32) : 4.964 MB/s [ 1212.0 IOPS]
Random Write 4KB (QD=32) : 1.947 MB/s [ 475.4 IOPS]
External storage/SD card (Sandisk 16gb Class 10/UC1)
Sequential Read : 14.311 MB/s
Sequential Write : 4.907 MB/s (!)
Random Read 512KB : 13.667 MB/s
Random Write 512KB : 1.468 MB/s
Random Read 4KB (QD=1) : 2.267 MB/s [ 553.5 IOPS]
Random Write 4KB (QD=1) : 0.985 MB/s [ 240.5 IOPS]
Random Read 4KB (QD=32) : 2.512 MB/s [ 613.4 IOPS]
Random Write 4KB (QD=32) : 1.251 MB/s [ 305.5 IOPS]
The choice is clear here, but my card is pretty old...yours may fare better. Sandisk cards are generally known for balanced performance.
As for the different results...I dunno. The eMMC partitions should be all the same, it's all on the same flash after all. The only thing I can think of is filesystem differences, but the internal partitions are all ext3, right?
As sad as it makes me to say it, zRAM...isn't very good at the moment. It seems to slow the phone a bit while enabled, for an effectively minimal amount of extra memory. You'd probably be better off increasing minfree thresholds to keep things killed when they're no longer needed, rather than stressing the memory management even more just to keep a couple more apps "loaded".
@LuH
Well, i don't use CM (it doesn't support lapdock), but I use on stock zRam - I saved ~4.5MB (6.9MB compressed to 2.5MB) ... but I read on internet, that zRam is faster than Swap
Fervi
Failed to send the attachment before, giving now. Anyways, probably will try your suggestion to do it from computer later.
Septfox said:
Double the write speed isn't "outperforming"? :v
Click to expand...
Click to collapse
Well, I'm not really concerned by swapping out - that usually takes place when the phone is at rest. I specifically want it to wake up fast -> read speed is the bottleneck and there it's not as big a difference.
Septfox said:
As for the different results...I dunno. The eMMC partitions should be all the same, it's all on the same flash after all. The only thing I can think of is filesystem differences, but the internal partitions are all ext3, right?
Click to expand...
Click to collapse
Well, it looks as though the smaller the partition, the worse the performance is. No idea why. The biggest (and fastest), "Internal SD card" or Media storage or whatever it's called at different system, the one mounted as /sdcard, is exFAT, others are mostly ext3 (preinstall, cache, system and data) and webtop is ext4.
Septfox said:
As sad as it makes me to say it, zRAM...isn't very good at the moment. It seems to slow the phone a bit while enabled, for an effectively minimal amount of extra memory. You'd probably be better off increasing minfree thresholds to keep things killed when they're no longer needed, rather than stressing the memory management even more just to keep a couple more apps "loaded".
Click to expand...
Click to collapse
Exactly, I need hundreds of MBs, not single megabytes, to outweigh the performance loss.
LuH said:
Well, I'm not really concerned by swapping out - that usually takes place when the phone is at rest. I specifically want it to wake up fast -> read speed is the bottleneck and there it's not as big a difference.
Click to expand...
Click to collapse
Swapping should be happening every time the phone starts running out of memory. So, uh, pretty much every other second.
Run an app > OOM > store "oldest" objects in RAM to pagefile/swap partition > load latest app into RAM > user does something in-app requiring a service provider or some other additional data being loaded > OOM > vicious cycle continues
LuH said:
Well, it looks as though the smaller the partition, the worse the performance is. No idea why. The biggest (and fastest), "Internal SD card" or Media storage or whatever it's called at different system, the one mounted as /sdcard, is exFAT, others are mostly ext3 (preinstall, cache, system and data) and webtop is ext4.
Click to expand...
Click to collapse
Oh right, I guess the internal "SD" would be exFAT or some other FAT variant, since it's treated as a removable card.
Write speed being lower on smaller flash partitions makes sense, if they already have data in them, kind of.
If a write is attempted on a page within a flash block which already has data in it, you have to go through the whole read-erase-modify-write process, dragging overall speed down...
Unless our flash supports TRIM, which would pre-emptively erase blocks while the filesystem is idle; I'm pretty sure it unfortunately doesn't. So it's rare that an app writing files is going to happen upon a nice, big contiguous area of already-cleared blocks that can be simply written to.
But then, /cache is almost certainly empty (or minimally filled), so it makes no sense for writes on it to be slow.
*shrugs* I guess you could try formatting it and see if the write speed improves.
LuH said:
Exactly, I need hundreds of MBs, not single megabytes, to outweigh the performance loss.
Click to expand...
Click to collapse
zRAM is 256mb at default, and you can probably count it being effectively double that at least, once things are compressed into it.
It just...doesn't seem to work very quickly. YMMV though. It's enabled by default on the last few CM12 nightlies, so if you've updated recently (well, and are using 12), it's already on.
If you want it to be bigger/smaller, the value isn't baked in; utilities such as Kernel Aduitor can resize it. I tried increasing it to 500mb just to see if I could break something, and the phone...seemed to run slightly better for some reason. So that was a thing.
And reiteration: it's worthwhile to modify minfree settings. At least in Lollipop, if you keep free memory floating above 200mb, it runs much better. Apps will need to relaunch more, but relaunching is usually a lot faster than letting free memory sink to the 160-170mb range that stock values allow, and waiting while the memory manager chokes.
Empty App: 200 and Hidden App: 160 is adequate.
And speaking of the memory manager, joojoobee's kernel has a bunch of patches merged in that aren't in the nightlies yet, which improve memory handling somewhat (phone still starts choking under 200mb, but it's usable).
On the performance side:
Have any of you had any positive long term experiences with swap enabled? While swap gave me the ability to run several huge tasks all at once, in the long run it made my system very unstable. Things would crash out of random, the phone would take ages to wake up from sleep sometimes etc.
I have now upgraded to cm12.1 and disabled my script again.

Categories

Resources