[Tip] Mounting swapfile from init.d - Samsung Galaxy W I8150

After some experimentation, I finally figured out how to mount a swapfile from init.d
But first! A disclaimer!
STANDARD DISCLAIMER: I am TOTALLY not reponsible if you brick your own phone. This procedure is provided 'as-is', with no guarantee of non-damage, or functionality.
I *do* use this script, and it's working as I expected, but YMMV.
Now, on with the Tip...
SAFETY PRECAUTION
Install (flash) the TWRP recovery first. If all goes well, you can flash your favorite recovery back.
PREREQUISITE
You need:
A rooted phone (of course!)
.
A kernel that supports swapfiles
.
A busybox that provides the following applets: nohup, basename, dirname, renice
The latest busybox by @stericson happens to provide all needed applets.
.
A working init.d infrastructure
PROCEDURE
Make sure that the directory /data/scripts exists (create one if it doesn't)
Create a swapfile by running the following commands from within Terminal (change "64" to the size (in MiB) of the swapfile you want):
Code:
su
TARG=/sdcard/.swapfile
dd if=/dev/zero of=$TARG bs=$((1024*1024)) count=64
mkswap $TARG
echo "SWAPFILE=$TARG" > /data/scripts/wait-mount-swap.conf
Download the attached script, rename it to "wait-mount-swap.sh"
Copy the script to the /data/scripts folder
Run the following commands from within Terminal:
Code:
su
WMS=/data/scripts/wait-mount-swap.sh
FIL=/system/etc/init.d/99swap
chmod 0777 $WMS
mount -o remount,rw /system
echo "#!/bin/bash
nohup $WMS &
" > $FIL
chmod 0755 $FIL
WARNING: Unless you know exactly what you're doing, you must follow the above code *exactly*!! DO NOT add spaces to 'make it easier to read'; DO NOT forget to enter the whole line (including that ampersand '&' symbol).
Reboot
Wait up to 1.5 minutes
Check the /data/scripts/wait-mount-swap.log; the last line should declare "..successful!"
Check using the 'free' command from Terminal
Got Stuck in BootLoop?
Power off your phone, then boot into TWRP recovery.
Tap "Mount".
Check (X) "Mount System"
Tap "Home icon"
Tap "Advanced"
Tap "File Manager"
Go to /system/etc/init.d
Tap on "99swap"
Tap "Rename File"
Append ".disabled" (that's dot-disabled), and tap Enter
Swipe to confirm
Tap "Home icon"
Tap "Reboot"
Tap "System"
--- Sent from Opera on Lenovo T420 ---

Technical Explanation
The gist of the method are two parts: The script and the nohup line. We'll begin with the latter.
If you analyze the 99swap file in /system/etc/init.d, you can see that it has only one all-important line:
Code:
nohup /path/to/script.sh &
The ampersand "&" at the end of the line means: Run this line as a background (separate) process.
The 'secret sauce' is the "nohup" command: It makes the background process stay alive even when the invoking process (i.e., the init.d script) terminates.
So, at the end of the 99swap initscript, the initscript terminates, but wait-mount-swap.sh is still running in memory.
Now, for reasons unknown, the SD Card is not mounted during init.d processing. So, the wait-mount-swap.sh script must wait until the SD Card is available before it can activate the swapfile located in the SD Card.
If you analyze the wait-mount-swap.sh script, you can see that after being invoked, the script will sleep for 30 seconds before attempting to activate the swapfile. If after the 'initial sleep' the script doesn't find the swapfile, it sleeps again for 10 seconds, and repeat the process. If after 5 attempts the swapfile still hasn't appear, it gives up and exits gracefully.
-- Sent from Opera on Lenovo T420 --

Wow! You finally did it man.
Congrats! Will try this asap. Thank you.
Sent from my GT-I8150 using xda app-developers app

pepoluan said:
Technical Explanation
The gist of the method are two parts: The script and the nohup line. We'll begin with the latter.
If you analyze the 99swap file in /system/etc/init.d, you can see that it has only one all-important line:
Code:
nohup /path/to/script.sh &
The ampersand "&" at the end of the line means: Run this line as a background (separate) process.
The 'secret sauce' is the "nohup" command: It makes the background process stay alive even when the invoking process (i.e., the init.d script) terminates.
So, at the end of the 99swap initscript, the initscript terminates, but wait-mount-swap.sh is still running in memory.
Now, for reasons unknown, the SD Card is not mounted during init.d processing. So, the wait-mount-swap.sh script must wait until the SD Card is available before it can activate the swapfile located in the SD Card.
If you analyze the wait-mount-swap.sh script, you can see that after being invoked, the script will sleep for 30 seconds before attempting to activate the swapfile. If after the 'initial sleep' the script doesn't find the swapfile, it sleeps again for 10 seconds, and repeat the process. If after 5 attempts the swapfile still hasn't appear, it gives up and exits gracefully.
-- Sent from Opera on Lenovo T420 --
Click to expand...
Click to collapse
very clever, i remember my good dos/windows days, how i wish i could do the same with linux/android
just looking and understanding your script, i feel i feel like i've gained additional 50% knowledge in linux scripting :good:
Edit: Man i have a joke for you, i mean it's not really a joke but sort of. If you decide to venture into rom development, i want to be the first person to try and test it.

Tq for tips

try your method..
Sent from my GT-I8150 using xda premium

I've figured out a way to make installation *much* easier... stay tuned for R2
Sent from my GT-I8150 using xda app-developers app

pepoluan said:
I've figured out a way to make installation *much* easier... stay tuned for R2
Sent from my GT-I8150 using xda app-developers app
Click to expand...
Click to collapse
looking forward

Hello, I tried this but when I do 'chmod +x $WMS', then shel tell me 'Bad mode'. What's wrong?
Sent from my GT-I8150 with CM 10.1 by Arco using xda premium

honzin2009 said:
Hello, I tried this but when I do 'chmod +x $WMS', then shel tell me 'Bad mode'. What's wrong?
Sent from my GT-I8150 with CM 10.1 by Arco using xda premium
Click to expand...
Click to collapse
Oops, I made a mistake there. I replaced 0777 with +x post-facto.
Try entering 'chmod 0777 $WMS' instead.
The OP has now been fixed, thanks for the report
Sent from my GT-I8150 using xda app-developers app

pepoluan said:
Oops, I made a mistake there. I replaced 0777 with +x post-facto.
Try entering 'chmod 0777 $WMS' instead.
The OP has now been fixed, thanks for the report
Sent from my GT-I8150 using xda app-developers app
Click to expand...
Click to collapse
Thank you, script now working well but the swap file is still not mounted after boot .
I will solve it by manual mounting of swap file after each boot, as I do now.
Sent from my GT-I8150 with CM 10.1a2 by Arco using xda premium

honzin2009 said:
Thank you, script now working well but the swap file is still not mounted after boot .
I will solve it by manual mounting of swap file after each boot, as I do now.
Sent from my GT-I8150 with CM 10.1a2 by Arco using xda premium
Click to expand...
Click to collapse
Hmmm, strange.
It does take up to 30 seconds after boot for swap to be activated.
However, I will not pursue this issue anymore with the current version; I'll be releasing version 2 sometime later this week
Sent from my GT-I8150 using xda app-developers app

boot
pepoluan said:
Hmmm, strange.
It does take up to 30 seconds after boot for swap to be activated.
However, I will not pursue this issue anymore with the current version; I'll be releasing version 2 sometime later this week
Sent from my GT-I8150 using xda app-developers app
Click to expand...
Click to collapse
:good:

pepoluan said:
Hmmm, strange.
It does take up to 30 seconds after boot for swap to be activated.
However, I will not pursue this issue anymore with the current version; I'll be releasing version 2 sometime later this week
Sent from my GT-I8150 using xda app-developers app
Click to expand...
Click to collapse
so is the simpler version 2 out yet? cuz the current one seems slightly overwhelming for me haha!

mount -o remount,rw /system
Click to expand...
Click to collapse
on terminal emulator, this will not run becoz of the comma after remount.
it works if it busybox b4 mount like this:
busybox mount -o remount,rw /system
Click to expand...
Click to collapse
or replace the comma with a space, like this:
mount -o remount rw /system
Click to expand...
Click to collapse

Great mounting with delay
Hi everybody
too late to post in this forum?
I see last reply is of 2013
The man who invented this delayed engine did a great thing :good::good::good::good::good:
The Background is a GT-P5200 stock ROM - android 4.4.2. In less words: Samsung Galaxy Tab 3.
I tried different methods, apps and scripts, but without lucky. I tried with Rhoesoft RAMExpander Test, that told me: your device is compatible...
Not sure 100%, I tried some free apps, with the target to see confirmed that swapfile works, before spending money and discovering that the swap don't autostart at boot. The apps I tried, they created the swapfile, but at boot it was never loaded... Furthermore I don't like having one more app continuously in execution, only to drive the swapfile. So with many doubts, I tried some scripts... But one of them tolds me that my (stock) kernel hasn't swap support :crying:
I'm little stubborn, because I began my swapfile adventure, inputting commands on terminal emulator, forced to learn what does every command. And learning I had feeling that swapfile works, with the only exception of being constrained to swapon manually from the emulator.
So (stubborn) I tried other scripts, to perform this autoload on boot... but never working! I read so many things in many forums, looking for a solution, but for an inexperienced ... things too heavy to digest.
The turning point is thanks to you, @pepoluan
You must know that after every boot, if I open the terminal rapidly, the cursor becomes active after a few minutes.... about 3-4 minutes.
So maybe... if my device is slow to boot, when the SD card will be available?
The conclusion: I took the pepoluan script, and modified the swapfile lines, and initial delay: where there was 30 I put 250
it is better to wait 5 minutes, as long as they are quiet

Related

[APP] Native EXT2 without custom kernel

Update! Much improved APP version is available here: http://forum.xda-developers.com/showpost.php?p=8230964&postcount=143
Still not recommended for anybody without a fully working recovery mode.
------------
This is very much ALPHA! Don't try it unless you have something to prove!
Does not work with the latest froyo builds
Start off with a clean firmware without any other lagfixes. It should work in other cases, but I've only tested it with a clean JM8. It should work fine in a clean JPC Froyo too. You're gonna need busybox (1.17.1) or similar tools.
Step 1: You need a 512byte MBR file. If you have a 8GB I9000 like me, you can use my attached file. Else, proceed to post #2 on how to create this file for your device.
Step 2: Copy all of the required files to the correct place.
Code:
adb push test.sh /sdcard/test.sh
adb push parted-static /sdcard/parted-static
adb push partprobe-static /sdcard/partprobe-static
adb push playlogos1 /sdcard/playlogos1
adb shell
su
busybox cp /sdcard/test.sh /system/bin/userinit.sh
busybox cp /sdcard/parted-static /dbdata/parted-static
busybox cp /sdcard/partprobe-static /dbdata/partprobe-static
busybox mv /system/bin/playlogos1 /system/bin/playlogosnow
busybox cp /sdcard/playlogos1 /system/bin/playlogos1
chmod 755 /system/bin/playlogos1
chmod 755 /system/bin/userinit.sh
Step 3: Put the MBR file in place. It must be a 512byte file, and it must be placed in /dbdata/test2 - Refer to 2nd post to create one, or use my included one in the zip.
EDIT: Missed a step. You need to move the binary '/system/bin/fsck_msdos' to '/system/bin/fsck_msdos.bak' or other name. You won't be able to unmount if the FAT32 check is running. It will have to be done manually after.
Step 4: This is the hard part! Reboot your phone. The boot logo will be 20 seconds delayed. This is because there is a 'sleep 20' command inside the boot script, as it seems to take 10+ seconds for mmcblk0p3 to show up in /dev/block. I don't know why, it should show up instantly. Anyway, it'll boot up after you see the messed up boot logo.
Step 5: Create the EXT2 partition
Code:
adb shell
su
busybox mkfs.ext2 -b 4096 -m 0 /dev/block/mmcblk0p3
mount -t ext2 -o noatime,nodiratime,errors=continue /dev/block/mmcblk0p3 /data/data2
Step 6: Copy your /data/data across, and whatever else you want too
Code:
mkdir /data/data2
busybox cp -rp /data/data /data/data2/
busybox mv /data/data /data/data.bak
busybox ln -s /data/data2/data /data/data
You can repeat the cp, mv, and ln for app, app-private, system, dalvik-cache
Step 7: Reboot. It'll have the messed up boot animation again.
Congratulations!
Quadrant scores are around 1900 (database writes take longer than EXT2 on RFS, as the buffer is smaller)
It runs very very smoothly though!
Good luck if you try this!
I'll have an app to do all of this later in the week / next week.
If anybody can tell me why I need the 'sleep 20' before /dev/block/mmcblk0p3 is created, I'd really like to know.
Updates / Known Issues
GPS breaks on boot. Fix it with 'kill pid', where pid is found with 'ps' and the process is called '/system/bin/gpsd/glgps_samsungJupiter'
20 second pause is too long, and some apps may start to load before hand! I changed the 20 sec sleep in test.sh to 10 sec, and it seems a lot better. Still need to find out why a pause is needed at all.
How to create your own MBR 512byte file:
First, make sure you have /dbdata/parted-static. See above post on how to copy it.
Then, you need to knock /sdcard/sd and /sdcard out of operation. This method is easiest:
Code:
busybox fuser -km /sdcard/sd
busybox fuser -km /sdcard
umount /sdcard/sd
umount /sdcard
Now you need to create the partition using parted-static. You could use sfdisk or busybox fdisk too, but I like parted!
Code:
/dbdata/parted-static /dev/block/mmcblk0
First, list the existing partitions with 'print'. You should get something like this:
Code:
Number Start End Size Type File system Flags
1 32.8kB 6208MB 6208MB primary fat32 lba
2 6208MB 8221MB 2013MB primary lba
Now, resize your /sdcard partition. It's the big one (6208MB in my case):
Code:
resize 1 32.8kB 5208MB
And then, you need to create a new partition using the remaining space:
Code:
mkpart
logical
5208MB
6208MB
And now list the partitions again with print. You should have something like this:
Code:
Number Start End Size Type File system Flags
1 32.8kB 5208MB 5208MB primary fat32 lba
3 5208MB 6208MB 999MB primary ext2
2 6208MB 8221MB 2013MB primary lba
All done! Exit parted with 'quit'
Now, you need to create the 512byte file. Really easy:
Code:
dd if=/dev/block/mmcblk0 of=/dbdata/test2 bs=1 count=512
And now you have your own MBR file sitting in /dbdata/test2, all ready for use by the reboot script.
Thanks for your work ryan
i Guess you need root
mazsuper said:
Thanks for your work ryan
i Guess you need root
Click to expand...
Click to collapse
Hahah, you very much need root! If root is a problem for you, you really shouldn't try this out! It's fairly complicated. Difficulty Level: Advanced!
That said, this will be hopefully end up in OCLF as a one click option (well, it might have to be 2 clicks). I'm not sure how much testing this is going to need. I guess the more people who help test it out, the sooner I can move it up. I'm sure there are a lot of bugs.
MBR file
Would be willing to give it a try if you could pre-bake a MBR file that is compatible with the 16gb version !
bratfink said:
Would be willing to give it a try if you could pre-bake a MBR file that is compatible with the 16gb version !
Click to expand...
Click to collapse
It's really easy, just follow the steps in post 2. Shouldn't take more than 5 mins.
You just resize the big partition (look for the one with the biggest size) and then enter the start as the same as the current start, and the end as end-1000MB or whatever.
The 20 sec wait seems to be too long though. It is possible to lose apps if they try to load up too soon.
Shows up after doing a few reboots. Should be fixable.
That looks promising. But do I understand it correctly that the system is still running off of rfs? Thumbs up in any case, this looks like it could finally fix the lagging on my JPC
Ok RyanZA, I finally understood what you meant
Meister_Li said:
That looks promising. But do I understand it correctly that the system is still running off of rfs? Thumbs up in any case, this looks like it could finally fix the lagging on my JPC
Click to expand...
Click to collapse
Nope, the system runs completely off EXT2. It's very fast.
Bug found: The fix breaks the GPS deamon for some reason! Interesting, I wonder why.
Anyway, workaround is easy: just kill the gps deamon and it will automatically restart, and work fine. GPS deamon is called /system/bin/gpsd/glgps_samsungJupiter - It can be found with 'ps' and killed with 'kill pid'
Gotta make notes of all of this stuff..
supercurio said:
Ok RyanZA, I finally understood what you meant
Click to expand...
Click to collapse
Woooooooohoooooooooo!!
You see? It works after all! Got some bugs and stuff still, but with a bit of work it is definitely possible to make this bulletproof. I think, anyway.
Do you know why it takes ~5-10 seconds for /dev/block to update? Looking at the log, it seems to wait for vold to do it. I guess I need to find a way to force vold to re-check it quicker?
I'm quite liking this fix so far. Makes JPC a LOT nicer.
Anyway, I'll use this for a day and report back on any issues tomorrow night. If anybody else could give it a try, that would be awesome!
Hi ryan
Thanks for your great work as ever
2 questions
Do I have to do this every time I flash a new rom
And how do I undo this
Sent from my SAMSUNG-SGH-I897 using XDA App
Thank you, RyanZA, for your work! It's very appreciated.
Sent from my GT-I9000 using XDA App
wow first voodoo now this These lag fixes can only get better. Will try this on the weekend when my phone have some "downtime"
Maybe even go back to JPC as well lol Only reason I'm using JM cos of lagfixes lol
Thank you both for you work Curio and Ryan.Im very happy with the voodoo so far but if u are going to make an app like one click i probably wanna try it.Afterall maybe we can get froyo and lagfix next week hein??
Ryan, I'm lazy mate... have you got this into any sort of package yet, or do I need to read the destructions carefully? (Running JPC with your 1.6x lagfix)
Any hope for an apk or similar noob proof stuff?
toca79 said:
Any hope for an apk or similar noob proof stuff?
Click to expand...
Click to collapse
RyanZA said:
That said, this will be hopefully end up in OCLF as a one click option (well, it might have to be 2 clicks). I'm not sure how much testing this is going to need. I guess the more people who help test it out, the sooner I can move it up. I'm sure there are a lot of bugs.
Click to expand...
Click to collapse
Message for char limit.
I mean com'on. Look at when he created this thread. Look at the text in bright red to get an idea of where this is at.

[GUIDE] Setting Up and Activating SWAP Partition Without Breaking USB Mass Storage

Okay, many of you complain about USB MASS STORAGE not working with swap enabled. So heres a guide, using CWM (latest version) to set it up with working USB.
NEEDED:
MicroSD (i use class 4 sandisk 8gb)
Root+Busybox
CWM Recovery* (see post 2 for reasons of the *)
Terminal Emulator/ADB
Download this file http://dl.dropbox.com/u/1169731/swap_enabler.sh and place it IN THE ROOT OF YOUR SD!!!
Precautionary:BACKUP EVERYTHING ON MICRO SD CARD.
Steps:
Making the partition
Make sure you have everything backed up, as this WILL wipe your SD.
Boot into clockworkmod recovery.
Go to Advanced->Partition SD Card->EXT and Swap. I chose 128mb for EXT and 256 for SWAP.
Activating Through ADB
Make sure you downloaded that file earlier.
Type this into the CMD:
Code:
adb shell
chmod 755 /mnt/sdcard/swap_enabler.sh
sh /mnt/sdcard/swap_enabler.sh
And reboot
When your phone has rebooted, go back into ADB, and type:
Code:
adb shell
free
and if you didnt not get 0's next to SWAP, it worked.
Activating through Terminal Emulator
Load up Terminal Emulator
Type in this:
Code:
su
chmod 755 /mnt/sdcard/swap_enabler.sh
sh /mnt/sdcard/swap_enabler.sh
reboot. when your phones has booted back up, load terminal emulator once more, and type:
Code:
su
free
and if there isnt a bunch of 0's next to SWAP, it worked
And thats that!
Enjoy
TO DISABLE THROUGH ADB:
adb shell (skip if you're already in adb shell)
sh /mnt/sdcard/swap_enabler.sh disable
Click to expand...
Click to collapse
TO DISABLE THROUGH TERMINAL EMUALTOR
su
sh /mnt/sdcard/swap_enabler.sh disable
Click to expand...
Click to collapse
NEW QUICK EASY WAY (HIT AND MISS)
1) download script manager from the market
2) run swap_enabler.sh with script manager
3) reboot
SPECIAL THANKS TO: Nv for the script, and cimer for the original guide.
also, thanks to cjward for reminding me to put in the thanks ;D
* this guide is for CWM recovery, as the steps for 4EXT may be different. Also, when i tried to do it with 4EXT, it never activated the swap partition correctly.
Man, I've been trying to get this right. Think I messed up because I did not restart after running the script, so when I did the free command I got them zeros.
enserio said:
Man, I've been trying to get this right. Think I messed up because I did not restart after running the script, so when I did the free command I got them zeros.
Click to expand...
Click to collapse
what SD card you have? also, i have noticed it does not work on some roms, but most it does.
I used this method to set swap up to use with virtuous 3.5 and work great for me on my first try. It definately helps out.
Sent from my HTC Vision using xda premium
xT4Z1N4TRx said:
what SD card you have? also, i have noticed it does not work on some roms, but most it does.
Click to expand...
Click to collapse
The 8GB one that came standard with the G2 in the US, Dec 2010. If you need me to take it out and confirm what kind, I will, because this something I want to learn how to do. Also, I tried it with the ILWT Rom. I was trying to get to to work because I wanted to flash that Virtuous 3.5
PS - Anyone have a better method for backing up the SD card besides creating a folder on the desktop and dragging everything in there?
when i type su in terminal emulator I get
"[1] + Stopped (signal)"
I'm now getting a +2 error.
This is mildly frustrating because it seems so easy. I've learned several other processes to do to my phone, and THIS is the one that I get hung up on?
Latest debacle:
I wipe using G2+Superwipe. Make partitions of 128 and 256. Sdcard goes completely blank, so I have to mount it in recovery, and load up a nandroid. I figure, its still all good, go through with it. So I run the commands in Terminal Emulator and get the +2 error. damn damn damn
enserio said:
I'm now getting a +2 error.
This is mildly frustrating because it seems so easy. I've learned several other processes to do to my phone, and THIS is the one that I get hung up on?
Latest debacle:
I wipe using G2+Superwipe. Make partitions of 128 and 256. Sdcard goes completely blank, so I have to mount it in recovery, and load up a nandroid. I figure, its still all good, go through with it. So I run the commands in Terminal Emulator and get the +2 error. damn damn damn
Click to expand...
Click to collapse
Have you tried with ADB?
Sent from my Desire Z running @ 2GHZ
now on terminal emu i get: arith: syntax error: "65 on +2"
I'd try adb but i dont know much about adb
Hi everybody
I was asking myself, before doing it, do I really need it ?
I mean, I'm on Cyanogen Nightly and I've seen it's needed on virtuous (awesome) roms. But on CM, will it change something to activate swap ?
Thanks in advance
xT4Z1N4TRx said:
Have you tried with ADB?
Sent from my Desire Z running @ 2GHZ
Click to expand...
Click to collapse
well, new SDK is giving me problems setting up on my mac. Now you have to use SDK manager, which says to run 'android' file, and when I do it gives me an error just as its about to finish setting up.
Ugh, I want this to happen.
EDIT: got ADB fixed. gonna gee it a go this way.
KeitaroSenpai said:
Hi everybody
I was asking myself, before doing it, do I really need it ?
I mean, I'm on Cyanogen Nightly and I've seen it's needed on virtuous (awesome) roms. But on CM, will it change something to activate swap ?
Thanks in advance
Click to expand...
Click to collapse
This I would also like to know! Thx!
While I can't be 100%, I would say that it wouldn't help you much at all, on any CM based ROMs. Just the ones that are RAM intensive (i.e., sense roms). I know that I only want it to run the Virtuous 3.5 ROM.
Can anyone tell me is there a difference between doing it this way, or just using the app "swapper for root" from the app market..?
Thanks
Thought I would pop in. Doing it via terminal does not normally work you need to do it via ADB. If you're unfamiliar with ADB please go to here: http://theunlockr.com/2009/10/06/how-to-set-up-adb-usb-drivers-for-android-devices/ and learn about it. It can be such a useful tool. You do not need swap for CM7,MIUI, or Sense 2.1. It can be needed for Sense 3.0 or Sense 3.5 because Sense is such a memory hog at those version levels.
fredcorp6 said:
Can anyone tell me is there a difference between doing it this way, or just using the app "swapper for root" from the app market..?
Thanks
Click to expand...
Click to collapse
Yes, using this way restricts it to one partition, whereas using swapper allows it to use the FAT partition. This means, with this only your swap part will get corrupted over time, whereas with swapper your FAT will, losing your data.
Sent from my Desire Z running @ 2GHZ
Ah ok I see.. cheers
Anyone able to overcome the +2 error? Using Umaro kernal on EliteMod CM7.
Code:
# sh /mnt/sdcard/swap_enabler.sh
sh /mnt/sdcard/swap_enabler.sh
* Some tests.
/mnt/sdcard/swap_enabler.sh: arith: syntax error: "65 on +2"
EDIT:
Probably something not being compatible either busybox or CM7 but I got it to work by doing the following after looking at the code in the swap_enabler.sh file.
Since it was "65 on + 2" I figured that the cut commands weren't being executed properly somewhere and that it should have been 65 + 2 = 67..... =)
in shell i typed swapon /dev/block/vold/179:67
and it worked. Of course I had to manually make an entry in init.d and test it =)....
Maybe this can help OP edit the code.
Nshih422 said:
Anyone able to overcome the +2 error? Using Umaro kernal on EliteMod CM7.
Code:
# sh /mnt/sdcard/swap_enabler.sh
sh /mnt/sdcard/swap_enabler.sh
* Some tests.
/mnt/sdcard/swap_enabler.sh: arith: syntax error: "65 on +2"
EDIT:
Probably something not being compatible either busybox or CM7 but I got it to work by doing the following after looking at the code in the swap_enabler.sh file.
Since it was "65 on + 2" I figured that the cut commands weren't being executed properly somewhere and that it should have been 65 + 2 = 67..... =)
in shell i typed swapon /dev/block/vold/179:67
and it worked. Of course I had to manually make an entry in init.d and test it =)....
Maybe this can help OP edit the code.
Click to expand...
Click to collapse
Why do you want to use swap on cm7. There are zero benefits. But there are disadvantages, it could affect battery life, performance and wear your sdcard out faster
Sent from my HTC Vision using Tapatalk

