Search code examples
javaandroidstoragevirtualandroid-sdcard

Create a virtual Memory using Internal Storage


I want to basically create a virtual Memory like SD Card in my Android device running 8.0 and is rooted.

So basically all the other apps(Like File Browsers) should recognize it as a SD card where as it is just going to be a virtual memory.

And they should also recognize my Internal Memory.

Is this possible to achieve?

Any help would be grateful.


Solution

  • Your question is not clear, but it seems that you want to expose some of your device's virtual memory (RAM) as a virtual SD card.

    Looking at how people attempted to address a different problem (see https://forum.xda-developers.com/showthread.php?t=948887), I infer that one way to do it would be:

    • Create a "tmpfs" file system
    • Mount it1 at the location where Android would mount an regular external SD card.

    (Sorry: no commands to copy and paste. This kind of stuff could brick your device. Anyone doing this should take responsibility for looking up and reading the manual ... so that they understand what they are doing themselves.)

    The problem is that there is no standard that tells Android device manufacturers where SD cards should be mounted. And apparently, different manufacturers put the cards in different places. (The Android developer docs say that you shouldn't use hard-wired pathnames ...)

    A couple of common patterns I have seen for SD card pathnames:

    • There is often a "/sdcard" symlink that points to the place where the SD card or cards are actually mounted.
    • The SD card file systems are often mounted within the "/mnt" tree.

    You will need to investigate what happens on your device ...


    1 - I would be cautious about making this a permanent mount to start with. If this approach fails, you may need to reboot to recover. If you made the mount permanent, there is a risk that you would not be able to boot. I don't know if it is possible to recover from that.