[HOW TO] Create SWAPFILE to extend memory - Xperia Z1 General

Hi guys. I want to share with you how to create SWAPFILE to extend memory.
Requirements :
- rooted ROM
- working init.d (if you want to mount it at boot, you need init.d capability)
- busybox (Stericson version is recommended)
- terminal emulator
1. Create swapfile
Open your terminal emulator, then escalate to root access using command
Code:
$ su
Before we step further, choose where you want to make swapfile. In this tutorial, I'll create swapfile on /data directory. Different locations, means different command!
To create swapfile, apply this command
Code:
# dd if=/dev/zero of=/data/swap bs=$((1024*1024)) count=YOUR_DESIRE_VALUE
Make your choice, how big your swapfile will be created. In this tutorial, I'll make 1024 kb of swapfile, yes it's 1 GB of swapfile.
So my command is
Code:
# dd if=/dev/zero of=/data/swap bs=$((1024*1024)) count=1024
Wait a second. The bigger your value, the longer the process. After it's finished, and there's no error. Proceed to next step.
2. Format swapfile using mkswap command
After the creation is success, format the file using mkswap, so that file can be used as swap.
Code:
# mkswap /data/swap
Remember, my swapfile is located in /data directory. Yours maybe different. Depends on where you created it in 1st step.
3. Mount your swapfile
After we format it, now we can mount it as swap using following command
Code:
# swapon /data/swap
Remember, my swapfile is located in /data directory. Yours maybe different. Depends on where you created it in 1st step.
4. Tweak swappiness value to optimize swap system
Code:
# echo 20 > /proc/sys/vm/swappiness
You can put value between 1 - 100. The less the value, the better the result. Why? Swappiness is a condition when to put overload memory to swap when your RAM is running out of memory. If you put value 20, System will put overload memory to swap when RAM is 80% (free 20%). By the way my value is 1 (ONE)
After that, drop cache so next time overload memory will be placed in your swap.
Code:
# echo 3 > /proc/sys/vm/drop_cache
I need to wait 1 - 2 hour(s) to make it work.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
As you can see, my swap is really working. You may need sometime to make it work.
Hit thanks if this helpful.

Is this really necessary on Z1? What improvement we will get have 2gb real Ram + 2gb Swap Ram on SD?

eclyptos said:
Is this really necessary on Z1? What improvement we will get have 2gb real Ram + 2gb Swap Ram on SD?
Click to expand...
Click to collapse
Agreed. Do you see any measurable difference on benchmarks, even?

I can't activate swapp on official 4.3... Can you help me?
Sent from my C6903 using xda app-developers app

On stock rooted .257, last command is
Code:
echo 3 > /proc/sys/vm/drop_cache[B]s[/B]
with an "s" to drop_cache.

This is the most idiotic idea ever, do not do this people, it will not increase performance in the slightest.

benben972 said:
I can't activate swapp on official 4.3... Can you help me?
Sent from my C6903 using xda app-developers app
Click to expand...
Click to collapse
No one knows what you did and what went wrong. Learn to ask questions.

xasbo said:
No one knows what you did and what went wrong. Learn to ask questions.
Click to expand...
Click to collapse
He did.
4.3 is the point - on locked bootloaders as no system rw access. In orher words not possible on LB. A part of that the swap idea is nonsense as it slows down the device.
Sent from my C6903 using xda app-developers app

Swap file is useful when the system needs more 'memory space than available physical memory (RAM)
Z1 has 2GB of RAM and able to provides resources for most of the time without the needs for swap file.
BTW ,swapping to external storage is slow and may increasing the storage failure.
On my Z1, it uses about 1GB of RAM and still have some more ready to be use.
Thank you.
Ref:
Code:
$ cat /proc/meminfo
Sent from my C6903 using xda app-developers app

Related

[APP] findutils 4.2.33 (updatedb / locate) for Android