Help with CIFS & scripting

Hopefully this is the right place for this.
Trying to write a script that will auto mount/unmount my SMB shares using CIFS based on this post:
http://forum.xda-developers.com/showthread.php?t=1151949
Everything works well except for unmounting the share.
It's weird - when I adb shell and issue "umount /sdcard/cifsshare" as superuser the share unmounts fine. If I create a script and put in a single line "umount /sdcard/cifsshare" and run the script via adb shell as superuser I get the error: failed: No such file or directory. What's the difference?
This is driving me nuts!!!!!!!!!!
I've also tried "umount /mnt/sdcard/cifsshare" as suggested in the linked post but this didn't work either......:crying:
Please help - I'm about to throw this phone out the window!
You can use the mount command on your device terminal to view all mountpoints. How is your SMB share listed?
Petrovski80 said:
You can use the mount command on your device terminal to view all mountpoints. How is your SMB share listed?
Click to expand...
Click to collapse
Thanks, good idea.
mount shows in mounted as /storage/sdcard0/cifsshare but unfortunately again - it works if I issue the command "umount /storage/sdcard0/cifsshare" at the command line but if I create a script with the same line in it and run the script I still get the error: failed: No such file or directory
This doesn't make any sense?
rob151515 said:
Thanks, good idea.
mount shows in mounted as /storage/sdcard0/cifsshare but unfortunately again - it works if I issue the command "umount /storage/sdcard0/cifsshare" at the command line but if I create a script with the same line in it and run the script I still get the error: failed: No such file or directory
This doesn't make any sense?
Click to expand...
Click to collapse
You could try to use the mount command in that script, and see what mountpoints that shows.
Petrovski80 said:
You could try to use the mount command in that script, and see what mountpoints that shows.
Click to expand...
Click to collapse
Ok I'm not quite sure what happened but it seems to be working now....
I did what you said, I put mount in the script and it was still indicating /storage/sdcard0/cifsshare but using this path with umount was still giving me the error. I then put "ls -l /storage/sdcard0/cifsshare" as a command directly above "umount /storage/sdcard0/cifsshare" in the script and it seems to have started working - no more error....
very weird.....
Anyway I appreciate your help on this - thanks!
Ok, good thing that it works now.
Sent from my Galaxy Nexus using Tapatalk 2
rob151515 said:
Ok I'm not quite sure what happened but it seems to be working now....
I did what you said, I put mount in the script and it was still indicating /storage/sdcard0/cifsshare but using this path with umount was still giving me the error. I then put "ls -l /storage/sdcard0/cifsshare" as a command directly above "umount /storage/sdcard0/cifsshare" in the script and it seems to have started working - no more error....
very weird.....
Anyway I appreciate your help on this - thanks!
Click to expand...
Click to collapse
Are you shebanging your script properly? The first line of a shell script should point to your shell environment. For instance:
Code:
#!/system/bin/sh
umount /sdcard/cifsshare
If you don't shebang properly, the script can sometimes do some funky things.
Cilraaz said:
Are you shebanging your script properly? The first line of a shell script should point to your shell environment. For instance:
Code:
#!/system/bin/sh
umount /sdcard/cifsshare
If you don't shebang properly, the script can sometimes do some funky things.
Click to expand...
Click to collapse
I don't think I am (bit of a noob i'm afraid) - I have #!/bin/bash not #!/system/bin/sh at the top of the script.
The bash shell is not available on JB by default. Use the path to sh as suggested by cilraaz.
Sent from my Galaxy Nexus using Tapatalk 2
Petrovski80 said:
The bash shell is not available on JB by default. Use the path to sh as suggested by cilraaz.
Sent from my Galaxy Nexus using Tapatalk 2
Click to expand...
Click to collapse
Ok sorry, thought it was working - well it was sort of.....
I wanted to add a second share to the script.
My working script:
#!system/bin/sh
umount /sdcard/cifsshare1
Now I added a second line to the script and the whole thing starts failing again:
#!system/bin/sh
umount /sdcard/cifsshare1
umount /sdcard/cifsshare2
causes the error 'failed: No such file or directory'.
what's really strange is this works:
#!system/bin/sh
umount /sdcard/cifsshare1
this doesn't:
#!system/bin/sh
umount /sdcard/cifsshare1
#test
Is this weird or am I doing something totally wrong - it's like it will run fine as long as there's only one line in the script????
I should also mention that I'm running it using from adb shell:
sh ./cifs_unmount.sh
is this correct?
What are you using to write the script?
For example, Windows notes can introduce undesired formatting, especially on line breaks...
danger-rat said:
What are you using to write the script?
For example, Windows notes can introduce undesired formatting, especially on line breaks...
Click to expand...
Click to collapse
Unfortunately I am using Windows but I am using plain old notepad so I would have thought that would be ok.
rob151515 said:
#!system/bin/sh
umount /sdcard/cifsshare1
umount /sdcard/cifsshare2
causes the error 'failed: No such file or directory'.
Click to expand...
Click to collapse
You need the leading slash on your path:
#!/system/bin/sh
rob151515 said:
Unfortunately I am using Windows but I am using plain old notepad so I would have thought that would be ok.
Click to expand...
Click to collapse
Go get NotePad++, as it has the ability to write with windows end lines as well as Unix end lines.
Sent from my Galaxy Nexus using Tapatalk 2

