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: