yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] eushaun99:
So now I have both zRAM and swap installed. I don't see any conflicts but I think zRAM will only start working when there is no more space left to swap. Through the 'free' command I see that I now have 500++ mb of swap as there's 360 mb from swap and 180 mb from zRAM. In PerformanceControl you can see that zRAM is not working when swap is enabled.

PS: This is all just my conclusions. There is a 50% chance that I may be wrong. :p
[Android Software/Hacking General [Developers Only]] defiant07:
Interesting...

I could be wrong, but I am quite certain that those figures from PerformanceControl show zram

is working

...it's just not doing much :p...I think it shows 4 kb have been compressed down to 52 b...I think the used ratio shows zero because 52 b out of 180 mb is more or less zero :silly:.

Not that it really matters (so don't feel obligated to do any testing or anything), but out of curiosity...How many apps did you have running at the time of those screenshots? I bet if you pushed your device harder you'd get higher numbers. Also I wonder two things: (1) if you'd get more zram usage if you decreased the swapfile size; and (2) assuming similar conditions as those in the screenshot if you turn swap off I wonder if the zram usage would be similar?
[Android Software/Hacking General [Developers Only]] eushaun99:
Oops, wrong term used. Should've been not doing much instead of not working..:p Well its more or less the same right? :D

The screenshots was took right after a reboot so it could be possible that you're right, but I've just only checked, the values didn't even move, while swap is being used actively. My guess is that the 4kb is compressed right after a reboot. Before I enabled swap, I saw that the zRAM values went higher than 4kb, so I guess swap will be used first, or at least will be used more than zRAM. I will continue to test and do what you suggested to understand more. :)

I don't mind testing these things. I have 2 months of school holiday to spend so I have all the time in the world to test. :D
[Android Software/Hacking General [Developers Only]] eushaun99:
TEST 1: SWAP DISABLED

I've disabled swap, rebooted, and walaa, zRAM went more than 4kb. :D

Exhibit A:

This was took right after a reboot after I disabled swap.

Exhibit B:

This was took right after I opened chrome and dolphin browser together.

TEST 2 : SWAPFILE REDUCED TO 30MB

I've set the swapfile size to 30mb, rebooted, checked PerformanceControl, zRAM showed 4kb being compressed and free command showed 20+ mb swapped. I then ran a few apps, checked free, it went up to 40+ mb, which meant there is no more space left to swap. Checked PerformanceControl, zRAM started being used.

Exhibit A:

This was took right after a reboot.

Exhibit B:

This was took after I ran chrome and dolphin at the same time.

Conclusion: zRAM will only work properly when there is no more space left to swap.

Man, this is like my school's science report. :D

==========================================================================

Reading the thread hisname linked to you in v6 made me wonder...if its possible to create the swapfile in /cache since I have 400+ mb of wasted space in /cache? That would save the space in my sdcard and if I understand correctly, the read/write in cache is faster than /data right?
[Android Software/Hacking General [Developers Only]] hisname:
yea, what a waste of free space in /cache huh?
[Android Software/Hacking General [Developers Only]] eushaun99:
Yup, the only thing in my /cache is the last_log for recovery. But I'm quite curious where 7mb gone since that file is only 14kb.
[Android Software/Hacking General [Developers Only]] defiant07:
Yep, looks like swap takes precedence over zram. What a good xda scientist; you get an A+ on your report ;)...so many lovely pictures :p.

Yeah you could set it up in /cache by using the custom location option, although you may run into issues with permissions being that /cache has different permissions than /data (I could be wrong...never tried it personally).

Also that space is not really wasted; it is used for downloading stuff. So if you were leave little or no space in /cache you would not be able to download from the playstore. If you decide to try /cache be sure to leave at least 20 mb of free space (from what I have read in other threads this should be enough to avoid problems).

Regarding read/write speeds of /cache vs. /data: I do not know for sure, but assuming there are no tweaks I think they would be the same being that they use the same filesystem (ext4 on most devices I think; use the "mount" command in terminal to check if you want). On the other hand being that a lot of mod packages tweak /data maybe /data would be faster on modded/tweaked devices, but again I do not know for sure.
[Android Software/Hacking General [Developers Only]] Pos411:
ok...finally i decided to add your script 2 days ago...and the cf-bench was good [21240,4124,10970]...in the V6 thread you said...

so i decided to use "20" when i install your script...untill today there's no problem [MENTION=535343]all[/MENTION]...and yes i'm using KAK too....

my questions is...referring your sugestion to use, 1-50 is for multitasking and 50-100 is for gaming...can i use numbers like...25,51 or 75 ? or it must be 20,50 and 70...and when i use that number eg,25. do i have to change V6 script to...i hope you can understand, coz english is not my native....peace! :fingers-crossed:
[Android Software/Hacking General [Developers Only]] defiant07:
Sorry for the delayed response; it was a hectic weekend and I spent much of my free time updating this script :D.

Yes, you can use any integer from 0-100 as the script states :p...if you want to use values that are NOT multiples of 10 you must either rerun the base setup script or manually edit the init.d script (for future boots) and change the value via terminal (for current session)...you are only restricted to multiples of 10 when changing the value with the 'switch swap scripts.'
[Android Software/Hacking General [Developers Only]] defiant07:
Released v12...Major Update​

The most notable changes are the ability to create multiple prioritized swap files and the elimination of the need to uninstall before changing the swap file configuration (size, location, and priority). Thanks to [MENTION=4729636]hisname[/MENTION] for these suggestions.

For those interested in the details: The priorities are set to 32000 (primary swap file), 16000 (secondary), and 0 (tertiary); see HERE and HERE for more info on multiple swap files and priorities.

Note: If updating you will go through a 'cleaning' process the first time you run it and you will be forced to go through a fresh install process...sorry for the inconvenience.
[Android Software/Hacking General [Developers Only]] hootnath:
how about an option for /dev? it's swapfile would need to get recreated and permissions set for every time though. i had used a /data/dalvik-cache move to /dev once that worked like a charm - something like that, perhaps. it was called Mover_Dalvik_Cache.rar from http://dl.xda-developers.com/attach...5281d9ee/1/4/6/5/0/6/4/Mover_Dalvik_Cache.rar
[Android Software/Hacking General [Developers Only]] eushaun99:
V12 running great here, swapfile made at /cache, no issues at all. Keep up the good work! :good: :D

Unfortunately, it means your kernel does not implement 'swap' properly and there's no way to fix that unless you can get a kernel dev to implement it properly.
[Android Software/Hacking General [Developers Only]] hisname:
just ran the script. only created swap in /system even though I chose /data and /cache and /system
[Android Software/Hacking General [Developers Only]] defiant07:
The reason you pass the test at the beginning of the script is because the output of 'cat /proc/cpuinfo' lists swap as a feature. However, what I have found is that some kernels only partially implement swap; you can make and format the swap file, but you cannot turn swap on/off because the dev messed something up. Hence, in v12 I added a check for this "Function not implemented" error.

Sorry, but like script says you're SOL.

No promises, but I will look into this and do some testing. btw that link is bad.

Nice, thanks for the feedback.

Hmm...sounds odd. Did you notice any errors during the part where swap files and other stuff actually gets made? Post the the script's output.

EDIT: Just read your posts in the V6 thread, did this issue occur on that rom? If yes, post the output from "mount"...I bet it's a similar/related issue.
[Android Software/Hacking General [Developers Only]] hootnath:
here, it should be attached with this post.
[Android Software/Hacking General [Developers Only]] Pos411:
thanks bud...haturnuhun sadayana... :) andromax U LE not very recommended...no devs for this kernel...:( and it's lock too...

oh well...than...anyway thanks and keep up the good work to help the community :good:
[Android Software/Hacking General [Developers Only]] zeppelinrox:
I'm pretty sure that you only know enough to be dangerous/break things.

/trolled!
[Android Software/Hacking General [Developers Only]] eushaun99:
I think I found a problem. I made the swapfile at 3 locations, system, data and cache. In the log file, I see that the swapfile in /system isn't working since it has the read-only file system error.

Edit: deleted the whole part of the script that mounts back to ro before swapon and it works now.
[Android Software/Hacking General [Developers Only]] defiant07:
cool, thanks.

Sorry again :( and thanks for kind words :).

lol

Egads man, that's one screwy rom you got...

It can't do math...

/storage/emulated/0/SpeedSoftware/Extracted/swapit[565]: 0
2193 - 20: unexpected '2193'

...which in turn leads to it not taking input for for the second and third swap file sizes...so since it does not have those two sizes it leads to this:

dd: invalid number ''
dd: invalid number ''

and this:

mkswap: can't open '/cache/swapfile2': No such file or directory
mkswap: can't open '/data/swapfile3': No such file or directory

Also your busybox does not support the -p flag for the swapon command, hence:

unknown option -- p
BusyBox v1.21.1-jb bionic (2013-07-25 21:23 +0100) multi-call binary.

All the other errors are being caused because /system isn't getting remounted r/w for some reason.

Are you getting similar errors when you run V6?

Nice catch...damn, I thought I did thorough testing, but I neglected to test /cache and /system following a reboot. Thanks :highfive:.

Be aware deleting those lines will cause the swapXXX scripts to not work properly and if you run one of them it may mess up the init.d script.

If you want to fix it re-add that r/o stuff after the swapon stuff...I will release a FIX version tomorrow after I test it :p.
[Android Software/Hacking General [Developers Only]] eushaun99:
Got it, thanks! :)
[Android Software/Hacking General [Developers Only]] hisname:
Things aren't going too well. I installed busybox by Sterison and the script couldn't take it.. lol

