yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] zeppelinrox:
I got a clue from googling the error and saw that it can result from unsupported file systems.

looking at other swap scripts, they used /sdcard too so I figure that it has to be due to the internal sdcard being an unsupported file system.

I thought about adding swap stuff to V6 but never had the time plus other stuff keeps coming up lol

The 2 threads from the milestone forum are interesting.

http://xdaforums.com/showthread.php?t=1951983

http://xdaforums.com/showthread.php?t=2020312

The first look to see if there's a swap partition set up on the sdcard and if so, that's used.

If not, next they look to see if there is an ext partition on the sdcard and if so, that's used.

If not, it uses the sdcard's vfat file system.

Actually, I think the second one has the option to use the /cache/partition

anyway, been too busy to poke my nose the code much
[Android Software/Hacking General [Developers Only]] defiant07:
Weird, I googled the error ("swapon invalid argument") and it seemed its cause was either the user did not mkswap or a bad rom...I did not find anything related to filesystem. From past research I was under the impression that filesystem type was only a factor when using swap partitions, but I am probably mistaken.

Thanks for those links (never saw these scripts before...I don't search the device specific forums), they seem interesting, especially the first one...I will dig through those codes as best I can and see if there's anything of use.
[Android Software/Hacking General [Developers Only]] clnzx2:
I keep getting function not implemented when trying to enable swap. Any ideas?
[Android Software/Hacking General [Developers Only]] eushaun99:
Wait a minute, you said

swapon /storage/emulated/legacy/swapfile

?

I'm so sorry, my stupidness caused so much confusion for you. I thought you just wanted me to type swapon. *facepalm*

To clear things up, actually

swapon /storage/emulated/legacy/swapfile

did give me the invalid argument error. So sorry about that. :p

The test version you attached also give the invalid argument, and also a stat thing.

swapoff: can't stat '/storage/emulated/legacy/swapfile/swapfile': Not a directory
360+0 records in
360+0 records out
377487360 bytes transferred in 13.780 secs (27393857 bytes/sec)
Setting up swapspace version 1, size = 377483264 bytes
UUID=72010f65-d01a-41b5-a3ef-0f6121d2433a
swapon: /storage/emulated/legacy/swapfile: Invalid argument

Many thanks for all you and zep's efforts to help me. Somehow I think that this is actually user error given my carelessness. I'm trying to figure out maybe I have done something wrong that could have lead to this error?
[Android Software/Hacking General [Developers Only]] defiant07:
I have a few based upon a quick google search, although a screen shot or code box containing the script's dialog would be useful...

(1) the most common cause of this error is that your kernel does not support swap, but if this is the case you should not have made it far enough in to the script to see that error. just to double check if you enter this command cat /proc/cpuinfo in terminal does it list 'swp' or 'swap' under 'features'?

(2) it could be busybox related. do you have a "swapon" file located in /system/bin or /system/xbin?

(3) it could be a filesystem issue. if this is the case I think you will need to use a script or app that uses a partition or different location.

I will edit this post in the near future and attach a test version, which may help if it is a filesystem related issue.

I think my overly verbose posts played a part in the confusion...I know they have annoyed Zep in the past, lol :eek:.

Naw, it's not an user error...you did not get the dreaded ID10T error, lol :p. It seems to be a filesystem related issue, plus I think the fact that jb mirrors the filesystem in two locations because of its multiuser feature makes things get screwy.

I will edit this post in the near future and attach a test version incorporating Zep's fix, which will hopefully resolve this issue by making the swapfile on your actual external sdcard.

=====EDIT=====

##### Attached Test Version That May Resolve Swapon Related Errors #####​

##### It Should Make The Swapfile On Your External Sdcard #####​
[Android Software/Hacking General [Developers Only]] eushaun99:
Maybe. :D But then again I have a troll brain which always make me think stuff differently.

So to clarify things, now the swap file isn't working until I reboot, right? Typing free in terminal shows 0 for total, used and free. If its working, I suppose total should be the size of the swapfile which is 360 mb right?
[Android Software/Hacking General [Developers Only]] defiant07:
Nope...it is not working at all. It would have worked after reboot if the swapon /storage/emulated/legacy/swapfile command had worked, but since it did not I can definitively say nothing is working for you...you should delete the swapfile and swappinessvalue files located in /storage/emulated/legacy...they are just wasting space...you can leave the init.d script and xbin script as they will get overwritten should you give the test version a try.

=====EDIT=====

Sorry forgot to address your last question about free...yeah if swap was on you would have numbers in the 'total' 'used' and 'free' columns in the 'swap' row...also note the output of free is in kb so you'd have to divide by 1024 to get mb, although if you use free -m it will give you the output in mb.
[Android Software/Hacking General [Developers Only]] defiant07:
Weird indeed...I am using the same busybox and the test script runs flawlessly...no problems with stat.

I think probably the new means of detecting the storage location is not working for you...please try

storage=`busybox mount | awk '/vold/&&/sdcard/{print $3}' | awk 'NR==1'`
echo $storage

you should get something like /mnt/sdcard. If you do NOT get a storage location from this series of commands then the two errors you got would be expected. If you do get a storage location then I'm at a total loss.

Also if you do NOT get a location from these commands try replacing "sdcard" with "ext" so it would be

storage=`busybox mount | awk '/vold/&&/ext/{print $3}' | awk 'NR==1'`
echo $storage

and lmk if you get a storage location.

If both these sets of commands fail to return a storage location please give me the output from the mount command. It will be pretty long since I know you have a bunch of apps, I only need the first 25% or so of the output, which should make it bit easier for you to cut and paste.

Thanks again for your testing and feedback...good night...I will return to the grindstone tomorrow.
[Android Software/Hacking General [Developers Only]] clnzx2:
1. My kernel does support swap.

2. I have swapon and swapoff in both locations and tried installing busy box again as well

3. I tried swapon /storage/emulated/legacy/swapfile add well as swapon /storage/emulated/0/swapfile which should both get to the same file but i get function not implemented.

In the script I get the error when it does swapoff and of course when it does swapon

Thanks for the help
[Android Software/Hacking General [Developers Only]] eushaun99:
Yes, no storage location, but it showed a blank line instead. Did I do something wrong?

I don't know exactly where you want, so heck, here's the whole output. :p

http://pastebin.com/VTpVfUmF

Take a good rest my friend. You've definitely deserved it. :)
[Android Software/Hacking General [Developers Only]] zeppelinrox:
Umm... Easier way to get free space...

freemb=`busybox df -m | grep $storage | awk '{print $((NF-2))}'`
[Android Software/Hacking General [Developers Only]] zeppelinrox:
You don't actually have an external SD card, do you?
[Android Software/Hacking General [Developers Only]] eushaun99:
No I do not. The galaxy tab 10.1 doesn't have any external SD card slot.
[Android Software/Hacking General [Developers Only]] zeppelinrox:
So you can't have swap on something that you don't have.

I just read this

http://android-revolution-hd.blogspot.ca/2013/03/virtual-sd-card-on-android.html?m=1

You probably have the second configuration.

Do:

ls -l /data/media/0

Is that the stuff that's on your fake/internal "sdcard"?

If so, do:

swapon /data/media/0/swapfile
[Android Software/Hacking General [Developers Only]] eushaun99:
Hey it works now. I reflashed v4, ran swapit to create the swapfile then swapon /data/media/0/swapfile and no more errors. Free command also shows swap being used. Thanks so much zep and of course defiant07. :)
[Android Software/Hacking General [Developers Only]] clnzx2:
Any more ideas for my situation?
[Android Software/Hacking General [Developers Only]] hootnath:
manually creating /dev/swap , setting permissions to 777 :) and then using SetXperia work fine with /dev for me. BUT. that messes up stuff on reboot since permissions aren't manually re-established on reboot before whenever SetXperia does its thing - which causes it to create the swap and either freeze the system or cause reboots (i assume, once the swap file is tried to get accessed).

