2

I want to mount-bind an app data folder in /data/data/... to a user subfolder in order to automatically synchronize the contents for backup purposes. As root I use the following command:

mount -o bind /data/data/org.blabla.app/database/ /storage/emulated/0/blabla_database

The command seems to work and I can access the files in the mounted folder as long as I am root. However, as soon as I exit root, the files become invisible and the bind-mounted folder is empty.

How can I make the files visible for non-root users so that my sync app can access the files for backup?

3
  • Just a guess: Are you using SuperSU? If so, please check whether switching off "mount namespaces" helps. For details, see What does “mount namespace separation” in the app SuperSU do?
    – Izzy
    Commented Jul 25, 2016 at 6:55
  • Thank you Izzy, you are right! Un-checking "mount namespace separation" in the SuperSU preferences makes a difference. But here comes the weird part: When I change back from root to normal user in the remote SSH, which I am using, I can effectively see the bind-mounted files now. But the files remain still invisible in the file manager and even if I open a new Termux shell and cd into the folder. Isn't that weird?? If I change to root (su -) in Termux I can see the files again %-( Any ideas?
    – Aron
    Commented Jul 26, 2016 at 12:01
  • Unfortunately no more ideas, sorry. Hopefully someone else can pick up from here.
    – Izzy
    Commented Jul 26, 2016 at 12:04

1 Answer 1

2

In order to have different file ownership and permissions for every app in /sdcard, since Android 6 every app is run in an isolated mount namespace. /storage/emulated is bind mounted for every app with private / slave mount propagation to a different VIEW:

/mnt/runtime/default/emulated
/mnt/runtime/read/emulated
/mnt/runtime/write/emulated

It depends on if the app has READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permission granted or not. For details see What is the “u#_everybody” UID?

Mounting directly to /storage/emulated won't appear in apps' mount namespaces unless you enter every app's mount namespace explicitly. The same is true if you mount from some app's isolated mount namespace as mentioned by @Izzy in comment. See Partition gets unmounted automatically in Android Oreo.

So you need to mount from root mount namespace to one of the above VIEWs, so that mount is propagated to all apps' mount namespaces.

For more details see How to bind mount a folder inside /sdcard with correct permissions?

You must log in to answer this question.

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