4

Galaxy S5 running LineageOS 16 (Android 9).

I'm having issues with running out of storage space, even though I have 128GB external SD card, merged with the internal storage. Is there a way to create a symlink from the internal memory to the external SD card, even though they are technically merged and aren't identified as separate storage locations within Android as a result?

I've never made symlinks on Android so I'd appreciate some pointers or resources on that as well.

12
  • post the output of adb shell df
    – alecxs
    Jul 1, 2019 at 12:52
  • pastebin.com/9a1LrHBf
    – BingBong
    Jul 1, 2019 at 14:27
  • it is already mounted to /storage/emulated with 100 GiB free space (84%) no need to symlink
    – alecxs
    Jul 1, 2019 at 14:32
  • But I get warnings about low space sometimes. Should I just ignore that or will it cause issues with the system? My intent with symlinks was to force my large music folder to be stored on the external SD card as well as my TWRP backups.
    – BingBong
    Jul 1, 2019 at 14:33
  • Well i haven't seen one for a day now. But if it persists then I'll comment here again with said screenshot. Thanks for the help
    – BingBong
    Jul 1, 2019 at 14:37

1 Answer 1

5

First of all, symlinks don't work on Android's emulated storage. A workaround is to use bind mounts instead. See this answer for details.

But with Adoptable Storage you don't need to:

  • Create symlink to external SD card
  • Manually move data to external SD card
  • Bind mount a directory from external SD card

Because what you see as /sdcard or /storage/emulated/0 should already be on Adoptable SD Card.

When you format external SD card as Adoptable Storage, it's mounted at /mnt/expand/[UUID], which holds a file hierarchy very similar to /data partition, like /data/app, /data/data and /data/media etc. When you migrate your data to newly created Adoptable Storage, data from /data/media/ is moved to /mnt/expand/[UUID]/media/ and the later is now emulated and bind mounted at /storage/emulated (which apps see).

You can check this by executing df or mount command on a terminal app or adb shell.

Without Adoptable Storage:

~$ df --output=source,target
Filesystem                  Mounted on
/dev/block/dm-0             /data
/data/media                 /storage/emulated
/dev/block/vold/public:8,1  /mnt/media_rw/[UUID]

* dm-0 is FDE encrypted userdata partition, vold public volume is external SD card or USB drive.

Before moving data:

~$ df --output=source,target
Filesystem                  Mounted on
/dev/block/dm-0             /data
/data/media                 /storage/emulated
/dev/block/dm-1             /mnt/expand/[UUID]

* dm-1 is FDE encrypted Adoptable SD card.

After moving data:

~$ df --output=source,target
Filesystem                  Mounted on
/dev/block/dm-0             /data
/dev/block/dm-1             /mnt/expand/[UUID]
/mnt/expand/[UUID]/media    /storage/emulated

* Actually /data/media or /mnt/expand/[UUID]/media is emulated to /mnt/runtime/[default|read|write]/emulated which is bind mounted to /storage/emulated.

You can only move apps (along with their data) to Adoptable Storage which have installLocation set to preferExternal or auto by app developer. In case of auto, default install location (set using pm set-install-location) decides where app will be installed. See this answer for details.

If you want more free space, replace large directories (like /data/media, /data/app and /data/data) with mounts (or bind-mounts) from partitions (or directories) on external SD card. However (DAC and MAC) permissions should be taken care of, otherwise apps (or even OS) may break.


RELATED:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .