I created an AVD using

 bin/avdmanager create avd -d "Nexus 5" -c 2G -n nexus_5 -k "system-images;android-29;google_apis;x86_64"

The -c 2G is supposed to create a 2GB sdcard.

When I boot the emulator, however, /sdcard seems to point to internal storage on /data/media rather on the 2GB disk:

$ adb shell df -h
Filesystem                    Size  Used Avail Use% Mounted on
tmpfs                         996M  604K  996M   1% /dev
tmpfs                         996M     0  996M   0% /mnt
tmpfs                         996M     0  996M   0% /apex
/dev/block/dm-2               2.4G  2.3G   64M  98% /
/dev/block/dm-1               124M  123M  444K 100% /vendor
/dev/block/vdc                775M  302M  473M  39% /data
/data/media                   775M  302M  473M  39% /mnt/runtime/default/emulated
/dev/block/vold/public:253,80 1.9G  532M  1.4G  27% /mnt/media_rw/1400-1801
/mnt/media_rw/1400-1801       1.9G  532M  1.4G  27% /mnt/runtime/default/1400-1801
$ adb shell ls -l /sdcard /storage/self/primary  /mnt/user/0/primary
lrwxrwxrwx 1 root root 19 2020-12-01 13:29 /mnt/user/0/primary -> /storage/emulated/0
lrw-r--r-- 1 root root 21 2020-07-21 03:02 /sdcard -> /storage/self/primary
lrwxrwxrwx 1 root root 19 2020-12-01 13:28 /storage/self/primary -> /mnt/user/0/primary
$ adb shell mount | grep storage/emulated
/data/media on /storage/emulated type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid,default_normal)

When I try to adb push data to /sdcard this fails because there’s not sufficient space available (on internal storage).

How can I tell the emulator to use the external sdcard instead?


/sdcard isn't physically external SD card but a symlink to primary external shared storage. See details in my answers to Android's Storage Journey and What is /storage/emulated/0/?

From your comment:

How can make Android use the 2GB device instead of the smaller one. How do I configure this?

Android by-default doesn't use secondary external shared storage. But apps can, if they want. See my answer to How to save files to external SD card on a non-rooted Android?.

If you want to make Android always use physical SD card as primary external shared storage, you need to change your ROM's configuration from Emulated primary only or Emulated primary, physical secondary to Physical primary only. It's possible by editing the fstab file and some init's .rc file. Follow the above official documentation links for details on configuration changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.