Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Termux can't write to external SD card #1886

Closed
rptb1 opened this issue Jan 14, 2021 · 2 comments
Closed

Termux can't write to external SD card #1886

rptb1 opened this issue Jan 14, 2021 · 2 comments

Comments

@rptb1
Copy link

rptb1 commented Jan 14, 2021

Problem description

I have a Fairphone 3 with an SD card slot, and I have installed an SD card with a single FAT partition formatted by the phone. termux-setup-storage asks for permission to access /storage/emulated/0, and that all works, but it does not ask for permission to access /storage/ID and Termux can't write to any files there.

By contrast, Resilio Sync (also on SDK 28) explicitly asks to be granted permission to the SD card and after doing so, is able to write there.

Screenshot_20210114-110456_Sync

Note that my Termux has been granted the "Storage" permission in the apps settings. This is a separate permission.

I have read Internal and external storage but this is not about /storage/emulated/0, which is on my phone's internal flash memory.

Steps to reproduce

  1. termux-setup-storage
  2. cd /storage/ID/Download (substitute the id of your SD card's FAT FS)
  3. echo foo > bar gets a permission denied message

Expected behavior
I want to be able to work on files on the SD card using Termux.

Perhaps termux-setup-storage needs to ask for more permission.

Additional information

  • Termux application version: 0.104 from F-Droid
  • Android OS version: 10, /e/OS, e_FP3-userdebug 10 QQ3A.200805.001 eng.root.20201207.195119 dev-keys, developer mode, rooted by Magisk
  • Device model: Fairphone 3
@rptb1
Copy link
Author

rptb1 commented Jan 14, 2021

This may not be an app permissions issue, but something to do with filesystem permissions or the way bind mounts and sdcardfs mounts are set up. Here's some evidence:

.../FB03-5D01/Download $ sudo sh -c "echo foo > bar"
.../FB03-5D01/Download $ cat bar
foo
.../FB03-5D01/Download $ df .
Filesystem              1K-blocks    Used Available Use% Mounted on
/mnt/media_rw/FB03-5D01 104831968 1041216 103790752   1% /storage/FB03-5D01
.../FB03-5D01/Download $ mount | grep FB03
/dev/block/vold/public:179,65 on /mnt/media_rw/FB03-5D01 type vfat (rw,dirsync,nosuid,nodev,noexec,noatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/mnt/media_rw/FB03-5D01 on /mnt/runtime/default/FB03-5D01 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6)
/mnt/media_rw/FB03-5D01 on /mnt/runtime/read/FB03-5D01 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18)
/mnt/media_rw/FB03-5D01 on /mnt/runtime/write/FB03-5D01 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18)
/mnt/media_rw/FB03-5D01 on /mnt/runtime/full/FB03-5D01 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=7)
/mnt/media_rw/FB03-5D01 on /storage/FB03-5D01 type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18)
.../FB03-5D01/Download $ ls -ld .
drwxr-xr-x 2 root everybody 32768 Jan 14 11:41 .
.../FB03-5D01/Download $ su
:/storage/FB03-5D01/Download # ls -ld /mnt/runtime/*/FB03-5D01/Download
drwxrwx--x 2 root sdcard_rw 32768 2021-01-14 11:41 /mnt/runtime/default/FB03-5D01/Download
drwxrwx--- 2 root everybody 32768 2021-01-14 11:41 /mnt/runtime/full/FB03-5D01/Download
drwxr-xr-x 2 root everybody 32768 2021-01-14 11:41 /mnt/runtime/read/FB03-5D01/Download
drwxr-xr-x 2 root everybody 32768 2021-01-14 11:41 /mnt/runtime/write/FB03-5D01/Download

@Grimler91
Copy link
Member

Duplicate of #20, #1683 (and some other issues).

It is currently only possible to write to termux's folder on the external storage, /storage/FB03-5D01/Android/data/com.termux/files/ (i.e. ~/storage/external-1).
Might be possible to make it work for android <= 10, but requires some work, discussed in #1617, termux/termux-packages#5486

@ghost ghost locked and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants