[Q&A] Mounts2SD - Storage & Memory Management

Search This thread

Dunc001

Inactive Recognized Developer
Apr 6, 2010
2,705
1,462
Hiding out south of the border...
Cool, thanks for this superb piece of work. Would you mind if we use it in our ROM in place of our current a2sd script? BTW, what are the benefits of having an sd-cache partition - I haven't come across this before, so how is it best set up and is anything additional required to make use of it?
 

dk_zero-cool

Senior Member
Nov 6, 2010
3,529
4,996
Horsens
Cool, thanks for this superb piece of work. Would you mind if we use it in our ROM in place of our current a2sd script? BTW, what are the benefits of having an sd-cache partition - I haven't come across this before, so how is it best set up and is anything additional required to make use of it?

Use it as you like :)

I don't think there are any benefits to a seperate cacge partition on the sdcard. But the internal nand has a seperate partition for this, so I just added the option if people would like the same on the sdcard.

It works by adding a third partition to the cache. So to use it, make a cache partition after fat32 and sdext on the sdcard. Otherwise it uses /sd-ext/cache if no third partition exists or /data/cache if no sdext partition exists either (If you boot without sdcard for an example).
 

Dunc001

Inactive Recognized Developer
Apr 6, 2010
2,705
1,462
Hiding out south of the border...
Use it as you like :)

I don't think there are any benefits to a seperate cacge partition on the sdcard. But the internal nand has a seperate partition for this, so I just added the option if people would like the same on the sdcard.

It works by adding a third partition to the cache. So to use it, make a cache partition after fat32 and sdext on the sdcard. Otherwise it uses /sd-ext/cache if no third partition exists or /data/cache if no sdext partition exists either (If you boot without sdcard for an example).

Thanks, and thanks for the reply. So I guess we'll just stick with a single sd-ext ext4 partition and a Swap partition. Can I PM you or chat anywhere re whether your script will require our existing ROM updater-script modifying in terms of how it is currently set up with symlinks etc?
 

dk_zero-cool

Senior Member
Nov 6, 2010
3,529
4,996
Horsens
Thanks, and thanks for the reply. So I guess we'll just stick with a single sd-ext ext4 partition and a Swap partition. Can I PM you or chat anywhere re whether your script will require our existing ROM updater-script modifying in terms of how it is currently set up with symlinks etc?

PM away :)
Also believe my email should be public for everyone.
 

uzi2

Senior Member
Jun 6, 2008
2,528
638
The config files is deprecated and replaced with the "m2sd" command, as said above. Settings is saved to /data/.m2sd which means that it keeps your settings when you flash new ROM's as long as you don't wipe data.

I have an EU HD2 with very limited internal memory. At present I use an amended version of Amarullz' script to move apps, data and dalvik-cache to my ext4 partition. This works well and I can just drop the script into init.d when updating or testing new Roms.

I was looking to test your solution in a similar way, but it would appear that there is no way of setting it the way I want it at first run or will it recognise my current layout?
 

dk_zero-cool

Senior Member
Nov 6, 2010
3,529
4,996
Horsens
I have an EU HD2 with very limited internal memory. At present I use an amended version of Amarullz' script to move apps, data and dalvik-cache to my ext4 partition. This works well and I can just drop the script into init.d when updating or testing new Roms.

I was looking to test your solution in a similar way, but it would appear that there is no way of setting it the way I want it at first run or will it recognise my current layout?

By default this script will move /data/app and /data/app-private to /sd-ext (Second partition on sdcard).

If you don't have a second ext partition, it will then by default move /cache to /sd-ext/cache

Then when booted, you can change the config using "m2sd <option> <value>". These settings is saved in separate files for each setting in /data/.m2sd/
So on each new ROM flash, it will remember your settings.

However, if you would like to add settings before first boot, just create a folder "/data/.m2sd/". Then add the files you need, for an example to move dalvik-cache to /sd-ext you add the do "echo 'enable' > /data/.m2sd/.dalvik" or if you want to change sdcard-readahead for sdcard before first boot you do "echo '1024' > /data/.m2sd/.readahead" and so on.
 
  • Like