i don't think that the partition is in the ram. it looks like a tmpfs partition that is just temporary, albeit still on the disk. the internal NAND is supposed to be 1gb. 420 for /data 400 for /system and the 180mb in /dev explains the remainder. o.k. i just realised htat there is a 100mb cache as well. now i am confused.

putting a single /swap folder and a file in it doesn't do much harm. no one is wiping anything else anyway. plus, good thing its tmpfs.

i use SetXperia for swap in /cache I still have to set /cache/swap 's and /cache/swap/swapfile.swp's permissions manually for it to work properly.
[Android Software/Hacking General [Developers Only]] defiant07:
Guess so...it's not getting the number right as Zep realized...yet another fix to his credit :laugh:.

He was trying to get you to run it in debug...although it's a moot point now, you could have also deleted the hash tags at the beginning of lines 9 and 10 in script to produce a debug log.

Interesting...much thanks :highfive:....again ;).

Too lazy to update OP now, but give the attached version a try (note: it's NOT flashable); I made the edits recommended by Zep.

I don't think the freeze/reboot problem is due to permissions; it's likely due to the swap file being recreated during the boot process (other users have reported similar issues when the swap file is remade during the boot process even in less volatile locations...it seems only certain roms/devices tolerate this).

Umm, everything I've read says /dev is in ram, although much of what I read was forum posts, which could be unreliable. Also, I am quite certain tmpfs is in ram peep the WIKI (I assume what's said about linux is true for android).
[Android Software/Hacking General [Developers Only]] hisname:
well.... since there isn't any error message nor any funny output, I guess it works?
[Android Software/Hacking General [Developers Only]] hootnath:
It turns out that my device has a "reserved" 80mb partition, a 12.5mb boot, a 400mb system, a 420mb data, a 6mb appslog and a 101.5 cache partition. JFYI.