Introduction
As I like to stay connected via Putty to my Android phone, from time to time I missed the functionality of updatedb / locate that I so got used to within Linux environment.
I've decided to cross compile the findutils package (I couldn't get the latest version 4.4.2, but an older before, 4.2.33).
Screenshot
You can see the updatedb command followed by some locate commands.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Installation
Busybox is required.
1. Copy the archive onto your /sdcard/ folder.
2. mount your /system folder as read-write
3. cd /system/
4. tar xf /sdcard/findutils-4.2.33.tar.gz
It is mandatory that you are inside /system/ folder when you extract the archive.
Then you have to create the database (using updatedb script). It will take a bit of time - but not too much.
Then you can use the locate command giving any part of a file name that you can remember, you can also use wildcards!
Observations
1. No integration with cron / etc. If you know your updatedb database is out of date, rebuild it using "updatedb"
2. Busybox comes with a /system/xbin/find command. The trouble with it is that it doesn't support the fstype argument, and thus, updatedb cannot prune some standard file system type paths. However, the bundled package here comes with its own find utility which unpacks into /system/bin/find.
3. Busybox is required for sort / sed, but updatedb script is patched to use the /system/bin/find (its own find executable) instead of the default busybox one.
4. My phone did not have an /etc/mtab file (list of mounts which mount is supposed to update whenever something happens). Thus, there is a line in the updatedb script which recreates that file on each updatedb invocation (mount > /etc/mtab). If you phone / tablet has it, please modify updatedb script and remove the mount command.
Download
Use it at your own risk!
findutils-4.2.33.tar.gz
This is great! Thanks for your work!
I hope that there will be a file manager for android which uses updatedb/locate to index/search files in the future, that would be sooooo awesome!
Don't know about other software that searches - but it would be nice too.
Maybe I can create something, but I'm sure there are others more integrated - such as looking in SMSes or in mails too, etc.
nice! find takes for ever lol now i have locate!
Any chance of getting the code. Did you create your own Android.mk? Did you use the FindUtils make?
When I run updatedb, I get these errors:
/system/bin/find: /preload: Value too large for defined data type
/system/bin/find: /storage/sdcard0: Value too large for defined data type
/system/bin/find: /system: Value too large for defined data type
/system/bin/find: /data: Value too large for defined data type
yelkarama said:
When I run updatedb, I get these errors:
... <snip>
/system/bin/find: /data: Value too large for defined data type
Click to expand...
Click to collapse
I also get this error
This doesn't work. Might have worked a couple years ago before 4.x Android...
Use something like es file Explorer
Sent from my SAMSUNG-SGH-I747 using XDA Premium 4 mobile app
I will rebuild it in the weekend I think back in the days the file systems were only 32bit, and now a lot of phones have 64bit file systems ...
viulian said:
I will rebuild it in the weekend I think back in the days the file systems were only 32bit, and now a lot of phones have 64bit file systems ...
Click to expand...
Click to collapse
Thanks for your efforts, I guessed it needed a rebuild from a google, but given how long ago you posted this I didn't think it would happen. Looking forward to the update!
Sent from my GT-N7100 using Tapatalk
Please upload the new build
viulian said:
I will rebuild it in the weekend I think back in the days the file systems were only 32bit, and now a lot of phones have 64bit file systems ...
Click to expand...
Click to collapse
Hi
Please upload the new built binaries.
Thanks
Don't work with Oreo. Please make a update.

More RAM on LG GT540(Swap)

Using Swap on LG GT540​
What is Swap ?
Code:
If I'm right, Swap is used to move UNused running programs from RAM to a file created in SD card or a swap partition
What method are we using ?
Code:
We will Swap by using [URL="http://adf.ly/4Hoa5"]SWAPPER[/URL]
Pros:
Code:
More Free RAM and faster response
SWAP will Fix "auto-close of some HD games while loading problem".
Cons:
Code:
Takes more time when switching between tasks (Depends on SD card speed)
How to use Swap ?
Code:
Simple just Download Swapper from [URL="http://adf.ly/4Hoa5"]HERE[/URL]
Run application and allow superuser permission
select the amount of MB's you want to swap I recommend 200MB
Select active on boot and click save
How to know if swap is working ?
Code:
In "Terminal Emulator" type free and it should be somthing like this
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
VERY IMPORTANT NOTE : It wont work on (SDSL3) because of some permission bug if someone got it worked just tell me.
List of games I used and worked after Swap:
Code:
GTA III (Never ran correctly before swap)
X-Formula (Never ran correctly before swap)
Worms (Never ran correctly before swap)
Gangstar 1 and 2 (worked at random times before swap)
i do recommend using a swap partition, more stable and with an easy script usable so no need for using swapper.
We can also check is swap working in setcpu. I dont recommend swap on stock sd card because phone is slower. Being ohnest swap is only usefull for games
Sent from my GT540 using Tapatalk
hey i made a thread about this last time time to bump it!!!
Hi,
I tried 'swapper for root' from the market before rooting my 'LG Optimus Pro C660'
no action happened !
I rooted my phone thanks to this great community !!!
Now i re-installed the 'swapper for root' and this time i saw some action, i created a swap size and checked the 'active on boot' and there was a small pop-up saying the swap file was being created.
I got so excited hoping that my 256MB RAM would now be less bothersome...
But alas! my excitement was short-lived ... a 'free' command on my terminal showed swap at 0-total 0-used 0-free
Can somebody help me implement swap successfully on my device
thanks,
aiamuzz.
aiamuzz said:
Hi,
I tried 'swapper for root' from the market before rooting my 'LG Optimus Pro C660'
no action happened !
I rooted my phone thanks to this great community !!!
Now i re-installed the 'swapper for root' and this time i saw some action, i created a swap size and checked the 'active on boot' and there was a small pop-up saying the swap file was being created.
I got so excited hoping that my 256MB RAM would now be less bothersome...
But alas! my excitement was short-lived ... a 'free' command on my terminal showed swap at 0-total 0-used 0-free
Can somebody help me implement swap successfully on my device
thanks,
aiamuzz.
Click to expand...
Click to collapse
Make sure you select the fat partition. Also, make the file smaller. Stay at 200 until it doesn't work, and roll back.
Sent from my LG GT540 Swift using Tapatalk
Thanks for looking into my post.
My research lead me into partitioning my SD card for a swap partition(instead of the swapfile method of 'swapper for root') and enabling swap on it through a shell script from here...
Auto Swap Partition
I was able to execute everything including
mkswap /dev/block/mmcblk0p1 ...
which resulted in the following response...
"Setting up swapspace version 1, size = 1733292032 bytes uuid=4e22c415-5500-48f9-8dc8-a93ebde7794e"
But the final command to implement swap...
swapon /dev/block/mmcblk0p1
resulted in the following error...
" swapon: /dev/block/mmcblk0p1: Function not implemented "
Which did not enable swap successfully !!!
I believe in the case of 'swapper for root' too the same command played the spoil sport.
swapon: /sdcard/swapfile.swp: Function not implemented.
Any Help to have swap enabled on my Android device 'LG Optimus ProC660' is most appreciated.
thanks,
aiamuzz
@up if you want swap on you other phone im sure it needs custom kernel
Thank you!
thanks ...........

[FIX] {100% working }how to mount external sd card to /sdcard/external_sd ~

alright follow these steps and you good to go
mounting sd card via command prompt (via adb)
1) go to your's phone's file manager
2) create a folder named external_sd in /sdcard/ (you have to make this folder to mount sd card in /sdcard/ !!!
3) inject this command in cmd (adb)
Code:
su
mount -o bind /mnt/emmc /sdcard/external_sd
and done enjoy ......
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
mounting sd card via terminal (terminal file added for newbies )
first do step 1 and 2 above .
then inject this code in terminal
Code:
busybox mount --bind /mnt/emmc /mnt/sdcard/external_sd
after mounting sd card to /sdcard/external_sd
done ......... enjoy
great! gonna try it! this is one of my reasons for not being in aokp/aosp, 'cause i've linked to much files with directory bind from sdcard to external, so i would have to move them back to internal sd card to re-bind them sdcard- to emmc, let you know if it works, btw, do i prompt this commands with the phone on or in recovery? I'm a noob when it comes to adb
plotinus said:
great! gonna try it! this is one of my reasons for not being in aokp/aosp, 'cause i've linked to much files with directory bind from sdcard to external, so i would have to move them back to internal sd card to re-bind them sdcard- to emmc, let you know if it works, btw, do i prompt this commands with the phone on or in recovery? I'm a noob when it comes to adb
Click to expand...
Click to collapse
1) you can do it when you phone is on
2 ) you have to inject this code after every boot (due to nand suff )
3) just download terminal form my attachment and do it
BTW you can try this method to add this script to boot http://www.xda-developers.com/tag/samsung-vibrant/
apk_xiz said:
2 ) you have to inject this code after every boot (due to nand suff )
http://www.xda-developers.com/tag/samsung-vibrant/
Click to expand...
Click to collapse
I tried to bind emmc to external_sd weeks ago.
The problem is that I couldn't get the script working under init.d. Probably the kernel I was using was the problem who knows.
I used gscript and ran the script at boot with su permission.
Also I suggest you to use this http://forum.xda-developers.com/showthread.php?t=1410262
I made APP
I made an APP to do it on app launch.
h t t p s : / / play . google . com/store/apps/details?id=com.guatedroid.galaxysd
its free no adds, (still in beta) but works.