Square Enix Chaos Rings (Force Close Root Workaround)

Hey, just in case anyone else shelled out the money for SE's new Android release, Chaos Rings and couldn't play due to being rooted...
All you need to do to be able to play is rename your SuperSU.apk/superuser.apk in the /system/app folder (I just added, ".bak" to the filename) and the force close will end. Of course, you will probably want to rename the apk back to normal once finished
EDIT:
Cooldoud has a script on post #5 which, with Script Manager, should offer a widgetable solution to quickly renaming the superuser/supersu apk
rmikulus said:
Hey, just in case anyone else shelled out the money for SE's new Android release, Chaos Rings and couldn't play due to being rooted...
All you need to do to be able to play is rename your SuperSU.apk/superuser.apk in the /system/app folder (I just added, ".bak" to the filename) and the force close will end. Of course, you will probably want to rename the apk back to normal once finished
Click to expand...
Click to collapse
Sounds like a job for a bash script and Anycut. Would hate to have to do that manually all of the time...
garwynn said:
Sounds like a job for a bash script and Anycut. Would hate to have to do that manually all of the time...
Click to expand...
Click to collapse
OOH how difficult is it to do? Would be nice to automate
rmikulus said:
OOH how difficult is it to do? Would be nice to automate
Click to expand...
Click to collapse
Renaming is easy - busybox mv <source> <dest>
It's calling the app that I'm not certain about.
Yep found that out too... Really can't figure out why they went through the hassle of implementing such a lame system... Anyway, I wrote the below script for my gnote, it will toggle supersu so you can use the same widget to enable and disable supers.
After that install script manager, and set the script to be executed as root. You can then just create a widget to easily access the script
Code:
mount -o remount,rw /system
if [ $? -ne 0 ]; then
echo "Failed to remount /system as rw"
exit
fi
if [ -f "/system/app/Superuser.apk" ]; then
echo "Disabling Superuser App..."
mv /system/app/Superuser.apk /system/app/Superuser.bak
mount -o remount,ro /system
echo "All Done"
else
echo "Enabling Superuser App..."
mv /system/app/Superuser.bak /system/app/Superuser.apk
mount -o remount,ro /system
echo "All Done"
fi
I tried making it into a .sh and running it on script manager but it didnt work. kept saying line errors.
Metalshadowx2 said:
I tried making it into a .sh and running it on script manager but it didnt work. kept saying line errors.
Click to expand...
Click to collapse
You must make sure you convert your newline characters to Unix format. Wondows-style newline will cause the error you're getting (well if we're talking about the same error )
You can use notepad++ or Google dos2unix for a command line tool.
Sent from my GT-N7000 using xda app-developers app
Shouldn't this be in the apps section?
Sent from my SPH-D710 using xda premium
Probably yes, might also want to take it out of the Epic 4G section and move it to general Android as this is going to affect all devices
That's what I was just thinking...
Sent from my SPH-D710 using xda premium
cooldoud said:
Yep found that out too... Really can't figure out why they went through the hassle of implementing such a lame system... Anyway, I wrote the below script for my gnote, it will toggle supersu so you can use the same widget to enable and disable supers.
After that install script manager, and set the script to be executed as root. You can then just create a widget to easily access the script
Code:
mount -o remount,rw /system
if [ $? -ne 0 ]; then
echo "Failed to remount /system as rw"
exit
fi
if [ -f "/system/app/Superuser.apk" ]; then
echo "Disabling Superuser App..."
mv /system/app/Superuser.apk /system/app/Superuser.bak
mount -o remount,ro /system
echo "All Done"
else
echo "Enabling Superuser App..."
mv /system/app/Superuser.bak /system/app/Superuser.apk
mount -o remount,ro /system
echo "All Done"
fi
Click to expand...
Click to collapse
Anyway, big ups to cooldaud, your script works great for me! Had to change "Superuser" to "SuperSU" but everything is great! SMWidget ftw as well
Well so ironic SE would punish rooted android users and not GAF on ffxi hackers still -.- Meh I only speed hack moderately anyway...have you tried traveling otherwise? Soooo slow >.<
Sent from my SPH-D710 using XDA
Hi, tried this script on galaxy note 10.1, all went well and tablet acts like non rooted, but still supersu app in the app drawer and the game crashes as usually
cooldoud said:
You must make sure you convert your newline characters to Unix format. Wondows-style newline will cause the error you're getting (well if we're talking about the same error )
You can use notepad++ or Google dos2unix for a command line tool.
Sent from my GT-N7000 using xda app-developers app
Click to expand...
Click to collapse
ok i did and now i get this error
Looks like you're not using the busybox binaries. Maybe try replacing "mount" by "busybox mount"? Problem is I don't know what shell you'd be using so that might still not be working. Are you using the international Note? What ROM?
Also double check whether you're using SuperSU.apk or Superuser.apk as your root configuration tool.
I have no idea how all these scripts work, so I just tried to change the name of my superuser.apk, but for the life of me I can't figure out how to do that. My phone insists that I have insufficient privileges to rename it...
It seems that they finally added "*This game cannot be played on rooted devices." to the app description, it was not there yesterday
Well, I went and researched scripts. Got this script to work. (Had to add "busybox" before "mount")
Checked that the app does get renamed to .bak, and yet I still get a force close when i press start. I guess I'll just have wait for SE's patch.
It's important to check that the application is not appearing in your app drawer anymore (if your launcher can detect the app, so can SE... ) . Go there and check, if the app is still appearing it means it is still accessible (not sure whether you then need a reboot for it to disappear or something?), if it's not there... it means SE is also checking some other stuff to determine whether you're rooted, but I have no idea what that would be.
Ah yes, that's it. It still shows in my app drawer. Reboot didn't help. Trying searching the issue, came up with nothing. I guess I'm not meant to play this game just yet lol. Thank for trying to help!

[Q] Very slow and laggy Nexus

Hi! From a few months, since I started flashing new ROMs, my gnex became slower and very laggy. The real problem is that it is very slow even when flashing ROMs and other stuffs in recovery mode. I'm currently using CM10 with Franco kernel and ClockworkMod recovery. Changing kernel and wiping didn't solved anything. What could be the reason?
Try to download eMMC brickbug check, is an app that check if your memory chip is affected by a factory bug (since there's a series of chip afflicted), this bug slow down all the system and makes it very laggy. Try to take a shot, and if the result is that you are afflicted in the forum there's the solution!
No bug and no errors in memory test
1 - Backup all files on your SD card .dont include /android/ Directory.
2 - Flash Google Factory Image for 4.1.2
2.1 - Flash Latest TWRP
3 - Download "Forever Gone"
4 - Start it and let it run through your empty SD card (it'll overwrite it with 0s, it helped fix a problem on the nexus 7 and helped me with some SD card IO lags, And it removes all traces of what once was, so...)
5 - Download Rasbeanjelly 11-6 (the 4.1.2 version ) It's pure AOSP, Blazing fast and the standby drain is amazing (and notifications don't delay even when asleep )
6 - Download Trinity Kernel latest stable (Link http://goo.gl/jl1Ga )
7 - Flash the above and set up your ROM.
SECTION TWO
8 - Go to Google maps >> Location settings & turn everything off.
8.1 - If you still want location history use backitude instead of latitude
9 - Use one chat app instead of many (especially FB messenger it sucks battery big time, use IMO . It's the best, has file transfer, audio/video call, lovely interface and supports most networks even skype.
10 - Sign out of Google talk
11 - Turn off Google+ Sync
12 - Turn off Google Backup
13 - If you don't use it, Turn off Google now (i think it's nice actually).
14 - Install Betterbatterystats & BatteryMonitorWidget to keep watch of any batter hogs should they come along.
15 - Install Velis Auto Brightness
Trust me on this one with trinity & rasbeanjelly
Set the CPU to 1000thingy max/600 thingy minimum
I believe that when i get a quality phone for this kind of cash i shouldn't compromise functionality c: so i don't use battery saving apps, i need my data on and always, I get about 17 hours with ~3 hours screen time, Pm me if you need anything else ^_^
[Edit] Optional : Turn off screen touch sounds/Vibration, if you want to...
-----------------------------------------------------------------------------------
Silencing maps (preventing non user caused wakelocks)
1. Sign out and /or freeze latitude.
That's it!
Additional information:
-manual startup of maps will work anyhow, don't worry,
-navigation still works
-toggling gps on will show your current position on the map
Do you format partition cache and Dalvik cache before flashing ROM?If no then this is the problem you are facing..coz i've flashed 100's of ROMs but no problem yet!!
Wait wait wait (xD)..it's very slow even WHILE FLASHING anything (or making backups) in recovery mode (when there's the green android with the rotating blue frame inside). I can't see how changing ROM or changing settings inside the OS can solve the problem...I'm not an expert but I think it's a problem at a lower lever..like kernel, drivers, chips..something like that :silly:
..anyway..cause not an expert I tried the Trinity kernel and didn't make any difference..and I will try to use Forever Gone after I made ​​a backup and restored to factory image..
This may and probably applies.
http://forum.xda-developers.com/showthread.php?t=1971852
Sent from my Galaxy Nexus using Tapatalk 2
tiny4579 said:
This may and probably applies.
http://forum.xda-developers.com/showthread.php?t=1971852
Click to expand...
Click to collapse
Ok I made a bench and I had horrible results. This night I'll try to fix this...
Restore all to stock and these are the results:
Seems that you have the same buggy eMMC chip of type V3U00M.
The phone might slowdown again after writing some data on it. You should add discard to your mount options.
Guide (filling the partition using dd and rm is optional for you)
I don't know how to run the code of the step 3: I tried to install Android Termina Emulator and run the commands here..."su" worked and the dialog box of SuperSU appeared asking me the permission, but when I wrote "mount -o remount,discard /data" nothing appened. Sorry men..I don't know what I'm doing
He says:
Type the following commands in a Terminal or preferably an adb shell:
Click to expand...
Click to collapse
and than
Therefore using adb would be better... Some users also reported a speedup when this is done in recovery mode (CWM/TWRP) via adb.
Click to expand...
Click to collapse
How can I do that? Like...reboot into recovery mode, connect the phone to the pc, move to the folder of adb.exe and run the command as "adb su" and "adb mount -o remount,discard /data" ? ...I don't think :silly:
nicari92 said:
I don't know how to run the code of the step 3: I tried to install Android Termina Emulator and run the commands here..."su" worked and the dialog box of SuperSU appeared asking me the permission, but when I wrote "mount -o remount,discard /data" nothing appened. Sorry men..I don't know what I'm doing
Click to expand...
Click to collapse
The command did add the discard option, but it is not showing any output
nicari92 said:
[...] How can I do that? Like...reboot into recovery mode, connect the phone to the pc, move to the folder of adb.exe and run the command as "adb su" and "adb mount -o remount,discard /data" ? ...I don't think :silly:
Click to expand...
Click to collapse
Nearly right: You have to open an adb shell (using the command adb shell) and then type the commands
Well, as you don't really know what you're doing, I think that it's not such a great idea to experiment with the command line in superuser mode...
You can get the same results doing the following:
Install Script Manager from Play Store.
Download the following text file to your internal memory: remount.sh
Browse to the script in Script Manager and add it to be run at boot (Open as... Script/Executable). Make sure you check both the Boot and Su options, then press Save and Run.
Now you should be done if you don't already experience huge slowdowns of your memory (0.4-0.5 MiB/s random write is OK)
If you HAVE slowdowns, install Forever Gone. Fill your sdcard (aka securely erase deleted files) and then free the filled space. Done.
Install and run LagFix (fstrim) from Play Store. Done.
---
FYI: The code in remount.sh is the following:
Code:
#!/system/bin/sh
mount -o remount,discard /data
mount -o remount,discard /cache
Ok thanks!
Do I have to relaunch the command (or recreate the script) every time I flash a new ROM?
nicari92 said:
Ok thanks!
Do I have to relaunch the command (or recreate the script) every time I flash a new ROM?
Click to expand...
Click to collapse
After a full wipe you have to re-install the app and configure the script again to make sure it is launched on every boot.
Install seeder v1.4 too.
Look for it in XDA(free) or the Play store(paid)
--------------------------------------------------
If I have helped you.... hit that sexy thanks button. ^_^
AW: [Q] Very slow and laggy Nexus
I don't think that waiting for the random source is the problem here...
The thread I linked has an app that can run the trim command which should help io.
Sent from my Galaxy Nexus using Tapatalk 2
Direct Link
You can use it instead of dd&rm / Forever Gone. The tool does this job better and is faster, I would say it's the preferred method now.
Doesn't permanently solve the problem, though (unless you run it periodically) ...
So maybe the best is using the discard init script plus this app once.
once you have run the remount script why do you need the lagfree app?
ph4zrd said:
The command did add the discard option, but it is not showing any output
Nearly right: You have to open an adb shell (using the command adb shell) and then type the commands
Well, as you don't really know what you're doing, I think that it's not such a great idea to experiment with the command line in superuser mode...
You can get the same results doing the following:
Install Script Manager from Play Store.
Download the following text file to your internal memory: remount.sh
Browse to the script in Script Manager and add it to be run at boot (Open as... Script/Executable). Make sure you check both the Boot and Su options, then press Save and Run.
Now you should be done if you don't already experience huge slowdowns of your memory (0.4-0.5 MiB/s random write is OK)
If you HAVE slowdowns, install Forever Gone. Fill your sdcard (aka securely erase deleted files) and then free the filled space. Done.
Install and run LagFix (fstrim) from Play Store. Done.
---
FYI: The code in remount.sh is the following:
Code:
#!/system/bin/sh
mount -o remount,discard /data
mount -o remount,discard /cache
Click to expand...
Click to collapse
Thanks a million... Works like a charm.

Categories

Resources