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.

Irfan Latif
  • 20,353
  • 3
  • 70
  • 213
BingBong
  • 141
  • 1
  • 3
  • post the output of adb shell df – alecxs Jul 01 '19 at 12:52
  • https://pastebin.com/9a1LrHBf – BingBong Jul 01 '19 at 14:27
  • it is already mounted to /storage/emulated with 100 GiB free space (84%) no need to symlink – alecxs Jul 01 '19 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 01 '19 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 01 '19 at 14:37
  • i can see the /data partition is full (92%) maybe you forgot to Migrate? Go to Settings > Storage & USB and tap your SD card. Tap the three dots in the upper-right corner and choose “Migrate data” – alecxs Jul 01 '19 at 14:42
  • @alecxs when I select the external SD card, the three dots show: rename, eject, format as portable. I see a migrate option in the internal SD card's three-dot menu, but I believe that is trying to move data to the internal memory. I tried it anyway and it said "not enough space" – BingBong Jul 01 '19 at 16:01
  • then see Irfan Latif - move the apps separately - Go to Settings > Apps and tap on an app. Tap “Storage”. At the top of the resulting window you should see “Storage used: Internal storage”. Tap the “Change” button – alecxs Jul 01 '19 at 16:36
  • Okay. I've done that for the big ones (OSMand and google maps with downloaded maps). A bulk of my data are just music files and TWRP backup files. Any way to force those to be stored on the external SD card like I just did with apps? Also, is there a way to have new apps installed to the external sd card by default from now on? – BingBong Jul 01 '19 at 16:41
  • nvm about default installation directory. I discovered that since merging the external sd card with internal, it installs new apps to the external sd card by default. Still curious about moving mp3 files and TWRP backup files into the sdcard though. Maybe I could use the terminal to move them into the sd card? Not sure how the external is mounted and if it's similar to Linux in that it would be located in /mnt or /media/user/ – BingBong Jul 01 '19 at 16:55
  • /mnt/expand/9cf8b187-cdba-4fad- 9d1c-14a17d4be4de – alecxs Jul 01 '19 at 18:11
  • @alecxs thank you – BingBong Jul 01 '19 at 19:01

1 Answers1

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:

Irfan Latif
  • 20,353
  • 3
  • 70
  • 213