==============================================

Hi. Thanks for using...

//----------------------------------------//

// Defiant07's SwapItOn //

//----------------------------------------//

Hope you like it!

==============================================

Okay, first gunna check if busybox has the

required applets, if you are running as root,

if /etc/init.d exists, and if your kernel

supports swap.

/storage/emulated/legacy/SpeedSoftware/Extracted/swapit[80]: /system/xbin/busybox: not executable: magic 0005

No Busybox - No Swap for You!

Install busybox and try again...bye :p.

==============================================

when using zeppe-linario busybox,

exec /system/bin/sh '/storage/sdcard1/SpeedSoftware/Extracted/SuperCharger_Starter_Kit_RC12/SuperCharger_Starter_Kit/busybox_v1.19.4_wraithdu_installer_v14.sh'

exec /system/bin/sh '/storroot@jfltetmo:/ # exec /system/bin/sh '/storage/sdcsdcard1/SpeedSoftware/Extracte arger_Starter_Kit_RC12/SuperCharger_Sta rter_Kit/busybox_v1.19.4_wraithdu_insta ller_v14.sh'

-=zeppelinrox=- presents...

#############################################

# BusyBox v1.19.4 (wraithdu) Installer v14 #

#############################################

This installs BusyBox v1.19.4(wraithdu)...

...to it's default location or /system/xbin.

=============================================

/storage/sdcard1/SpeedSoftware/Extracted/SuperCharger_Starter_Kit_RC12/SuperCharger_Starter_Kit/busybox_v1.19.4_wraithdu_installer_v14.sh[87]: 53%: unexpected 'end of expression'

System Partition has 53% Free (/system Used)

Ideally, and to be safe, free up 2.5 MB

#############################

# Make Space & Try Again! #

#############################

edit:got it working . so the command to un install is su - c unswap right?
[Android Software/Hacking General [Developers Only]] defiant07:
Nice, good to hear it.

Yeah that's the uninstall command.
[Android Software/Hacking General [Developers Only]] defiant07:
Released v12_fix...a day later than hoped...​

fixed r/o issue in init.d script when using /system that caused swapon error - thanks to [MENTION=5113073]eushaun99[/MENTION] for bug report

Also since I did reboots to test things this time (:p), I noticed that when using /cache the swap file gets deleted (by android) a recreated (by the init.d script) every reboot. It was not a problem for me, but based some past bug reports it may be an issue for some devices/roms. Thus, those of you that actually read these silly post, be warned /cache my NOT work and even cause problems for some users. I will add a warning to the OP and/or script should I get any reports of such.

============

[MENTION=4242632]hootnath[/MENTION] - Did some research and testing with regards to /dev. My conclusion is twofold: (1) it's not possible, I tried a multitude of different combinations of permissions and ownerships, but could not turn swap on [I kept getting invalid argument errors]; and (2) even if it is possible, it would be a counterproductive location being that /dev is located in ram, thereby, it would actually use/waist ram [note: imo putting anything there including dalvik would be bad unless you want to trade ram for space...and although minor, it's annoying that whatever is there needs to be rebuilt every boot]. Should you decide to do some testing on your own and find perm/own combo that works lmk and I will make it so the user can use it as a custom location.
[Android Software/Hacking General [Developers Only]] hisname:
/dev contains really low level OS stuff.you would not want to touch it. it is a mess if something were to go wrong
[Android Software/Hacking General [Developers Only]] eushaun99:
Weird. I moved your init.d script to sdcard to test and reboot and the swapfile is still in /cache. Guess I'm one of the lucky ones. :p
[Android Software/Hacking General [Developers Only]] defiant07:
Yeah, you're one of the really lucky ones; apparently you're cache partition does not get wiped every reboot so the swap file does not need to be rebuilt, thereby, totally avoiding potential issues.

