2 of 3
added 904 characters in body

Mounting portable SD card folder to internal folder (WhatsApp) - Tried EVERYTHING

******************** SOLVED ***************

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. Ie. 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, bit then it would not work properly. Therefore I used the bind sdcardfs option instead. Ie. 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

******************** SOLVED END ***************

I have used so many days on this issue, and I view my self as quite capable. Hope someone here can help in this regard.

I have read and tried what is shown in these threads. Here: How to bind-mount "data" and "obb" folders from external SD card in "/sdcard/Android"?

Here: How can I make a symlink (or equivalent) inside /storage/emulated/0?

Here: How to bind mount a folder inside /sdcard with correct permissions?

And here: Why can't WhatsApp write to bind mounts?

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, XZ1 compact (32GB internal storage, 128GB external SD card), Pie 9.0, stock image, bootlocker unlocked, dm-verity, and SElinux enforcing. Magisk 20.1 (mount Namespace Mode= Global Namespace). bindfs v.1.14.2

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.