1

I am trying to mount WhatsApp media directory from portable SD to internal "SD", as the phone internal storage is very limited.

My phone: Sony Xperia XZ1 Compact (32GB internal storage, 128GB external SD card), Pie 9.0, stock image, bootloader unlocked, dm-verity, and SElinux enforcing. Magisk 20.1 (mount Namespace Mode= Global Namespace). bindfs v.1.14.2.

I have read and tried what is shown in these threads:

Output of /proc/filesystems

nodev   sysfs
nodev   rootfs
nodev   ramfs
nodev   bdev
nodev   proc
nodev   cpuset
nodev   cgroup
nodev   cgroup2
nodev   tmpfs
nodev   configfs
nodev   debugfs
nodev   tracefs
nodev   sockfs
nodev   pipefs
nodev   devpts
        ext3
        ext2
        ext4
        vfat
        msdos
nodev   ecryptfs
nodev   sdcardfs
        fuseblk
nodev   fuse
nodev   fusectl
        f2fs
nodev   pstore
nodev   selinuxfs
        texfat
nodev   functionfs

The last relevant lines of output from mount -r ....

/data/media on /mnt/runtime/default/emulated type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid,default_normal)
/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)
/data/media on /mnt/runtime/read/emulated type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=23,derive_gid,default_normal)
/data/media on /mnt/runtime/write/emulated type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal)
/dev/block/sda60 on /mnt/qns type ext4 (rw,seclabel,nosuid,nodev,noexec,noatime,discard,data=ordered)
/dev/block/vold/public:179,1 on /mnt/media_rw/6534-3933 type texfat (rw,dirsync,nosuid,nodev,noexec,noatime,uid=1023,gid=1023,umask=0007,allow_utime=0020,utf8,min_prealloc_size=64k,max_prealloc_size=121910k,writeback_boundary=4M,readahead=4M,fail_safe,discard,hidden=show,errors=continue)
/mnt/media_rw/6534-3933 on /mnt/runtime/default/6534-3933 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6,nocache)
/mnt/media_rw/6534-3933 on /storage/6534-3933 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6,nocache)
/mnt/media_rw/6534-3933 on /mnt/runtime/read/6534-3933 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18,nocache)
/mnt/media_rw/6534-3933 on /mnt/runtime/write/6534-3933 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18,nocache)

The output of proposed command:

bindfs -u u0_a195 -g 9997 -p a-rwx,ug+rw,ug+X /mnt/media_rw/6534-3933/WhatsApp/Media /mnt/runtime/write/emulated/0/WhatsApp/Media

Gives me the following error:

fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option

I then add the nonempty string to the command, and then the external SD card directory mounts as "internal".

The new lines from mount -r now reads:

/mnt/media_rw/6534-3933/WhatsApp/Media on /mnt/runtime/write/emulated/0/WhatsApp/Media type fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
/mnt/media_rw/6534-3933/WhatsApp/Media on /storage/emulated/0/WhatsApp/Media type fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
/mnt/media_rw/6534-3933/WhatsApp/Media on /mnt/runtime/default/emulated/0/WhatsApp/Media type fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
/mnt/media_rw/6534-3933/WhatsApp/Media on /mnt/runtime/read/emulated/0/WhatsApp/Media type fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)

WhatsApp does READ all the files correctly, however I cannot download anything new to the drive. This is frustrating as hell, as I have come to this stage before. I just can seem to find out how to make WhatsApp being able to WRITE to the directory.

I have used apps like apps2sd, ts-bind, fbind, mount options. Anything under the sun. I can never reach a stage longer than WhatsApp being "tricked" to read from external SD, but never being able to write to external SD.

The only working solution, is not a viable solution, is to install experimental xposed, install old module xinternalSD, and magisk module "ExSDCard Access Enabler". Then WhatsApp works perfectly, but I believe this is a very unstable for the rest of my system and my phone. And I would really like to have a more clean solution to this problem, like the one you are proposing.