[Q] Nexus System Partition Size

Hi, I'm not sure if this is specifically a Nexus question or a general Android question but I have both a Nexus 4 and Nexus 7 and have observed the same behaviour on both
I have posted in the General section with nor response so now I'm posting on specific forums
Basically what's happening is when I delete stuff from the SDcard the free space seems to be allocated to the system partition WTF?!
Take a look at the screenshots I'm going to try a couple of things - one of the suggested things was clearing the data in the Google Services Framework data >> Settings - Apps - All - Google Services Framework - Clear Data - which freed up some of it but not all, the next thing from here for me would be to flash the factory images again and see what I start out with
Both devices are on CM10.1 if that helps, is anyone else is having the same issue??
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
The discussion on Google+ http://goo.gl/lNyLW
Ok so this is my partition sizes now after flashing the factory images back onto my nexus 7. No where near 5GB anyone have any idea what's causing this?
I am guessing you have a couple of CWM back up? Maybe 3-4 of them? Maybe you tried to delete some of them?
Buggy CWM Recovery. Especially if you still hang on to the older versions. Mostly because the way CWM save the backup files.
KyraOfFire said:
I am guessing you have a couple of CWM back up? Maybe 3-4 of them? Maybe you tried to delete some of them?
Buggy CWM Recovery. Especially if you still hang on to the older versions. Mostly because the way CWM save the backup files.
Click to expand...
Click to collapse
I just use TiBU and DataSync now, stopped doing nandroids a while back now
Sent from my Nexus 7 using Tapatalk 2
It's not "system data" for sure. It's some apps with root permission saving its file to locations it shouldn't be doing.
Some how l still think it is CWM, even as you stopped using it in a distance past (which is like 1-2 months ago). I recommend flashing newest CWM and see if there're still old back up files.
If you still can't find anything, try this
bassmadrigal said:
If you are rooted and have adb set up on your computer, you can find out what folders are using the most space by using the commands below, then change into that directory and run the command again.
Code:
adb
su
cd /
du -hd 1
--find the largest folder and change directory (cd) into it - if you find you no longer want to continue in the folder you are in, you can cd .. to get to the previous folder or cd / to get back to the root of the filesystem--
Code:
cd large_folder
du -hd 1
rinse
repeat
????
profit
This will allow you to find what folders are using the most space and can eventually lead you to any large files and can then let you find out if you can delete them or if you need to keep them.
Click to expand...
Click to collapse
isnt this what they were saying was the reason for no SD card and use of MTP ?; basically if i recall correctly the nexus devices do not truly assign partitions instead there is a storage 'pool' that anything can use dynamically.
We got tired of seeing OEMs include many GB of internal storage for music, while users were still running out of space for apps and data. This approach lets us merge everything on one volume, which is way better.
-- Dan Morrill, Android engineer at Google
Click to expand...
Click to collapse
so i guess there is no partitions its just all 1 volume.
source: http://www.androidcentral.com/why-nexus-devices-have-no-sd-card
noobdeagle said:
isnt this what they were saying was the reason for no SD card and use of MTP ?; basically if i recall correctly the nexus devices do not truly assign partitions instead there is a storage 'pool' that anything can use dynamically.
so i guess there is no partitions its just all 1 volume.
source: http://www.androidcentral.com/why-nexus-devices-have-no-sd-card
Click to expand...
Click to collapse
I wish that was the case but it not, the space goes to the system partition and I cant access it on the sdcard