Those are the same errors you posted last time minus the ones stemming from /system not being remounted r/w.

The problem is your roms do not seem to like math. What do you get if you do:

echo $((200 - 20))
[Android Software/Hacking General [Developers Only]] hisname:
hey! it can do math

u0_a44@jfltetmo:/ $ echo $((200-20))

180

u0_a44@jfltetmo:/ $
[Android Software/Hacking General [Developers Only]] zeppelinrox:
Do

sh -x /path/to/swapit
[Android Software/Hacking General [Developers Only]] hisname:
u0_a44@jfltetmo:/ $ su

root@jfltetmo:/ # sh -x /path/to/swapit

sh -x /path/to/swapit

sh: /path/to/swapit: No such file or directory

127|root@jfltetmo:/ #
[Android Software/Hacking General [Developers Only]] zeppelinrox:
That's so wrong.

/path/to does not mean what you think it means.
[Android Software/Hacking General [Developers Only]] hisname:
I'm thinking what it means :p

---------- Post added at 11:02 PM ---------- Previous post was at 10:23 PM ----------

u0_a44@jfltetmo:/ $ su

root@jfltetmo:/ # sh -x /system/swap

sh -x /system/swap

sh: /system/swap: No such file or directory

127|root@jfltetmo:/ #
[Android Software/Hacking General [Developers Only]] zeppelinrox:
oh for the love of god...

just copy the swapit script to the sdcard and do:

sh -x /sdcard/swapit
[Android Software/Hacking General [Developers Only]] hisname:
here
[Android Software/Hacking General [Developers Only]] zeppelinrox:
Do:

busybox df -m

Regardless of the output, this code isn't 100%

freemb=`df -m | grep $storage | awk '{print $((NF-2))}'`

1. Should specify busybox df at the beginning as some roms have a crappy df in /system/bin...

sh-4.2# df -m
df -m
Filesystem Size Used Free Blksize
-m: No such file or directory

However, that's not the issue in this case.

2. grep $storage should be grep " $storage" (a preceding space is included)

Why?

sh-4.2# storage=/system
storage=/system
sh-4.2# busybox df -m | grep $storage
busybox df -m | grep $storage
/dev/block/platform/msm_sdcc.1/by-name/system
1476 550 926 37% /system

The output isn't always on 1 line, have multiple hits, and can therefore have weird results.

sh-4.2# busybox df -m | grep $storage | awk '{print $((NF-2))}'
busybox df -m | grep $storage | awk '{print $((NF-2))}'

926
sh-4.2#

Note the blank line above the result we want.

By including that preceding space, the output is more reliable

How it looks with the tweaked code...

sh-4.2# busybox df -m | grep " $storage"
busybox df -m | grep " $storage"
1476 550 926 37% /system
sh-4.2# busybox df -m | grep " $storage" | awk '{print $((NF-2))}'
busybox df -m | grep " $storage" | awk '{print $((NF-2))}'
926
sh-4.2#
[Android Software/Hacking General [Developers Only]] hisname:
bla bla bla. just spoon feed me with the answers. tell me what to do next

using sterisson busy box

u0_a44@jfltetmo:/ $ su

root@jfltetmo:/ # busybox df -m

busybox df -m

Filesystem 1M-blocks Used Available Use% Mounted on

tmpfs 904 0 904 0% /dev

tmpfs 904 0 904 0% /mnt/secure

tmpfs 904 0 904 0% /mnt/asec

tmpfs 904 0 904 0% /mnt/obb

tmpfs 904 0 904 0% /mnt/fuse

/dev/block/platform/msm_sdcc.1/by-name/persdata

9 4 5 47% /persdata/absolute

/dev/block/platform/msm_sdcc.1/by-name/cache

2037 36 2002 2% /cache

/dev/block/platform/msm_sdcc.1/by-name/system

2717 1438 1278 53% /system