The /dev has to be in the RAM. Like your link says. Mount shows just tmpfs mounting to /dev. Makes sense now why no one was putting the swap in /dev. I wasconfusing it with something else, because of the dalvik2dev script.
[Android Software/Hacking General [Developers Only]] defiant07:
Hopefully its working now...verify with 'free' and/or 'cat /prop/swaps'...play a game that lags without swap and see if it's smoother.

:p:D
[Android Software/Hacking General [Developers Only]] jam90:
Hi! does this script works on kitkat 4.4.2?
[Android Software/Hacking General [Developers Only]] defiant07:
I am not 100% sure as I have not received any reports in these regards, but I think it should work (don't know of any reason why it wouldn't assuming you meet the requirements listed in the OP).

Give it a try and lmk your results; it shouldn't harm your device even if it does not work. But if you have trepidations I think I will finally have time this weekend to setup my new nexus7 so I will test it with KK and let you know.
[Android Software/Hacking General [Developers Only]] jam90:
it doesn't work on kit kat. it create the swapfile but don't use it. can you fix it? thanks, i really need this! XD
[Android Software/Hacking General [Developers Only]] eushaun99:
Pictures/logs/info would be helpful.
[Android Software/Hacking General [Developers Only]] jam90:
i don't have any "logs" folder in pictures!
[Android Software/Hacking General [Developers Only]] eushaun99:
*EPIC FACEPALM* I meant logs OR pictures OR anything that you think would be useful in assisting [MENTION=5146220]defiant07[/MENTION] to get 4.4 compatibility.
[Android Software/Hacking General [Developers Only]] jam90:
I didn't knew what did you meant, 'cause this is the first time i used this script. So, i don't know what to post here for getting you know this. what may i have to post for your knowledge?
[Android Software/Hacking General [Developers Only]] killoid:
[MENTION=5146220]defiant07[/MENTION] excellent script! :good: i don't have to use anymore apps to swap. working great on my galaxy y duos,stock 2.3.6. btw an option to set minfree value as well would be great! this will complete the script!
[Android Software/Hacking General [Developers Only]] eushaun99:
There are two files Ran_SwapOn and BootLog_SwapOn in /data. Rename it to .txt format and attach it here. If there was any errors during swapfile creation you can also post a screenshot of it.
[Android Software/Hacking General [Developers Only]] eushaun99:
I recommend using V6. http://xdaforums.com/showthread.php?t=991276
[Android Software/Hacking General [Developers Only]] defiant07:
If the swapfile was created and the setup/installer script did not abort during the swapfile creation process it should be working. How did you verify the swapfile was not being used? If you used the 'free' command, was the whole bottom row zeros or was at least one of them a non-zero value? Also it is possible swapfile it not being used because there is no need for it; try running a bunch of apps or a graphics intense game and then check if the swapfile is being using.

If it is legit not working, like [MENTION=5113073]eushaun99[/MENTION] said, I need more info...post the logs he mentioned and/or screenshots of the script's output from the part where the swapfile is actually made. Or wait a day or two until I setup my nexus7 so I can first hand test 4.4.2.

Thanks for the kind feedback...why waist ram with an app, right?

I considered a minfree option, but figured most people probably use one of the numerous other scripts/mod packages floating around xda to set their minfrees. Like [MENTION=5113073]eushaun99[/MENTION] suggested, consider using V6 Supercharger it has the best minfree options (you can choose from preset values, values calculated based on ram, or input your own values)...I personally use it :laugh:. However, I will consider adding this option should I find further reasons to update the script.
[Android Software/Hacking General [Developers Only]] jam90:
here you are all screenchot that i think could be usefull...i don't know much about swapping XD could you understand by these?

samsung galaxy wonder, android 4.4.2 (cm11)
[Android Software/Hacking General [Developers Only]] eushaun99:
[MENTION=5270235]jam90[/MENTION] in terminal, do

cat /proc/swaps

Early theory, its not that it didn't work, its just that you're using zram and maybe your device uses zram first then only swap? I'm just guessing because your Ran_SwapOn.log screenshot is too messy to look. :p
[Android Software/Hacking General [Developers Only]] jam90:
the ran_swapon.log it's all there. All that i cutted is:

and then start my screenshot.

anyway, here it is: "cat/proc/swaps + free" in my terminal
[Android Software/Hacking General [Developers Only]] eushaun99:
Right. Now, what doesn't work? There is no problem at all.
[Android Software/Hacking General [Developers Only]] killoid:
yeah,you are absolutely right! :D

i know v6 does better minfree value setting job but i really don't need other options that offers v6. if possible with zep's permission,plz include the minfree value setting of v6 in your script. so i can have only things i need to use! just my two cents. :)
[Android Software/Hacking General [Developers Only]] jam90:
Infact this is my 3° time that i run this script, and now i can feel the differences...and it works so good on kitkat too, i can assure!
[Android Software/Hacking General [Developers Only]] eushaun99:
I really doubt that would happen, since the minfree values are the core of v6. Maybe defiant can experiment with some new values? :D
[Android Software/Hacking General [Developers Only]] killoid:
let's hope for the best! :fingers-crossed:
[Android Software/Hacking General [Developers Only]] defiant07:
Sorry for delayed response was busy Saturday and spent Sunday and today trying to get adb working with my Dirty Unicorns rom...finally gave up and decided to turn my attention to this issue. At any rate...

Based upon the screenshots and as you already figured out both swap and zram are working properly ;). It was probably always working :p.

Okay since there seems to be some reasonable demand for it I will add an option for minfrees :good:. Gimme a week or two :D.

Nice, glad to hear it :laugh:.

I will give it a go and try to come up with some minfree options within a week or two :)...gunna pimp out/fully setup my nexus7/dirty unicorns rom first :eek:.
[Android Software/Hacking General [Developers Only]] killoid:
take your time mate, we have no hurry. :)
[Android Software/Hacking General [Developers Only]] jam90:
problems again

hi, i have problems again.

I've done a pristine because of problems with my rom, i flashed this zip and done everything i do before, when it works.

Now, during the creation, it says that all is good but when i do cat /proc/swaps it don't shows anymore the last string (swaps: "numbers")

what's happened? thank you whoever will help me

[MENTION=5113073]eushaun99[/MENTION] got some ideas? :S

edit (solved, done the same thing for the 4th time, it goes)
[Android Software/Hacking General [Developers Only]] jam90:
is there a way to create it in sdcard0 by default? not in system, data, cache or other folders it says, but just sdcard0...yes, there's custom place, but it gives me problem of unswapping (and sometimes it don't start with the phone, i have to reboot).
[Android Software/Hacking General [Developers Only]] defiant07:
:highfive:;)

Is /sdcard0 an actual (i.e. NOT emulated) external sd card? If yes (and think this is the case), then this 'unswapping' problem sounds like a slow to mount/slow to become accessible swapfile location. The solution is to pick 'yes' when the installer script asks you if you want to add an additional delay to the init.d script.

Is /sdcard0 a fake sd card? If yes (and I doubt this is the case), some roms(JellyBean and maybe KitKat)/devices have issues with swap because of the way they mirror data in various locations. The solution is to use /data as a swapfile location; it is analogous to using /emulate/storage/0, /sdcard0, and other such locations in these cases being that it is the origin of the data reflections.