Setting SElinux boolean may unlock Amazon tablets

Guys. Everyone I need your undivided attention please. This might be it. This may be the key we have been seeking. However a once wise man said "these aren't the keys you're looking for" A true geek knows the reference. Now serious business.
Ok I did some research. So this Boolean folder is important. In fact this may be the jem we need.
In /system/bin you have two executables getsebool and setsebool. I'm going to explain this as easy as possible.
An*SELinux boolean*is a single string (hopefully sufficiently interpretable) that changes how SELinux reacts. With*getsebool*you can get a list of booleans and their current value. Changing SELinux booleans can be done through*setsebool*(where you add the desired state of the boolean, such as*on*or*off) or*togglesebool*(which flips the current value of a boolean).
Click to expand...
Click to collapse
Let's play a little game. Unfortunately for this to do anything, you need to be root already i think.
Code:
getsebool -a
This will list any booleans set in the SElinux policy and their values (on or off). On the HD 10, there is one boolean present. At the moment, this device is the only one I have run into that has anything set in the booleans. I own about a dozen different devices (phones and tablets) all of them work and are either rooted or boot loader unlocked (only my Moto E4 isnt). Not a single one of them have anything in the booleans in this folder, except for this HD 10. It is wiped clean on every other device. HD 10 boolean:
Code:
$ su
# getsebool -a
device_unlocked --> off
Here's the fun part:
Code:
# setsebool device_unlocked on
# getsebool device_unlocked
device_unlocked --> on
However there is a problem with changing this value, even being root:
When you do this, the changed value will take effect immediately but only for the duration that the current loaded policy is active. That means, if the system reboots, you loose the changes. Or when you explicitly would reload the SELinux policy, you loose the changes. On the other hand, switching booleans this way is fast and helps you to debug problems.
Click to expand...
Click to collapse
There is a way to change this, running a simple command. However I'm certain the bin file or files have been modified and the commands removed from the policy.
Code:
setsebool -P device_unlocked on
In a normal world, the above command would make the value we set persist upon a reboot. So why alter the policy? That doesn't make sense to me. I know as an OEM you can write said policy, but why go through the massive effort if only to leave this boolean in place? Now given this potential massive discovery, what does this now mean? Did I just do what I think I did? Was this really that easy?
I was not able to find the single log entry of the event on my HD 10. However the Fire 7, even with the custom ROM by @ggow, has the same boolean and value. I did the same steps on that tablet and I was able to get the single log entry. Can we get excited and jump...or cry for joy yet? I am totally lost in this neck of the woods.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
References:
https://wiki.gentoo.org/wiki/SELinux/Tutorials/Using_SELinux_booleans
https://www.thegeekdiary.com/understanding-selinux-booleans/
Well this may or may not be anything. A few months ago I discovered a booleans in /sys/fs/selinux/booleans called 'device_unlocked'. You can set the bool, but the value persists to 'off' (of course) when you reboot. In a terminal:
Code:
su
setsebool device_unlocked on
getsebool device_unlocked
on
Reboot and it will be set to 'off'. Well thanks to the su.d shell commands/script I found here on xda, I can now make that persists on reboot. In a terminal:
Code:
su
mount -o remount,rw /system
mkdir /system/su.d
chmod 700 /system/su.d
echo "#!/system/bin/sh" > /system/su.d/unlocked.sh
echo "setsebool device_unlocked on" > /system/su.d/unlocked.sh
echo "on" > /sys/fs/selinux/booleans/device_unlocked
chmod 700 /system/su.d/unlocked.sh
No need to reboot. Now the question is...what is it?
If you have an unlocked tablet now, in a shell do this:
Code:
su
getsebool -a
device_unlocked --> on
it's definitely tied into the unlocking procedure. Because my fire 7 says 'on' and I never set the bool.
Sent from my Amazon KFSUWI using XDA Labs

Categories

Resources