Can't sync to SD card Android 10

So I might be stuck using Resilio instead? Because that syncing tool manages write access.

1 Like

Ah… but the key is that the root of the SD card isn’t a regular directory. :wink:

Take the following example where the volume label for a SD card is “1234-ABCD”. When the SD card is inserted, Android 10 and up creates a temporary subdirectory under /storage using the SD card’s label:

storage/1234-ABCD

The path above is then the mount point for the SD card. It doesn’t matter what permissions are on the subdirectory 1234-ABCD because it’ll be superseded by whatever is applied during the automount.

Android allows an app to create files and folders at the root of the SD card if the app has been granted permissions by user. So VLC could make a subdirectory:

storage/1234-ABCD/Music

Likewise, Syncthing could also be told to use the root of the SD card, and if granted access by the user:

storage/1234-ABCD/.stfolder

However, it doesn’t mean that Syncthing can now simply come along and copy files into the Music folder above because the folder was created by VLC.

Nope, you’re not insane. :grinning:

Perhaps this will help. Here’s a real-world demonstration on my phone using a terminal app:

In the screenshot above (cropped for size), the shell prompt in the terminal app starts at the root of Android’s filesystem (/):

  1. I change over to the base storage directory (cd /storage).
  2. I try to list the contents of /storage and I’m denied.
  3. Next I change over to my SD card that has the volume label “2FC9-191C” (cd 2FC9-191C).
  4. Now I’m at /storage/2FC9-191C and able to list the contents because my terminal app has “media” access in Android.
  5. However, when I try to create a new subdirectory (mkdir testdir) I’m denied because I only granted the terminal app permission to access the SD card, not write or modify files. If the terminal app encounters any files and/or folders that aren’t world readable, it’ll also be permission denied.

At the same time, Syncthing has been happily syncing music files from my laptop into /storage/2FC9-191C/Music. Syncthing only gets blocked if I try to give it full control of /storage/2FC9-191C.

Now let’s take a closer look at the folder ownership and permissions:

So users in the “everybody” group are able to read, write and execute files starting at /storage/2FC9-191C. Same permissions on all of the top-level subdirectories on the SD card.

But… just when it looks simple…

image

Command “ls -ldZ” above does a “long list of the directory, and not its contents, plus the security context that’s in force”.

In the output above, the string “u:object_r:fuse:s0” is a SELinux file security context label.

Note how the /storage/2FC9-191C mount point has a “fuse” security type. It means that the view of the SD card contents in a file manager app, file picker, terminal app, etc. are all filtered through the FUSE kernel module.

As mentioned earlier, FUSE adds additional security. When combined with SELinux, access to a file/folder can be limited down to a single app, even if the file/folder has “rwx” (read/write/execute) bits enabled for all.

If you’re comfortable with a command-line, you could install a terminal app (I like ConnectBot) and repeat the steps I described above to get a listing of the permissions including SELinux security context labels.

Post screenshots and it might give enough clues to help fix the problem.

My phone shipped with Android 10 and I upgraded it to Android 11 so my results aren’t going to exactly match yours. Scoped Storage and FUSE weren’t mandatory until Android 11, but they were present in Android 10.

Oh, yeah I use Linux on my NAS, not scared of a shell, just not exactly running into that many “fancy” file permissions there!

I went with the app that you recommended, and went for it.

This is how it behaves, regardless of if I give the app storage permissions or not.

Apparently my phone doesn’t use Fuse for the SD card

It’s not always easy to tell online. :grinning:

I’ve worked with people with computer science degrees who almost have a panic attack when they have to use a CLI.

Yeah, it’s still using the old SDCardFS system – a Samsung creation that was later adopted by Google for Android 8/Oreo (the irony is that Google switched from FUSE to SDCardFS and then back to FUSE again for Android 11).

SDCardFS is its own filesystem while FUSE is a VFS (virtual file system) module that supports all kinds of filesystems including FAT, VFAT, exFAT, NTFS, etc.

Because my Motorola phone was upgraded to Android 11, it ended up with kernel 4.19 while a factory fresh Android 11 phone would be on 5.4. Phones that have Android 11 + Linux kernel version 5.4 are barred from using SDCardFS (the user is told that the SD card needs to be formatted).

This brings up an interesting question… has your SD card been reformatted since you upgraded to Android 10?

I actually don’t know. I got this phone used, put my own SD card in. So I might actually only ever had used it with Android 10

But I really can’t remember if it already had Android 10 when I got it or not…

The reason I asked is because I’m wondering if reformatting the SD card would help since Android 10 has the updated FUSE system that’s also in Android 11.

I dug out my older phone that has an SD card and is running Android 9 (“Android One” edition, so stock Android with only a few bundled apps from the manufacturer) to take a closer look:

  • FUSE is still in the kernel. FUSE is used for OTG (USB On-The-Go) to access USB flash drives.
  • SDCardFS is the default format for the SD card.
  • I was able to replicate the Syncthing behavior you’re seeing on your Galaxy S9.

Since you’re comfortable with a command-line and Linux, just in case you’re feeling adventurous and have some time to burn… :wink:

Google’s AOSP (Android Open Source Project) has been used to create new OS images for older devices. Currently the most popular project is LineageOS (http://lineageos.org/).

Instructions for upgrading a Samsung Galaxy S9:

After upgrading:

A few years ago I upgraded one of my old Android tablets and will eventually upgrade my Android 9 phone to Android 12.

Personally, I’d be very cautious about recommending custom ROMs to someone with no previous experience, especially when there is no official LineageOS support like in this case. XDA downloads are bound to be buggy in some way, e.g. they claim that everything “works”, then after installation you realise that the feature you need is either broken or not available at all. This is true especially with Samsung who aren’t exactly known for their openness and community support which as a result makes their devices difficult to mod. Multiple different models of the “same” device with hardware differences between them don’t help either. There may be some exceptions but I’m just speaking from experience having used a variety of different Samsung phones and tablets for ~10 years or so.

So called “instructions” on how to install custom ROMs that are available on the Internet are also often very sketchy, e.g. the first link talks about using fastboot which doesn’t even work on Samsung devices (which require Odin instead).

Oh yeah! I used install custom ROMs on all my previous phones! But I decided against using it because even though I spent hours with magisk hide on my A5, I couldn’t get my banking app to work properly, and even just getting Netflix to work was a huge pain…

I think I’ll live with using Resilio Sync instead for this application, since it can write to the SD card (even the root of it) just fine :sweat_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.