1. Are you ready for the Galaxy S20? Here is everything we know so far!

Cannot access internal phone memory through terminal or shell

Discussion in 'Android Lounge' started by izabelle221, Jul 11, 2020.

  1. izabelle221

    izabelle221 Lurker
    Thread Starter

    I have a Samsung A5 (2017) with android 8.0 and while using the termux application and/or the shell command through adb I noticed that after running df -h I get this result:

    Filesystem Size Used Avail Use% Mounted on
    rootfs 1.2G 9.3M 1.2G 1% /
    tmpfs 1.3G 1.0M 1.3G 1% /dev
    tmpfs 1.3G 0 1.3G 0% /mnt
    tmpfs 1.3G 0 1.3G 0% /mnt/secure
    /dev/block/mmcblk0p19 4.5G 4.1G 435M 91% /system
    /dev/block/mmcblk0p20 193M 3.9M 189M 3% /cache
    /dev/block/mmcblk0p25 24G 21G 2.5G 89% /data
    /dev/block/mmcblk0p3 16M 2.9M 13M 19% /efs
    tmpfs 1.3G 0 1.3G 0% /storage
    /data/media 24G 21G 2.5G 90% /storage/emulated
    /mnt/media_rw/27FF-4487 59G 3.5G 56G 7% /storage/27FF-4487

    Now I can guess that both /dev/block/mmcblk0p25 24G 21G 2.5G 89% /data AND /data/media 24G 21G 2.5G 90% /storage/emulated are the same and this is where the phone memory is mounted. Not sure why I see 2 different mounts for the same drive but that's not really the point here.

    What I am really interested in is why I cannot access by doing ls any of those locations

    ls /data
    ls: /data: Permission denied

    ls /storage/emulated
    ls: /storage/emulated: Permission denied

    By using the "My Files" application I can access the contents of "My Files > Internal Storage" and everything else that's inside. I assume this location it's the same as those 2 shown by the df command so why I cannot access them via shell?

    If possible, an overview of all the other mounts shown by the df command would be appreciated as would shed more light on the android mounting system.

    The mount command shows this:

    rootfs on / type rootfs (ro,seclabel,size=1306380k,nr_inodes=326595)
    tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,mode=755)
    devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
    proc on /proc type proc (rw,relatime,gid=3009,hidepid=2)
    sysfs on /sys type sysfs (rw,seclabel,relatime)
    selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
    /sys/kernel/debug on /sys/kernel/debug type debugfs (rw,seclabel,relatime)
    none on /acct type cgroup (rw,relatime,cpuacct)
    tmpfs on /mnt type tmpfs (rw,seclabel,relatime,mode=755,gid=1000)
    none on /config type configfs (rw,relatime)
    tmpfs on /mnt/secure type tmpfs (rw,seclabel,relatime,mode=700)
    tmpfs on /mnt/secure/asec type tmpfs (rw,seclabel,relatime,mode=700)
    none on /dev/cpuctl type cgroup (rw,relatime,cpu)
    pstore on /sys/fs/pstore type pstore (rw,seclabel,relatime)
    /dev/block/mmcblk0p19 on /system type ext4 (ro,seclabel,noatime)
    /dev/block/mmcblk0p20 on /cache type ext4 (rw,seclabel,nosuid,nodev,noatime,journal_checksum,journal_async_commit,noauto_da_alloc)
    /dev/block/mmcblk0p25 on /data type ext4 (rw,seclabel,nosuid,nodev,noatime,journal_checksum,journal_async_commit,noauto_da_alloc)
    /dev/block/mmcblk0p3 on /efs type ext4 (rw,seclabel,nosuid,nodev,noatime,discard,journal_checksum,journal_async_commit,noauto_da_alloc,data=ordered)
    tmpfs on /storage type tmpfs (rw,seclabel,relatime,mode=755,gid=1000)
    adb on /dev/usb-ffs/adb type functionfs (rw,relatime)
    /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,reserved=20MB)
    /data/media on /storage/emulated type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid,reserved=20MB)
    /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,reserved=20MB)
    /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,reserved=20MB)
    /dev/block/vold/public:179,33 on /mnt/media_rw/27FF-4487 type sdfat (rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,fs=exfat,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,utf8,namecase=0,adj_req,symlink=0,bps=512,errors=remount-ro)
    /dev/block/vold/public:179,33 on /mnt/secure/asec type sdfat (rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,fs=exfat,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,utf8,namecase=0,adj_req,symlink=0,bps=512,errors=remount-ro)
    /mnt/media_rw/27FF-4487 on /mnt/runtime/default/27FF-4487 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6,derive_gid)
    /mnt/media_rw/27FF-4487 on /storage/27FF-4487 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6,derive_gid)
    /mnt/media_rw/27FF-4487 on /mnt/runtime/read/27FF-4487 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18,derive_gid)
    /mnt/media_rw/27FF-4487 on /mnt/runtime/write/27FF-4487 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18,derive_gid)
     


  2. Hadron

    Hadron Smoke me a kipper...
    VIP Member

    Have you tried accessing /storage/emulated/0, or /sdcard? Those are the paths to the user-accessible part of the internal storage.

    My guess is that without root privileges you don't have read access to the directories higher up the filesystem, but you should be able to see those (I checked this just now on an unrooted phone with a terminal emulator).

    As for why these multiple paths to the same place, a lot of that is history (updating to a more flexible file structure while not breaking old, badly-written apps). /data includes the space you can access, but also the region where apps' private data is stored (which you can't), so you can only see another virtual volume inside that (which is the one I've given 2 paths to above) rather than the whole thing.
     
    ocnbrze, Dannydet and MoodyBlues like this.
  3. svim

    svim Extreme Android User

    Keep in mind that the Termux app is its own pseudo-container and starts up with just one user. And while you can install your own mini-CLI-only distro within it, it's still not going to give you root privileges to the host operating system (i.e. You can install the proot apk to go crazy within Termux but it's still a running as a non-root app, just like the My Files app, so you cannot get unfettered access to the system-level directories in the Android OS itself.
    https://wiki.termux.com/wiki/Internal_and_external_storage
    https://wiki.termux.com/wiki/PRoot
     
    ocnbrze, Dannydet and MoodyBlues like this.
Loading...

Share This Page

Loading...