/dev/block/platform/msm_sdcc.1/by-name/userdata

9351 8830 521 94% /data

/dev/block/platform/msm_sdcc.1/by-name/apnhlos

86 9 77 10% /firmware

/dev/block/platform/msm_sdcc.1/by-name/mdm

86 50 36 58% /firmware-mdm

/dev/block/platform/msm_sdcc.1/by-name/efs

13 4 9 31% /efs

/dev/fuse 9351 8830 521 94% /mnt/shell/emulated

/dev/block/vold/179:33

15186 8647 6538 57% /storage/sdcard1

root@jfltetmo:/ #
[Android Software/Hacking General [Developers Only]] zeppelinrox:
Edit the script as specified under bla bla bla.

There are actually 3 "df -m" lines that need to be changed.

Or wait for an update :D
[Android Software/Hacking General [Developers Only]] defiant07:
Thanks for the info/reports.

Both remount commands are valid, but I guess some devices only like certain variations of the command…guess which one mine likes, lol. At any rate at least this problem is solved.

Regard the invalid argument: I am thoroughly bewildered :confused: since that swapon command worked. The proper usage of swapon, swapoff, mkswap, and a whole bunch of other commands used in my script is

<command> <location of a file or directory>

The commands giving you errors are

swapon $storage/swapfile

and

swapoff $storage/swapfile

And since $storage is, in your case, a variable for /storage/emulated/legacy I really cannot see why its giving you those errors, especially since the $storage is used frequently throughout the script (for example the command right before the swapon command is “mkswap $storage/swapfile” which is working properly according to your output).

The fact that you’re getting invalid argument errors for these two commands will result in two things: (1) the very first time you ran “swapit_v4” swap was NOT turned on in that session unless you did that swapon command in the same session [but for all subsequent sessions (i.e. after all future reboots) it WILL/should be turned on being that if you look at the init.d script it should contain the long version of the swapon command that seems to work for you…check with the --free-- command you should see swap being used]; and (2) if you run “swapit” in future sessions you probably will NOT be able to change the swapfile size because if swap is not turned off you cannot delete the swapfile…if you want to change the swapfile size you’ll probably have to do this command

swapoff /storage/emulated/legacy/swapfile

before rerunning “swapit”.

I will continue looking in to this problem, but thus far my research is drawing blanks. I doubt it is busybox related since the mkswap command does not return an error, but I suppose it is possible for whatever reason the swapon and swapoff applets in your busybox don’t like variables…you could try the one from the V6 starter kit, it’s the one I use.

I’m sorry this is beyond my knowledge, I feel bad such a cool user is having problems :crying:. I attached a custom version that uses the long versions of the commands for swapon and swapoff, which should give the script 100% functionality for you :good:…it’s flashable since I see you’re using that option.
[Android Software/Hacking General [Developers Only]] zeppelinrox:
Ya it reflects placebo tolerance... yours may be on the low side... lol

The problem is with the fake "external" sdcard which is really internal.

Reposting from the V6 thread...

About the other thing... it's not a busybox thing.

And I doubt either command would work if $storage is really the internal sdcard and not a "real" sdcard ie. a truly external one.

Did some quick testing and the trick is to find the real external sdcard which will have a vfat file system

So here you go...

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

I added the awk 'NR==1' (same as head -n 1 but why use a second tool :p) to limit the result to one hit - and I couldn't find a simple way to have awk do everything at once - limit it to one hit while searching for the pattern... so that'll do

It will also work if you change vold to vfat but I think vold is less likely to get stale with age.

oh and one more thing... gotta love teh awk :cool:
[Android Software/Hacking General [Developers Only]] defiant07:
Damn dude, thanks again, did not expect all that extra effort - testing commands and what not; I was only expecting a yes or no :highfive:.

That code is beast...wish I had your command of the commands :silly:. I will use it to define storage in the next update...think I'm gunna add powershift style scripts to allow the user to more easily change swappiness on the fly. I'd run out of ideas for improving this script if it wasn't for you and V6, lol.

I'm still a bit confused though as to why your new code defining storage may solve his problems being that I asked him to manually do

swapon /storage/emulated/legacy/swapfile

and he said he got no errors, plus the mkswap $storage/swapfile command in the script did not return any errors. If that custom version does not work for him, I'll make a test version for him to see if redefining storage helps. nvm guess maybe it's a jelly bean related issue due to its multi-user feature?