/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this ROM
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
I could not find anything to disable zram so I have written a kernel patch to update it.
Flash the file fstab_edit.zip (attached) using TWRP, take a backup of boot.img before.
This can be done after every installation of custom rom.
This will disable the zram in your device, suppose to perform better.
Commented in fstab.qcom
#/dev/block/zram0 none swap defaults zramsize=268435456
Tip: Try to minimize applications running under Developer Options -> Running Services
Hi, for what exactly works disable the ZRam?
Disabling zram will give extra 255mb of RAM which is used by Moto G kernels as swap.
sounds interesting... anyone tried it yet?
prime3sdro said:
Disabling zram will give extra 255mb of RAM which is used by Moto G kernels as swap.
Click to expand...
Click to collapse
Note that zram is not swap. zram is a section of ram that contains only compressed data, giving you extra memory at the cost of CPU. swap is when you use storage space as extra memory, more often then not swap will be much slower then zram, and both can actually be enabled at the same time.
tl;dr, this script results in less data being able to be stored in memory, but the data that is stored can be accessed much faster as it is on the ram and not in a compressed state or storage. This is why the op recommends limiting running services.
Thank you for your effort. Do I need to flash the zip again after every update of LOS?
Extralars said:
Thank you for your effort. Do I need to flash the zip again after every update of LOS?
Click to expand...
Click to collapse
Yes.
can you make one for moto g 4g (peregrine)
If you're a heavy multitasker keep zram enabled, it provides more ram through compression (better yet go for a kernel providing lz4 zram compression, it will be even faster).
If you don't need extra ram disable it, there will be some performance improvement.
Related
Hi everyone... have a question... It's possible to enable swap support on our droids? and if it's how?. Because I'm tired of everytime a switch from one app to another it kills one of them. Thanks!
bump, after a long search it seems to be imposible because current kernel don't have have swap support and with a locked bootloader we can't change the stock kernel, i hope some day motorola unlock our droids bootloader or someone can do it . If i'm wrong please let me know. Thanks!
I activated a swap file on my Droid 3 using mkswap and swapon as root from the command line. The kernel recognized the swap space, but as soon as the phone ran out of memory and tried to swap something, it rebooted.
I'd be interested in hearing if anyone else has had a different result.
rblanca said:
Hi everyone... have a question... It's possible to enable swap support on our droids? and if it's how?. Because I'm tired of everytime a switch from one app to another it kills one of them. Thanks!
Click to expand...
Click to collapse
nicktastique said:
I activated a swap file on my Droid 3 using mkswap and swapon as root from the command line. The kernel recognized the swap space, but as soon as the phone ran out of memory and tried to swap something, it rebooted.
I'd be interested in hearing if anyone else has had a different result.
Click to expand...
Click to collapse
It suprised me that kernel recognize you the swap space...do you create swap file in your internal memory or a sd memory?
Edit: I tried this morning but i have the same results as you... as soons it starts to use virtual momery it rebooted.
edit: Well i play with swappines but same results as soon our device started to use swap it rebooted..perhaps someone with more knowlegde can do something about it...it would be great if someone can do it.
Like all file systems, support for swap must be coded in the kernel (it's not), or added by kernel modules . . . Which would have to be specifically compiled against OMAP4 source code, I think, to work. I'm not a programmer, so I can't help directly. See if whoever provided the community the tun.ko kernel module for D3 can whip us up a swap module. Still, our kernels are locked, so the swap.ko would have to be added to a /preinstall aka 2nd-init kernel. Maybe Hashcode can help?
BTW: this thread should be in development, not General, I think
Sent from my DROID3 using xda premium
I use swap all the time. For instance, currently my phone has 111M RAM free and is using 162M of swap.
I've created a swap partition on an SD card and use that, so no swap file.
白い熊 said:
I use swap all the time. For instance, currently my phone has 111M RAM free and is using 162M of swap.
I've created a swap partition on an SD card and use that, so no swap file.
Click to expand...
Click to collapse
do you have your droid 3 with stock rom or other?. Thanks
I used swap on the stock ROM, currently running the Brazilian Vivo ROM, on 860.
白い熊 said:
I used swap on the stock ROM, currently running the Brazilian Vivo ROM, on 860.
Click to expand...
Click to collapse
Thanks dude, but same story as soon as it start to use swap partition it rebooted... it seems there is something missing on xt862 kernel's
Seems there must be some diff between 860 and 862...
白い熊 said:
Seems there must be some diff between 860 and 862...
Click to expand...
Click to collapse
Yes, it seems...one more favor...can you tell me your full Kernel version and your Android version? Thanks
2.6.35.7-g9f70789
[email protected] #1
and
2.3.5
白い熊 said:
I used swap on the stock ROM, currently running the Brazilian Vivo ROM, on 860.
Click to expand...
Click to collapse
Yes, please explain what you did to obtain Swap. The last Android device I had with functioning swap was the G1/HTC Dream, and we had swap because custom kernels had support for it an modules created the fs every time android booted. Whether a swap partition was created and mounted was up to the rooted user. I have used the makeswap and swapon commands with busybox from the command line and could not get the swap partition to show up in mount. Which address block did you use to create the partition? I tried /dev/mmcblk1p025 and 26 (sdcard and emmc?) and neither worked.
BTW: Many intelligent minds say swap in Android is useless since the Java/DalvikVM is so aggressive about reclaiming memory (just watch logcat to see that happening non-stop). You would have to swap to a device that is as fast as your secondary storage (meaning the 512mb of DDR2 installed in the XT862) in order to "beat" Dalvik's garbage collection and "augment" the natural AndroidOS memory management. One of the gifts of running bytecode in Java is that one does not usually address RAM directly (unless you jump out of Java with some C/C++ code), the OS is always handling your classes-to-registers allocation for you, the developer. In other words, it's Android's job to manage your memory, and if you ask the linux kernel and file system to cache registers to the comparatively "slow" sdcard (flashmem is slower than DRAM), you'll essentially be blocking Android's ability to handling your instructions, data, and files because it will then have to go pick up that data from a slow swap partition. When we were trying to push the G1's limits (which was delivered with a paltry 64mb of userdata space), swap made sense because the time it took to request stuff from swap was much slower than recreating threads out of compcache (compressed and old handles). 512mb is still relatively big for a device, and Android, like Linux, will always buffer most of your memory to make sure you don't run out of space for your apps. I am not a programmer so I may have messed up some of the finer points--but this is the gist of Android-vs-Swap as some see it.
rynosaur said:
Yes, please explain what you did to obtain Swap. The last Android device I had with functioning swap was the G1/HTC Dream, and we had swap because custom kernels had support for it an modules created the fs every time android booted. Whether a swap partition was created and mounted was up to the rooted user. I have used the makeswap and swapon commands with busybox from the command line and could not get the swap partition to show up in mount. Which address block did you use to create the partition? I tried /dev/mmcblk1p025 and 26 (sdcard and emmc?) and neither worked.
Click to expand...
Click to collapse
Swap will have to be setup on the external sdcard, which is /dev/block/mmcblk0p
mmcblk0p1 - * would be the partitions
Exactly, setup a swap partition on an ext SD card, then swap on it. Never had a prob.
I don't really care about Android memory usage and management, I need swap because I run GNU/Linux in a chroot, and for that the measly 150M that the Droid 3 has free by default is useless...
I really like DROID 3 and would get it but 512 of RAM and locked bootloader are killing me. But I can't imagine a better device than this one if those two factors didn't count.
Please tell me that something can be done with ICS, low RAM and custom kernels?
ICS runs good and the only reason I tweak my memory settings is just because Words with Friends is a battery hog and so is FB sometimes. I never seem to run out of RAM.
If you like the keyboard, why not get a Droid 4?
Sent from my DROID3 using xda premium
Droid 4 doesn't support GSM networks and I am from Europe where most of the carriers are GSM and so is mine. Droid 3 xt862 is a global phone (both CDMA and GSM) and Milestone 3 xt860 - GSM only. Besides Droid/Milestone 3 looks much better than D4 as for me.
[DEV-HINT] Implementing a swap partition or swap file for new and old bootloader
Wikipedia defines swap file (or paging) as: "[..] use disk storage for data that does not fit into physical random-access memory (RAM)."
With CM10 or CM10.1 around, the 'about phone' screen usually shows 343 MB of usable RAM on the LG-P990, so one gets ideas. With CM9 it was a bit better, but still.... Take Chrome for example: nice to the eye, but not so nice to the RAM of devices that have been around a lot longer than the Nexus 4 with its whopping two Gigabytes. So what's the catch with swap? For example, a HDD swap partition on a PC offers some sort of relief when RAM is scarce by moving some parts of the RAM (pages) to the HDD and moving them back when it needs it. Of course, it comes for a price: performance! But it works. So why not using it on Android too? To hell with the fact that virtual RAM on the internal memory card is a lot slower than physical RAM, there are times when it would be just nice to have the extra megabytes at hand.
Were you a bit envious too when you saw that the 'new' partition layout that came with the ICS bootloader on our beloved LG-P990 had a swap partition included? Well, I was. I even changed to a customized layout to get one for a little while too... But that is not really necessary. Never was, actually. I came back to the original layout and old bootloader weeks ago. What still bugged me was the missing swap partition. CM10.1, CM10 or even CM9 could really use swap from time to time but commonly don't use it.
So, is there really a big difference between the two partition layouts? Yes, but regarding the swap it doesn't count. In fact, the situation for both user groups is pretty much the same: both do not use any kind of swap space whatsoever. First, there are the users with the new bootloader. They have the swap partition but actually don't make use of it. As compared with users with the old bootloader: they may not have the swap partition on their partition table but even they can easily implement a solution very similar to a standard swap partition: a swap file. Then they can benefit as well from some extra Megabytes in certain low memory situations. You don't have a swap partition/file in use yourself yet? In just a few minutes you can change that no matter what bootloader you have.
First you have to find out which bootloader/partition layout is on your LG-P990:
here is how you determine your bootloader/partition layout: reboot!
If you see a pink LG logo when the phone boots then you have the new bootloader/new partition layout (ICS)
If you see a white LG logo when the phone boots then you have the old bootloader / old partition layout(GB)
All commands used in the terminal are shown with a '$'-sign or '#'-sign (root). Copy just the commands without the signs to the terminal, unless stated otherwise.
New bootloader/partition layout (ICS) - Pink LG logo as splash screen - You have the old bootloader/partition layout? Skip to the second part below.
If you are using the new partition layout, then it is easy to use the swap mechanism. The 350MB swap partition is just waiting for you to be switched on.
Use 'adb shell' or the terminal:
check the situation with
Code:
$ free
Does it show 0 0 0 in the swap line? Then swap is not working at the moment and has to be switched on.
Use
Code:
$ su
to get superuser rights
Make the swap partition usable (Be extra careful! Triple-check the command!)
Code:
# mkswap /dev/block/mmcblk0p4
Switch it on
Code:
# swapon /dev/block/mmcblk0p4
Change swappiness to zero at runtime
Code:
# sysctl -w vm.swappiness=0
To keep the swap partition switched on, after reboot and even after flashing ROM updates
create the file /data/local/userinit.sh
Put these lines inside (with the '#' sign)
Code:
#!/system/bin/sh
swapon /dev/block/mmcblk0p4
sysctl -w vm.swappiness=0
swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left.
Save the file.
Now reboot.
Check it via adb shell or terminal if it is working.
Code:
$ free
The swap line should show that 350 MB are available (total/free).
Check the swappiness with
Code:
$ cat /proc/sys/vm/swappiness
It should show 0 now.
Testdrive your work. Start Chrome or a game or whatever uses a lot of RAM on your system. Use it heavily and then check the swap usage of your kernel again with a final
Code:
$ free
Just try it!
Old bootloader/partition layout (GB) - White LG logo as splash-screen
The task is to create a 128 MB Swap-File on the data partition. 128 MB seems enough since it is just for memory emergencies. And it's best to create it on the data partition and not on the sdcard because of the USB mass-storage support that would interfere with any swap file on sdcards. By the way, it doesn't format your data partition. It just makes your usable space of the data partition 128 MB smaller than it is right now. Basically, it creates an empty file with the fixed size of 128 MB and makes it usable as a swap 'partition'. It has the same functionality as a swap partition. And the same speed. And everything else. It just doesn't reside in its own partition. It is even better: when you don't want it anymore or change the size of it, just stop the swap-file with 'swapoff' and delete the file 'swapfile' in your data partition and it's gone for good. Immediately you can use the freed-up space for something else.
Use 'adb shell' or the terminal:
check the situation with
Code:
$ free
Does it show 0 0 0 in the swap line? Then it is not working at the moment and has to be switched on.
See with
Code:
$ df
whether there is enough free space left on /data. 200 MB or more should be free on /data. 128 MB will be used.
Get superuser rights
Code:
$ su
Optional: To see more interesting memory stats you can use
Code:
# cat /proc/meminfo
Now create the file named 'swapfile' with the size of 128 MB
Code:
# dd if=/dev/zero of=/data/swapfile bs=1024 count=128000
This can take a moment.
Limit the rights of the swapfile
Code:
# chmod 600 /data/swapfile
now set up the swapfile for swap usage
Code:
# mkswap /data/swapfile
Switch it on
Code:
# swapon /data/swapfile
Hint: switch off would be swapoff /data/swapfile
Now it is already working!
Tune it to your needs: we just want the swap file to be used in emergencies when there is no RAM left anymore and Android would turn Project Butter in Project Stutter.
Check the status of swappiness
Code:
# cat /proc/sys/vm/swappiness
Default is 60. That is much too high. swappiness=0 lets the kernel use the swap file only when there is no more physical RAM left.
Change it to zero
Code:
# sysctl -w vm.swappiness=0
With this sysctl command you can change the swappiness setting (0-100) on runtime.
If you want to make these settings permanent no matter if you reboot or even flash a ROM update without wiping data then
create the file /data/local/userinit.sh
Put these lines inside (with the '#' sign)
Code:
#!/system/bin/sh
swapon /data/swapfile
sysctl -w vm.swappiness=0
Save it.
Reboot and check it with a last
Code:
# free
in terminal. Now testdrive your swap file with two browsers and a game simultanously or whatever suits your needs to stress your P990.
Just try it yourself!
Have fun!
and another awesome dev thread by Raum1807 :good:
Interested in making a flashable zip out of it? If not I could do it next week.
Just adding everything into one sh-file which gets called by the updater-script - or just via the Terminal.
tonyp said:
and another awesome dev thread by Raum1807 :good:
Interested in making a flashable zip out of it? If not I could do it next week.
Just adding everything into one sh-file which gets called by the updater-script - or just via the Terminal.
Click to expand...
Click to collapse
Thanks for the offer. Thought about that, too. But I think it is more interesting to understand what we are doing here by following it step-by-step. A script makes it too easy... Maybe later, we will see.
sorry for this dumb question.
what's the difference between using this method and using roehsoft ram expander?
both of them have the option to change swappiness and to enable/disable swap from sdcard (roehsoft ram expander can even choose ext sd as swap location)
i don't get it :silly:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
derEremit said:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
Click to expand...
Click to collapse
i don't think so, AFAIK the max reading speed for ext sd is 10 MBps, which is lower than reading speed in our int sd (about 13 MBps). that's why using int one for swapping would be a better choice
please CMIIW, i'm still noobs in this kind of stuff. though, i just want to share what i know
I have one point to this.
You write "swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left."
But there is every time some free space on RAM, because android never let decrease memory to zero.
babi_perang said:
sorry for this dumb question.
what's the difference between using this method and using roehsoft ram expander?
both of them have the option to change swappiness and to enable/disable swap from sdcard (roehsoft ram expander can even choose ext sd as swap location)
i don't get it :silly:
Click to expand...
Click to collapse
- Doesn't use the external sdcard
- Doesn't cost 7 Euro
- gives you an idea how things work
Sent from my LG-P990 using xda app-developers app
derEremit said:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
Click to expand...
Click to collapse
Swapping is only happening when the RAM is critically low. Btw, the swap partition of the ICS partition layout is also located on the internal memory. No difference so to speak. Using this method shouldn't harm the internal memory at all.
Sent from my LG-P990 using xda app-developers app
tomsi91 said:
I have one point to this.
You write "swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left."
But there is every time some free space on RAM, because android never let decrease memory to zero.
Click to expand...
Click to collapse
Yes, the memory management of Android tries to keep the RAM clean while keeping the last few opened apps in the RAM. Four or five running CM10.x on the P990. But the less RAM you have on your phone the harder this balance gets. Imagine memory eating apps like Gallery/Camera or Chrome. They benefit from more memory being available.
Sent from my LG-P990 using xda app-developers app
Thank you for this helpful guide! It is so easy to make it. And now I know a bit much more about Android and RAM.
Gesendet von meinem LGP990 mit CM10.
Hey! This seems interesting but i have a question , before doing this we have 343 RAM available and after all this trouble only 350 ? so thats 7more RAM or am i missing something ?
Soare23 said:
Hey! This seems interesting but i have a question , before doing this we have 343 RAM available and after all this trouble only 350 ? so thats 7more RAM or am i missing something ?
Click to expand...
Click to collapse
Yes, you forgot to read the original post that explains what exactly swap is:
So what's the catch with swap? For example, a HDD swap partition on a PC offers some sort of relief when RAM is scarce by moving some parts of the RAM (pages) to the HDD and moving them back when it needs it. Of course, it comes for a price: performance! But it works. So why not using it on Android too? To hell with the fact that virtual RAM on the internal memory card is a lot slower than physical RAM, there are times when it would be just nice to have the extra megabytes at hand.
Click to expand...
Click to collapse
The reported RAM will remail the same because you aren't increasing your physical RAM.
When i try to creat a swap file, this Error appears:
/def/zero/: canot open for read: Not directory
I'm a superuser
---------- Post added at 09:20 PM ---------- Previous post was at 09:13 PM ----------
After disconnecting from computer it worked!
Swappiness=0 doesn't stick for me after reboot It returns to 60 everytime.
@Raum1807
Awesome thread. Thanks for kindly explaining everything. I learned a lot here!
Ajsh said:
Swappiness=0 doesn't stick for me after reboot It returns to 60 everytime.
Click to expand...
Click to collapse
just put:
echo "0" > /proc/sys/vm/swappiness
at the end of a .sh file in init.d
As we´re talking about using the wasted Swap-Partition:
Is it possible to use it as a "new" kind of Ramhack?
As for now we cut off some shared Ram of GPU to use it as normal RAM. What if we let the GPU use the Swap-Partition as its Memory and get all physical RAM available?
GPU will not perform as good as now, but some People don´t need a Phone to play Games...
Is this possible or restricted to some Nvidia-Libs that are Closed-Source??
zerocoolriddler said:
As we´re talking about using the wasted Swap-Partition:
Is it possible to use it as a "new" kind of Ramhack?
As for now we cut off some shared Ram of GPU to use it as normal RAM. What if we let the GPU use the Swap-Partition as its Memory and get all physical RAM available?
GPU will not perform as good as now, but some People don´t need a Phone to play Games...
Is this possible or restricted to some Nvidia-Libs that are Closed-Source??
Click to expand...
Click to collapse
This is interesting... it could really make a difference , only if it works tho heh.
Sent from my LG-P990 using xda app-developers app
Can we have both Swap and Zram on in CM 10 ? Any possible side effects
SLIMFRESH ROM V11 FOR GIONEE M2
Some features
Features
-----------------------------------------------
*Android 4.4.2
*Dual SIM 3G
*Smooth
*Stable
*Good battery backup
* Android L call style
Good sound enhancement
And lots more.
-Installation instructions---
You must have ctr custom recovery
First take a full ctr backup in case you want to restore your old ROM
Reboot to ctr
wipe all - ( data,cache,system,dalvik) or use preflash wipe option
Install zip from sd card
Reboot
---Your warranty is now void---
I am not responsible for bricked devices, dead SD cards, thermonuclear war, or you getting fired because the alarm app failed. Please do some research if you have any concerns about features included in this ROM before flashing it! YOU are choosing to make these modifications, and if you point the finger at me for messing up your device, I will laugh at you.
Credit goes to slimhouse
ARGN
Thread closed per OP request.
My xiaomi mi max 2 is rooted, has a custom rom and running twrp-3.2.1-0-oxygen.img. I tried using the latest twrp image(twrp-3.5.2_9-0-oxygen.img) but it showed data as 0(couldnt mount /data) I am trying to make a full backup using twrp and when trying to backup into a otg usb it freezes at the same point every time. I select every option in backup and it seems to fail at some percentage of system image partition(tried 2 different usb sticks) and this is the log
Backing up System...
* Generating digest...
* Digest Created.
* Digest Created.
* Digest Created.
* Digest Created.
Backing up System Image...
Backup Failed. Cleaning Backup Folder.
If you believe using a big enough microsd card will change things and will actually succeed at backing up i'll go buy a big enough microsd card.
I just want a full backup of data widgets, everything as I just fixed the phone and it has some widgets/wallpapers/themes not available anymore. Any help is appreciated.
Kostasl said:
My xiaomi mi max 2 is rooted, has a custom rom and running twrp-3.2.1-0-oxygen.img. I tried using the latest twrp image(twrp-3.5.2_9-0-oxygen.img) but it showed data as 0(couldnt mount /data) I am trying to make a full backup using twrp and when trying to backup into a otg usb it freezes at the same point every time. I select every option in backup and it seems to fail at some percentage of system image partition(tried 2 different usb sticks) and this is the log
Backing up System...
* Generating digest...
* Digest Created.
* Digest Created.
* Digest Created.
* Digest Created.
Backing up System Image...
Backup Failed. Cleaning Backup Folder.
If you believe using a big enough microsd card will change things and will actually succeed at backing up i'll go buy a big enough microsd card.
I just want a full backup of data widgets, everything as I just fixed the phone and it has some widgets/wallpapers/themes not available anymore. Any help is appreciated.
Click to expand...
Click to collapse
The full details of the error will be in the log file - not the log screen. The system image is 4GB, so if your usb stick is formatted to fat32, then you might have problems.
Yeah, I thought fat32 was the only format androids can read, so you think a microsd would actually work? What do you suggest? Thank you for your input.
DarthJabba9 said:
The full details of the error will be in the log file - not the log screen. The system image is 4GB, so if your usb stick is formatted to fat32, then you might have problems.
Click to expand...
Click to collapse
Thanks for the input.
Kostasl said:
Yeah, I thought fat32 was the only format androids can read, so you think a microsd would actually work? What do you suggest? Thank you for your input.
Click to expand...
Click to collapse
There is no reason why a MicroSD card would not work, if you have a good recovery. Best to format the MicroSD to exFAT.
Advantage and disvantage of zram + swapper,
Zram stores compressed data in the ram itself, where as swap uses your emmc. If you needed more ram then you had available, and zram is disabled, swap is going to write to storage far more often making it slower during heavy use. It'll also wear out your emmc faster, zram + swapper are recomended only for small physical ram device, disable it on 6gb+ device are recomended, it will increase the performance.
Zram + swap = Standard speeds.
Zram + no swap = Usually a bit faster than stock.
No Zram + swap = A bit slower than stock.
No Zram + No swap = The fastest option, but apps will get purged from memory more often. If you're a gamer, or not multitasking heavily between many apps, then this is probably your best option.
On systems with more RAM (3gb+), you'd probably want to disable both regardless of how you use your device. You'll get more
Its no permanent, it will reset after reboot
1. Download terminal emulator
2. Download Ram Truth
3. Magisk script https://drive.google.com/file/d/14a9kmraF8mJ4tutHNYoi-oi5PFPJ6vPi/view?usp=drivesdk
4. Install script via magisk
5. Check via (RAM Truth) for comparison and Zram + Swap usage
6. Open terminal and type command:
su
zsm
zsm off
7. Check again at RAM Truth, 0.00MB means sucessfull turning off.
8. Retype again after shutdown or reboot
Im not responsible for everything so do it with your own risk.