0

I want to run the following command as root in the Android Terminal Emulator.

mount -o bind /storage/extSdCard /data/media

I have tested this on a Samsung Galaxy S3 running CyanogenMod 11 and it works as expected. When I enter /data/media using another app like ES File Explorer file manager, I get to the contents of the external SD-card instead of the internal memory.

The problem is that this doesn't work on another S3 I have, this one running stock TouchWiz ROM version 4.3 and rooted with CF-Auto-Root. I have also tried using Adam's Custom kernel and it doesn't work either.

When I run the command on the terminal and then type ls /data/media as root, it shows the external SD-card's content, but if I launch another terminal as a normal user (non root) and type the same command, I get the contents of the internal memory. Same thing happens if I try to access /data/media using ES File Explorer file manager

So it seems that root commands only have effect for the root user, not for other users system-wide. What could be the cause of this behavior?

UPDATE: OK, my bad, I didn't express myself correctly. It is true that a normal user can't access /data/media. But /data/media is the true location of the files in the internal memory. There are lots of paths where android makes this memory available for normal users, like /sdcard or /storage/sdcard0, both of which point to /data/media/0 through a FUSE filesystem.

My though here is that if I create a folder named 0 on the external sd and then bind /storage/extSdCard to /data/media, when the system tries to access /sdcard or /storage/sdcard0 it will get the contents of /storage/extSdCard/0 as /data/media no longer points to internal memory, but to external sd instead.

This works as expected on CM11 when I run as root

mount -o bind /storage/extSdCard /data/media

Then if I access /sdcard on the terminal, either as root and as normal user, I get to the contents of /storage/extSdCard/0. Same thing happens if I use ES File Explorer on normal or root modes

But when I do the same on rooted stock 4.3 firmware it doesn't work. Only root on the terminal can see the changes, normal user on the terminal and normal and root user on ES File Explorer will see no change

2
  • I get the contents of the internal memory.) -- I don't get it how a normal user is even able to see any content in /data/media at all without elevated privileges. You should get an error in terminal, something like "Operation not permitted". About your 2nd case with ES, as a normal user ES shouldn't be showing anything in /data directory and I do not know how to go to a certain location directly using ES (it doesn't seem to have location bar). That said, /data/media can still be accessed by a normal user using Terminal. I checked it, works well.
    – Firelord
    Commented Apr 30, 2015 at 5:17
  • Yes, you are right, I dindn't express myself well. I edited the question providing additional info
    – ZapperDJ
    Commented Apr 30, 2015 at 18:12

2 Answers 2

1

My case, I suppose it's the same reason for you.

Go to your Superuser manager app, I suppose it's SuperSU.

Go to settings, and look for 'Mount Namespace Separation' and check if it's ticked. Uncheck the option and reboot.

SuperSU provided this option to make your system safer by hiding one app's mount namespace from others', thus if you mount or unmount something, it's only visible to the app (UID) you're using and nothing else.

Alternatively, when running su, you can add an option -m to make your shell have the control of master mount namespace. Then your mounts will work globally.

0

Apparently, this is now an Android SELinux security feature -- mounts initiated from most processes are not visible to other processes. See this answer.

A related Android kernel development thread suggests replacing an uneeded system service (e.g. /system/bin/debuggerd) with a shell script that runs the desired mount command. This you'd launch with start debuggerd.

Update: This did work for me, after a reboot.

You must log in to answer this question.

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