Please assist in this great great headache.

Last note, also tried the command as given from your other post:

bindfs -o nosuid,nodev,noexec,noatime,context=u:object_r:sdcardfs:s0 -u 0 -g 9997 -p a-rwx,ug+rw,ugo+X --create-with-perms=a-rwx,ug+rw,ugo+X --xattr-none --chown-ignore --chgrp-ignore --chmod-ignore /mnt/media_rw/6534-3933/WhatsApp/Media /mnt/runtime/write/emulated/0/WhatsApp/Media

Same result after adding nonempty option, WhatsApp can read from external SD, but cannot write to it.

6
  • Hi @Irfan, You seem to be the most knowledgeable person about this issue. I followed your guides to the letter, but they don't seem to work for me. If you see what I have done, it should be OK, no? I was not allowed to comment on the other threads though. Also what difference would it make, if its the whole whatsapp folder or simply the media folder? The result should be the same no? Dec 24, 2019 at 11:51
  • Thank you so much for your active assistence and help. The reason why I dont believe that is the case as you suggest, is if I open the internal SD card, and browse to the folder I have mounted from external/portable SD card, I can read the folder, but cannot write into the folder. This is by 3rd party fole explorer on android (x-plore). This strengtens my suspicion, that there is something fundamentally wrong. Could it be something with SELINUX being set to enforced. Believe someone sugested that on xda forum. Dec 24, 2019 at 13:15
  • Ok. I have tried your suggestion of mounting the whole WhatsApp folder and not the WhatsApp/Media folder. No luck. I also tried mounting via sdcarsfs command given from your other post: bindfs -o nosuid,nodev,noexec,noatime,context=u:object_r:sdcardfs:s0 -u 0 -g 9997 -p a-rwx,ug+rw,ugo+X --create-with-perms=a-rwx,ug+rw,ugo+X --xattr-none --chown-ignore --chgrp-ignore --chmod-ignore /mnt/media_rw/6534-3933/WhatsApp /mnt/runtime/write/emulated/0/WhatsApp So i have tried both the sdcardfs and the vfat mounting. Dec 24, 2019 at 13:42
  • Also may I mind you, that also the file explore can only read the mounted folder, but cannot write to them. Could it be that the context is not the same for all android phones. So for example: context=u:object_r:sdcardfs:s0 should be something else? Dec 24, 2019 at 13:50

1 Answer 1

0

Based on the comment and the self-answer by OP:

This is the main outcome of this thread, and how it was made to work.

  1. WhatsApp will not work if you only bind mount the Media folder in WhatsApp. I have no idea why. I.e. you must bind /WhatsApp and not /WhatsApp/Media

  2. There is a difference if running commands from ADB shell or running from within a terminal app on the phone itself. I never paid attention to this detail before, as I thought they were the same.

  3. bindfs did not work from terminal app on the phone. Somehow it would not load. It would work from ADB shell, but then it would not work properly. Therefore, I used the bind sdcardfs option instead. I.e. full command is:

    mount -t sdcardfs -o nosuid,nodev,noexec,noatime,mask=7,gid=9997 /mnt/media_rw/6534-3933/WhatsApp /mnt/runtime/write/emulated/0/WhatsApp

3
  • Thanks for above but it does not work on Android Q. Any way we can bind mount WhatsApp on Android Q with root Mar 23, 2020 at 1:07
  • actually I tried this very above approach a long time ago. It sounds like /mnt/runtime/write/emulated/0/WhatsApp won't quite point to /Storage/emulated/0/WhatsApp' Unless you maybe unmount whats already mounted 1st. . The latter will keep writing to internal storage so I wonder if / how the above helped ? Apr 10, 2020 at 7:37
  • & I of course WhatsApp's storage is hard coded to /Storage/emulated/0/WhatsApp' . So whatever mischief you do under the hood... the final result should affect this path '/Storage/emulated/0/WhatsApp Apr 10, 2020 at 7:45

You must log in to answer this question.

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