If neither of these circumstances are applicable, lmk and we can probably find a solution.
[Android Software/Hacking General [Developers Only]] jam90:
i already have the swap file on the external sd and i knew that i had to set "yes" on the delay...infact right now i've got exactly this option...but i find a little bit of lag when the swap file is being used, maybe because of the external sd card.

So I want to use sdcard0 (aka the internal storage ) for the swapfile location and don't wanna use "data" folder 'cause it has just 100mb of free space...while in the internal storage i have at least 1,50 gb of free space...
[Android Software/Hacking General [Developers Only]] defiant07:
Hmm...seems very odd that you have this intermittent 'unswapping' problem using internal storage, especially with the additional delay. The only thing I can think of that maybe the cause is that the delay is not long enough. Edit the tenth line of the init.d script, change it from "sleep 60" to "sleep 120".
[Android Software/Hacking General [Developers Only]] defiant07:
Released v13...minor update...added minfree option.​

[MENTION=5107949]killoid[/MENTION] here it is buddy...enjoy :).
[Android Software/Hacking General [Developers Only]] killoid:
after the latest update, my swap is not working anymore! :( typing 'su free' shows swap 0.here is the bootlog.
[Android Software/Hacking General [Developers Only]] viiron:
Needs work.

Nice script.. Could use a little aesthetic improvement (ansi colors look cool in linux,but like a bunch of garbage in DOS.

So how does one go about safely removing the script? :confused:
[Android Software/Hacking General [Developers Only]] eushaun99:
Type 'unswapit' in terminal.
[Android Software/Hacking General [Developers Only]] defiant07:
You must have updated/changed busybox versions since you last ran the script. Guess the swapon applet does not support the priority flag (-p) in the new Stericson. Solution: Use a different busybox. Should I release a new version I will add a precautionary check for this to the installer script.

Thanks...would your suggestion be to remove the colours? change them? ...bash has fairly limited text effects...can't paint too much with a limited pallet.

To uninstall do like [MENTION=5113073]eushaun99[/MENTION] said, in terminal:

su
unswapit

or if you prefer one-liners: "su -c unswapit" It will do most of the work; use your root file manager to delete the remaining two files "unswapit" (located in /system/xbin) and "swapit" (located in /system/xbin if you flashed it or wherever you put it if you used the other method).
[Android Software/Hacking General [Developers Only]] viiron:
My two cents would be to remove the colors. That way it's uniform across platforms. I've had it installed and turned on for the past few days. Seems to be doing it's job

I have however noticed a bug or two (it's 4am and I'm bored).

1) there was no unswapit script

2) this was cause by /system not being mounted rw during the install

3) line

fails with "busybox: invalid option -- p" even though -p is a valid option for swapon.

Anyhow...some things to look into. :)
[Android Software/Hacking General [Developers Only]] defiant07:
I will consider removing the colours, although it was a pita to add and maintain them :p.

Re 1 & 2: Seems odd that it is working and there was no unswapit in /system/xbin. In order for it to be working the init.d script must have been made, which requires /system to be remounted rw. There is an /system/etc/init.d/Z99SwapOn right??? Were any of the switch swap scripts created in /system/xbin??? On very rare occasions (maybe five times out of the hundreds of times I have run the installer script) the device messes up and some of the scripts don't get created (I think because all the scripts get made so fast sometimes the device falls behind and fubars things)... try rerunning the installer.

Re 3: This is NOT an issue with the script. This is an issue with your version of busybox. Solution - Use a bb that supports the swapon applet's priority flag (-p).

Hope this helps...enjoy :).
[Android Software/Hacking General [Developers Only]] viiron:
Fair enough. You're correct about the busybox version. I can't reproduce the missing unswapit problem so I'll just chalk it up to a fluke. As for the colors... say, go.. as long as the script works it makes no difference.
[Android Software/Hacking General [Developers Only]] defiant07:
Yeah, it's odd how much bb versions can vary.

The missing xbin scripts freaked me out the first time it happened to me...kept rechecking the code, but couldn't find any syntax errors; it was very vexing...took me awhile to attribute it to a device-side-fubar :p.

Regarding colors, I was thinking of only using them for the closing graphic that way they have some more shock/impact.