Reactions: jolas and uzi2

Dunc001

Inactive Recognized Developer
Apr 6, 2010
2,705
1,462
Hiding out south of the border...
OK, so if we are going to include your script in our ROM as discussed and we want to enable moving dalvik, apps, apps-private to sd-ext but not cache how do we do that in the ROM zip? Just add a folder in /data in the ROM zip and name it .m2sd, and then add script files called .dalvik .cache etc with no extension containing just the one word disable or enable in it? Or is there another way?
 

dk_zero-cool

Senior Member
Nov 6, 2010
3,529
4,996
Horsens
OK, so if we are going to include your script in our ROM as discussed and we want to enable moving dalvik, apps, apps-private to sd-ext but not cache how do we do that in the ROM zip? Just add a folder in /data in the ROM zip and name it .m2sd, and then add script files called .dalvik .cache etc with no extension containing just the one word disable or enable in it? Or is there another way?

That is correct
 
  • Like
Reactions: Dunc001

dk_zero-cool

Senior Member
Nov 6, 2010
3,529
4,996
Horsens

Dunc001

Inactive Recognized Developer
Apr 6, 2010
2,705
1,462
Hiding out south of the border...
Yeah, I have no problem creating the .cache and .dalvik files with Notepad++, it's the actual folder with the folder name .m2sd that I can't create to include in the ROM zip! I guess we could just use mkdir data/.m2sd in the updater-script and then package_extract_dir("m2sd", "/data/.m2sd") - what permissions does the folder/files need?
 

uzi2

Senior Member
Jun 6, 2008
2,528
638
Yeah, I have no problem creating the .cache and .dalvik files with Notepad++, it's the actual folder with the folder name .m2sd that I can't create to include in the ROM zip! I guess we could just use mkdir data/.m2sd in the updater-script and then package_extract_dir("m2sd", "/data/.m2sd") - what permissions does the folder/files need?

You can create the folder using your phone on your sd card and it will copy to Windows.
 
  • Like
Reactions: Dunc001

jolas

Senior Member
Feb 22, 2006
2,222
416
Athens
Hi dh_zero_cool

I have an fat32, an ext4 and a swap partition in my sd card.

In every ROM I am going to flash I want to move dalvik to ext4 and cache to swap (128MB).

So, what I did is to insert in your flashable zip in root the folder 'data' and inside another folder '.m2sd'.

Inside '.m2sd' folder, I added 4 files
.app (with value 'disable')
.app-private (with value 'disable')
.cache (with value 'enable')
.dalvik (with value 'disable')

Before I test it, I want to be sure that it is going to work and move only dalvik to ext4 and cache to swap partition...
Is it??? :confused:
 

Dunc001

Inactive Recognized Developer
Apr 6, 2010
2,705
1,462
Hiding out south of the border...
Hi dh_zero_cool

I have an fat32, an ext4 and a swap partition in my sd card.

In every ROM I am going to flash I want to move dalvik to ext4 and cache to swap (128MB).

So, what I did is to insert in your flashable zip in root the folder 'data' and inside another folder '.m2sd'.

Inside '.m2sd' folder, I added 4 files
.app (with value 'disable')
.app-private (with value 'disable')
.cache (with value 'enable')
.dalvik (with value 'disable')

Before I test it, I want to be sure that it is going to work and move only dalvik to ext4 and cache to swap partition...
Is it??? :confused:

Well two things - dalvik won't be moved if you've added .dalvik with the value 'disable', and secondly just adding data/.m2sd to the flashable zip won't do anything if you don't add a line in the updater-script in the zip to actually copy it to your phone. To do this you need to open the flashable zip with WinRAR or similar (don't unzip/extract it, just open it) and then navigate in to META-INF/com/google/android and pull the updater-script out onto your desktop. Open it with Notepad++ and below this:

Code:
ui_print("Installing Mounts2SD...");
package_extract_dir("system", "/system");

you need to add this line:

Code:
package_extract_dir("data", "/data");

Save the changes and drag it back from your desktop into META-INF/com/google/android and close the zip. Now you can flash it.
 
Last edited:
  • Like
Reactions: jolas

jolas

Senior Member
Feb 22, 2006
2,222
416
Athens
Well two things - dalvik won't be moved if you've added .dalvik with the value 'disable', and secondly just adding data/.m2sd to the flashable zip won't do anything if you don't add a line in the updater-script in the zip to actually copy it to your phone.


Thank you very much for your detailed answer!!! :)



EDIT: I did change the script file but script does not run.
It only creates (inside .m2sd folder) a couple of other files, like .journal, .swap, etc, but dalvik is still inside data folder...
 
Last edited:

dk_zero-cool

Senior Member
Nov 6, 2010
3,529
4,996
Horsens
Hi dh_zero_cool

I have an fat32, an ext4 and a swap partition in my sd card.

In every ROM I am going to flash I want to move dalvik to ext4 and cache to swap (128MB).

So, what I did is to insert in your flashable zip in root the folder 'data' and inside another folder '.m2sd'.

Inside '.m2sd' folder, I added 4 files
.app (with value 'disable')
.app-private (with value 'disable')
.cache (with value 'enable')
.dalvik (with value 'disable')

Before I test it, I want to be sure that it is going to work and move only dalvik to ext4 and cache to swap partition...
Is it??? :confused:

The files .app ad .app-private will not work. These settings does not exist. App2SD cannot be disabled unless you remove the sd-ext partition. This is an App2SD script with extra options. But the app part is the scripts priority, only extra options can be disabled such as swap, cache and dalvik.
 

jolas

Senior Member
Feb 22, 2006
2,222
416
Athens
The files .app ad .app-private will not work. These settings does not exist. App2SD cannot be disabled unless you remove the sd-ext partition. This is an App2SD script with extra options. But the app part is the scripts priority, only extra options can be disabled such as swap, cache and dalvik.

It did not work either with .dalvik (dalvik still exists in data folder) nor with .cache (I set both values to 'enable')...:confused:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 276
    Mounts2SD - Storage & Memory Management

    The Opening Post (OP) has been moved to a new DevDB Section

    This Thread has been assigned as an Q&A.
    You should see a new pane above where you can navigate this project.
    16
    About dalvik-cache? It remains in phone memory?

    dalvik-cache remains, so does all of the app related data. Only the APK's is moved.

    Hi I cant understand How to use it ! any guide ?!

    First of all you need a custom rom. If you have a stock rom it will not work since you need a rom that will allow custom scripts during boot.

    You will also need to know how to use ADB (An android tool for communicating with your phone. It is used to enter the android shell and also to transfer files to and from the phone, among other things).

    And last, you will need at least 2 or 3 partitions on your sdcard (Otherwise it's a waste of time, although the script is build to adapt for these scenarios). One as a regular fat32 sdcard partition, one for the sd-ext and one for the cache. (Use ext2 for the last two. ext3 will eat your card to fast)

    Here is the steps (You need to have ADB working on your computer).

    1. Copy/Paste the script content into a file editor and safe the file with the name "99mounts2sd"
    2. Plug your phone to your computer using a usb cable (Select charge only on your phone))
    3. Open a terminal on your computer (In windows use "run" and type "cmd")
    4. Type in shell: "adb shell mount -o remount,rw /system"
    5. Type in shell: "adb push <path to script> /system/etc/init.d/"
    6. Type in shell: "adb shell chmod a+x /system/etc/init.d/99mounts2sd"
    7. Reboot your phone

    The first time you boot your phone using the script it will take some time, because the script needs to copy all of your APK's from internal storage to the sd-ext partition.
    13
    Within a week or so, I will release a new major update of Mounts2SD, which will contain


    1. New Re-written script with additional new option
      1. Seperate option for app libraries (Android 4.x)
      2. New option to move /data/media (The new type of internal sdcard used on Samsung among others)
      3. Ability to enable ZRAM
      4. Ability to set preferred scheduler on external and internal MMC
      5. Ability to also set readahead on internal MMC
      6. Ability to set preferred storage threshold, or disable it (Instead of hard coded value)
      7. The finalising part has been added to a sub-process which is started by the app itself. This is no longer depended on the app to execute it after boot
      8. Default values will be configured based on the device and it's abilities
      9. And more....
    2. New Re-written app
      1. Live overview (No more pre-defined onboot status properties)
      2. New layout
        1. 3 different layout's for small phones screens, normal phone screens and tablet screens (And of cause different landscape/portrait layouts for each of them)
      3. Only allow the owner to control the script (Android 4.2 multi-user)
      4. New Re-written RootFW (Spazedog Root Framework)
      5. New and better extended AsyncTask for background loading
      6. Overview and Configure will now adapt to the abilities available on the device (For an example, SWAP will not be displayed at all on devices without SWAP suppport)
      7. And more...


    However, before this is finished, I would like it very much if someone could provide me with a version of /system/etc/recovery.sh after Link2SD has added whatever content it adds to this file, so that I can update the auto sd-ext deletion script to better remove Link2SD from a device. I have tried installing Link2SD on two of my test devices, but on neither was anything added to this file. So for now I have just update the deletion script to also include the Link2SD app, which should take care of most of the problems when migrating from this.
    9
    Test Package Available

    I have added a test package to the OP under the category "Testing Downloads" containing a preview of the upcoming version. This package is NOT a recovery package. It is just an archive containing the app and the script, you will have to manually copy the script to the init.d location (Not yet implemented in the app) and you will have to manually configure the script using the /data/property/m2sd.* files (also, not yet implemented in the app). There are two APK's in the package which uses two different themes (will be changeable in the app when it is done).

    The script should be finished, I have used it myself for the past month, but some more test devices would not hurt. The app however still have some work to be done. The overview is working fine, but I have yet to add some persistent storage for the configurations, so there will be a lot of loading each time you open it. Also there is still no configurations, no log viewer and no app settings for script installation, theme changer and so fourth.

    This is only meant for some early testing, mostly to test the script. It is not a finished product, so don't provide bug reports about missing app features, extensive app loading, missing Aroma installer and so on. All will be available soon. At this point I am only interested in script issues and possible issues with the app overview screen.

    The Script

    • Move Applications, Application Data, Application Libraries, Dalvik-cache and Data Media (Internal Storage) to sd-ext
    • Supports any file system type supported by the kernel
    • Handles Unix Lost+Found folder content to avoid having it take up to much disk usage
    • Supports SWAP and ZRAM (If kernel supports it)
    • Move the main cache partition to data or sd-ext, depending on available space
    • Change storage threshold to minimize the Android low storage market issue
    • Set Readahead and Scheduler for both internal and external MMC
    • Sets optimized mount parameters on the internal partitions
    • Safe-mode and new alternative work-around for service implemented init.d ROM's
    • Compares content with available disk space before moving content around to avoid corrupted data
    • More than a half dozen mount operations to ensure successful sd-ext mount, despite possible issues
    • File system check and repair
    • Enable/Disable ext4 journal
    • Supports storing system applications on /data and /sd-ext
    • A large number of different safe guards to avoid all kinds of thinkable issues
    • Fully adapts to different shell environments
    • 100% functional programming structure (Much better code overview)
    • Properly more...

    The APP

    • Fully working live overview (No more comparing static status properties)
    • Uses my TaskManager project (Handles background work much better)
    • Uses my latest RootFW from the development branch
    • Contains 5 different tab layouts which will be used depending on screen size and rotation
    • Contains both a light and dark theme
    9
    New release is out, and Play Store is finally updated as well. Just missing the recovery package, which I will have ready during the weekend.

    One notice about this release.
    I have added an additional tab entry with the feature of converting apps into system apps. This feature is a paid one, as this seamed like a good way of adding some donations. And because this is only more or less meant as a donation, the downloads on XDA is fully unlocked. Just note that if you install or update from Play Store, you will get a locked version without this additional feature.

    Also, the current feature is only a small start. I am going to add more individual application features to this tab.