Originally Posted by Steve_max
I believe I was able to reduce the problem by a huge amount; no lags at all for weeks. This is what I did, presented in a tutorial, simple-to-follow way. You need a custom recovery; CWM and its variations will work, TWRP probably will work fine as well. You also need fully functioning adb. There are other topics on this forum that can help you getting both the recovery and adb working fine. A good strategy for "worst-case scenarios" is to have an Odin/Heimdall flashable file on your PC. If you screw up and can't get back to recovery, Odin back to stock.
BACK UP ALL YOUR FILES!!! Seriously, we WILL DELETE ALL FILES on your internal SD.
You are accepting a risk by following this procedure. One period, one space, one enter at the wrong point can do possibly irrevocable damage to your phone. I accept no responsibility if you screw up!
Reboot into recovery and make a nandroid backup to external SD. I already had a CM10.2 ROM ready to install from the external SD as well; make sure you have some CWM installable ROM on it. Then, remove the SD just to be sure. Go to the "mounts and storage" section of CWM/TWRP and make sure /data, /system, /cache and /preload are all mounted (you should see options to unmount them). After that, connect the phone to your PC. On the PC, open a command window (on windows, start menu --> CMD; on OS X, the Terminal application; on Linux, Konsole/Terminal), and run:
This will give you a Linux terminal running on your phone, with the interface on your PC. But you need more, you need root access to that terminal. Look at the prompt you got. If it ends with a "#", you're already root and you can skip this step. If it ends with "$", you're a regular user and you'll need to become root. In this case, type:
That will make you root. You'll know you're running as root when the prompt changes from "$" to "#". Now we go to the real work, and the part where you can do a lot of damage. You did the backup, right? First, we will delete all files on your phone:
rm -rf /data/* /system/* /cache/* /preload/*
After that, your phone will be completely empty, with no OS. Why that? Because we want to write and rewrite on your whole internal SD, not just on the small part that is empty. Then, we will do exactly the same thing that DFG does, but on all four big partitions:
dd if=/dev/zero of=/data/dummy
dd if=/dev/zero of=/system/dummy
dd if=/dev/zero of=/cache/dummy
dd if=/dev/zero of=/preload/dummy
Note that each of those commands will take a while, from some tens of seconds for the smaller partitions to maybe even one hour for the big /data/ partition if it's very damaged. There will be no visual indication of their progress until they end, when you'll get a summary of what it did, how long it took and how fast it was.
This fills ALL your eMMC with a dummy file. Pay attention to the average speed reported on each step. Ideally, you will have approximately the same speed on all four steps; and a speed that is reasonably high (I don't remember the actual speed for my eMMC right now, but that should be about 30MB/s). If you're suffering from freezes, that will most likely not happen now. Each partition will give you a different speed, from (for example) 8 to 30 MB/s. Then, you will delete the dummy files:
rm /data/dummy /system/dummy /cache/dummy /preload/dummy
And run it all again. If you're still not getting consistent speeds, delete the files, run the "dd" commands again, and repeat until you do. Actually, repeat it until you get consistent speeds a few times. Set aside some time for that. A full afternoon is probably enough; I must have spent some six hours until I was confident enough.
After you're happy with your speeds, delete the dummy files if you still didn't do it and reinsert your SD. Now, install the ROM you had on your external SD, reboot, and (if it all worked as intended) you should be free of the freezes. Restore your files, reinstall your apps, and enjoy your phone.
I wouldn't restore the nandroid; take this opportunity to make a fresh start (besides, you can have some sort of filesystem damage that could return from the backup). But, in case something goes wrong, restore the backup and go back where you were. You still should see big improvements.
If you screw up big time, you may lose access to the recovery. In that case, Odin/Heimdall is your only bet. This should not happen unless you manage to screw up the commands I wrote in some very, very creative way, though.
Please, report any issues you find, and any positive (or negative) feedback will be appreciated. As I said, it worked for me. I hope it works for most of us!