Author Topic: Swapfile.  (Read 5987 times)

0 Members and 1 Guest are viewing this topic.

Swapfile.

« on: June 11, 2014, 11:13:52 AM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • vampirefo

    Posts: 38
    User Rating: +10/-0
    Online
    • *
    • Jr. Member
    Here is a swapfile and starter script I made, if you have room and are using a kernel with swap enabled, stock doesn't allow swap.
    These phones have a small amount of ram, so in Linux we offset lack of ram with swapfile, or swap partition, to help smooth out phones performance under a heavy load.

    You are not allowed to view links. Register or Login

    You need 110 MB free to use this file, or you can make a smaller one, I use 400MB myself. to use place on sdcard, boot into recovery and install, reboot and check if working.

    adb shell

    free -m

    or on older busybox

    free

    Code: You are not allowed to view links. Register or Login
    adb shell
    # free -m
                 total         used         free       shared      buffers
    Mem:           301          297            3            0            7
    -/+ buffers:                290           10
    Swap:          399            8          391


    # free
                 total         used         free       shared      buffers
    Mem:        308524       303836         4688            0         8108
    -/+ buffers:             295728        12796
    Swap:       409596         8324       401272
    #



    To make your own swapfile download Simple Root Swap from market. You are not allowed to view links. Register or Login, use app to make swap file on your sdcard.

    rename the swapfile Simple Root Swap makes to swapfile place in swap_100.zip and flash it instead.
    • Stock
    • ZTE OPEN C
    • Clock Work Mod
    • Rooted-Rom

    Re: Swapfile.

    « Reply #1 on: June 11, 2014, 01:38:28 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • cowellalexander

    Posts: 8
    User Rating: +0/-0
    Offline
    • VIP Member
    • *
    • Jr. Member
    Working great thanks. A quick question is the swap file on internal menory or my sd card?

    Sent from my LG-L38C using Tapatalk 2
    • Custom
    • L38C LG Optimus Dynamic
    • Clock Work Mod
    • AreaRomQ v1.1
    • Rooted-Rom

    Re: Swapfile.

    « Reply #2 on: June 11, 2014, 05:11:32 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • vampirefo

    Posts: 38
    User Rating: +10/-0
    Online
    • *
    • Jr. Member
    /system/xbin

    internal memory, sdcard is mounted last, auto start would be a problem, system is mounted early so start from system automatically.
    • Stock
    • ZTE OPEN C
    • Clock Work Mod
    • Rooted-Rom

    Re: Swapfile.

    « Reply #3 on: June 11, 2014, 05:25:33 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • cowellalexander

    Posts: 8
    User Rating: +0/-0
    Offline
    • VIP Member
    • *
    • Jr. Member
    So in order for me to use  higher swap value. I would have to use your sdcard hack?

    Sent from my LG-L38C using Tapatalk 2

    • Custom
    • L38C LG Optimus Dynamic
    • Clock Work Mod
    • AreaRomQ v1.1
    • Rooted-Rom

    Re: Swapfile.

    « Reply #4 on: June 11, 2014, 05:30:45 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • vampirefo

    Posts: 38
    User Rating: +10/-0
    Online
    • *
    • Jr. Member
    Yes and no, for auto start yes, for manual start no, you can use your micro sdcard to hold the swapfile, just remember to restart swap on each boot.
    • Stock
    • ZTE OPEN C
    • Clock Work Mod
    • Rooted-Rom

    Re: Swapfile.

    « Reply #5 on: June 11, 2014, 07:36:28 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • cowellalexander

    Posts: 8
    User Rating: +0/-0
    Offline
    • VIP Member
    • *
    • Jr. Member
    Ok well tonight I'm gonna attempt to do the sdcard hack and make a bigger swap file

    Sent from my LG-L38C using Tapatalk 2

    • Custom
    • L38C LG Optimus Dynamic
    • Clock Work Mod
    • AreaRomQ v1.1
    • Rooted-Rom

    Re: Swapfile.

    « Reply #6 on: December 10, 2014, 02:09:41 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • cosmicaug

    Posts: 28
    User Rating: +2/-0
    Offline
    • *
    • Jr. Member
    How the hell did I think that one of the partitions on this phone, as is, was a swap partition and that the stock ROM had swapping enabled?

    I checked some file showing phone's partition structure that I had lying around on my computer (probably output from fdisk) and, indeed, there's no swap filesystem type listed so I didn't get that incorrect notion from there.

    I'm going to have to install your modded rom or Mateo's derivative and enable the swap as per this thread. I'm getting kind of sick, as of late, of the extremely low performance of this. Hopefully enabling a swap file helps. Thanks.
    • Stock
    • LG LC38
    • Stock
    • AreaRom v1.0b
    • Rooted-Rom

    Re: Swapfile.

    « Reply #7 on: December 10, 2014, 04:10:10 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • lordlortnoc

    Posts: 22
    User Rating: +1/-0
    Offline
    • *
    • Jr. Member
    You can make a swap file without a 3rd party program, like simple root swap.  All you need is ADB or Terminal Emulator.

    Code: You are not allowed to view links. Register or Login
    / # cd /sdcard
    /sdcard # touch swapfile                 *Creates the file that will be used
    /sdcard # busybox mkswap swapfile 200000 *Converts the file into a swap space
    /sdcard # swapon swapfile                *Turns swap on
    /sdcard # free                           *Check to make sure that swap started
    /sdcard # echo 100 > /proc/sys/vm/swappiness   *Sets the amount of 'swappiness'

    You can set your own values for swappiness depending on your hardware.   You do not have to reboot, rebooting will turn swap off but will not delete the file.   It's as simple as that, no need for any 3rd party apks.  If you want this to start on next (re)boot, you will need to add 'swapon swapfile' to your init.d script, as well as 'echo 100 > /proc/sys/vm/swappiness'...   And that's it :-)  Have fun with your new swap space, and be sure to experiment with the swappiness value to see what works with your phone the best.  Too high and it will save all memory to swap space, causing extreme lag due to sdcards speed, too low and it wont save enough.   It is best to have AT LEAST a Class 4 memory card.  Any questions, let me know!
    • Custom
    • Samsung Galaxy Proclaim
    • AreaRom CWM v6
    • AreaRom v1.2
    • Rooted-Rom

    Re: Swapfile.

    « Reply #8 on: February 10, 2015, 09:47:57 AM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • drivebye33

    Posts: 3
    User Rating: +0/-0
    Offline
    • *
    • Jr. Member
          Thanks for the mod and thread it gave me an idea.. I started thinking about ram chips..
         Instead of having one big ram chip, you have several smaller ones.. The reason why several smaller chips because one chip is being filled up with data while the other one is being emptied..
         So here's what I did.. I created a directory on the external sd card. Named it swap.. Then I created two sub directories naming,one swap1 and the other swap2.. I then created a swapfile named fileswap.swp 375M and copied then pasted to both sub directories..
         Next I created a script file with the following commands..

    mkswap /mnt/sdcard/_externalsd/swap/swap1/fileswap.swp
    swapon /mnt/sdcard/_externalsd/swap/swap1/fileswap.swp
    mkswap /mnt/sdcard/_externalsd/swap/swap2/fileswap.swp
    swapon /mnt/sdcard/_externalsd/swap/swap2/fileswap.swp

    named it swapexsd

         Last I used rom toolbox app for the script program to run the script at boot...

    total         used         free       shared      buffers
    Mem:        308524       305796         2728            0        13512
    -/+ buffers:                    292284        16240
    Swap:       767992         4932       763060

    Over 1 gig of ram that runs like a beast.. The phone really seems to like it anyways..

         I'm still new to Linux, so if I made a mistake please correct me.. Then I'll blame windows for twisting my way of thinking.. lol
    • Stock
    • Stock
    • Not Rooted

    Re: Swapfile.

    « Reply #9 on: February 10, 2015, 09:56:12 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • drivebye33

    Posts: 3
    User Rating: +0/-0
    Offline
    • *
    • Jr. Member
    I did the system swap also, ended up with 1,150 megabytes of ram.. Plus repartitioned the phone's memory thanks to rjgee's mod. Ended up with 616 m system memory for apps. and 512 m internal memory.. which made a really sweat phone from nothing. Thanks to everyone here.. You guys are awesome..


    # free -m
                total         used         free       shared      buffers
    Mem:           301          297            4            0            0
    -/+ buffers:                296            4
    Swap:          849           44          805
    # free
                 total         used         free       shared      buffers
    Mem:        308524       304556         3968            0          328
    -/+ buffers:             304228         4296
    Swap:       870388        45148       825240
    • Stock
    • Stock
    • Not Rooted

    Re: Swapfile.

    « Reply #10 on: February 21, 2015, 01:32:06 AM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • lordlortnoc

    Posts: 22
    User Rating: +1/-0
    Offline
    • *
    • Jr. Member
    Yeah, yeah, np man....  What speed card are you using?  I was wondering if it would matter if you had 2 files instead of one seeing as you can only read write to a certain speed, but you might be correct...  that they will be 'swapping' information reading/writing to each other and it be better than using just one file...  hmmm....  kudos on thinking outside the box...

    also i forgot to mention, be careful with using swap my friend, it has been known to destroy memory cards in just a few months usage, so keep back ups of pictures and music, you have been warned ;-) I installed a ftp server locally on a PC on my lan and wrote a small script for my phone to backup certain folders to my computer at 12 hour intervals...  something to think about
    • Custom
    • Samsung Galaxy Proclaim
    • AreaRom CWM v6
    • AreaRom v1.2
    • Rooted-Rom

    Re: Swapfile.

    « Reply #11 on: February 21, 2015, 07:00:24 AM »
  • Thank You
  • -Given: 22
  • -Receive: 148
  • blazer64

    Posts: 1428
    User Rating: +277/-2
    Offline
    • Moderator
    • *
    • PostMaster General
    • Personal Text
      Android is King
    Im using a class 10 sdcard, and yes swap support eats up the life of an sdcard no matter what class they are.
    • Stock
    • Stock
    • None
    • n/a
    You are not allowed to view links. Register or Login

    Re: Swapfile.

    « Reply #12 on: February 22, 2015, 12:37:07 AM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • drivebye33

    Posts: 3
    User Rating: +0/-0
    Offline
    • *
    • Jr. Member
    I'm using a class 10 card also 16 gigs.. So Read write speed is faster then class 4. Since my post I created 6 swap files at 150 megs instead of 2 bigger files.. Same amount of VM memory. I was also wondering if the sd card would last longer because the VM being spread out, instead of just one part of the sd card..
    • Stock
    • Stock
    • Not Rooted

    Re: Swapfile.

    « Reply #13 on: February 22, 2015, 07:16:02 AM »
  • Thank You
  • -Given: 22
  • -Receive: 148
  • blazer64

    Posts: 1428
    User Rating: +277/-2
    Offline
    • Moderator
    • *
    • PostMaster General
    • Personal Text
      Android is King
    You just need one part swap file as well one part ext2/3/4 file if its neccessary, With alot of swap files youll end up messing up the device or hard bricking it.
    • Stock
    • Stock
    • None
    • n/a
    You are not allowed to view links. Register or Login

    Re: Swapfile.

    « Reply #14 on: February 22, 2015, 07:20:00 AM »
  • Thank You
  • -Given: 22
  • -Receive: 148
  • blazer64

    Posts: 1428
    User Rating: +277/-2
    Offline
    • Moderator
    • *
    • PostMaster General
    • Personal Text
      Android is King
    Plus the swap file part needs to be equivalent to the RAM from the device or half of it.

    • Stock
    • Stock
    • None
    • n/a
    You are not allowed to view links. Register or Login

    Re: Swapfile.

    « Reply #15 on: February 27, 2015, 08:14:47 AM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • lordlortnoc

    Posts: 22
    User Rating: +1/-0
    Offline
    • *
    • Jr. Member
    Isn't swap great....??  Except for the fact that it chews up your memory card... 

    And I don't think its going to matter how many files that you try to divide and distribute swap across, in the area of attempting to keep it from destroying your card...  Hard disk failure is hard disk failure...  And it's not IF it's going to happen, it's WHEN it's going to happen. 

    Another thing I do, (besides religiously backing up), if I know that I'm not going to NEED swap, I turn it off,...  and if I know that I'm going to be using swap heavily for gaming or something, (and I'm addicted to that game, and know that I'm going to be playing it for long amounts of time continuously), I change out my sdcard temporarily from my 32gb to my spare 4gb...  Cause if it eats my 4gig, I could really careless, and it takes wear and tear off my 32gb...

    Something else to think about...  :-)
    • Custom
    • Samsung Galaxy Proclaim
    • AreaRom CWM v6
    • AreaRom v1.2
    • Rooted-Rom

    Tags: