LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Mobile (https://www.linuxquestions.org/questions/linux-mobile-81/)
-   -   Can't share SD card between Android and GNU/Linux (https://www.linuxquestions.org/questions/linux-mobile-81/cant-share-sd-card-between-android-and-gnu-linux-4175643649/)

ordealbyfire83 12-04-2018 07:20 PM

Can't share SD card between Android and GNU/Linux
 
I'm having some weird problem with an SD card being rejected by Android (Replicant, Marshmallow) as "corrupted" when it is not. I typically move this card between a camera, my laptop, and Android and as it was called "corrupted" I decided to move everything off, overwrite the entire space, and re-format. The camera expects a particular UID, so I had to manually edit the FAT32 partition's identifier. What I'm finding out is that Android accepts this card when I use a new UID, but when I specify the old one, it is automatically corrupt.

Is there any way to completely reset Android's knowledge of SD cards? Something seems off here.

Keith Hedger 12-07-2018 08:49 AM

Are you formatting the card on the camera or the android device?

KIOPRET 12-09-2018 09:21 AM

try formatting your SD card and choosing FAT instead of NTFS, FAT seems to be more friendly towards mobile devices

ondoho 12-09-2018 03:49 PM

Quote:

Originally Posted by KIOPRET (Post 5935143)
try formatting your SD card and choosing FAT instead of NTFS, FAT seems to be more friendly towards mobile devices

did you even read the first post?

here:
Quote:

Originally Posted by ordealbyfire83 (Post 5933351)
The camera expects a particular UID, so I had to manually edit the FAT32 partition's identifier.


rokytnji 12-09-2018 05:37 PM

Hmmm.

Quote:

A unique identifier (UID) is a numeric or alphanumeric string that is associated with a single entity within a given system. UIDs make it possible to address that entity, so that it can be accessed and interacted with.
https://developer.android.com/studio...d-line/dumpsys

Take my post with a grain of salt. These waters I am in are deeper than I am used to.

business_kid 12-18-2018 09:01 AM

I would expect a camera and an android to format sdcards as FAT.

You need to unmount fat partitions because they automatically set (and ignore) a 'dirty' bit. Then when you unmount it, it clears that 'dirty' bit. If you don't unmount it, the next OS will wag fingers at you. It's a pain, nothing to go reformatting about. Just repair it.

ordealbyfire83 11-28-2021 12:05 AM

Not to bump an old thread, but having run into this issue again, I thought I would share my findings in case anyone else has this problem too.

Android has two ways of dealing with removable SD cards, one which uses it as storage for installed apps, and another which treats it as a removable flash drive. If you insert an SD card into your Android device that was formatted and filled with data elsewhere, it will be treated as the second.

In this case, if an app tries to store its own data on the SD card (either on its own will or if you tell it to), Android will no longer be able to tell which of the two ways it should treat the SD card. If you go through the system logs using logcat, you will probably see something like

Code:

11-28 00:15:02.175  1934  1986 E cutils  : Failed to lstat(/mnt/runtime/write/F045-D0FA): Transport endpoint is not connected
11-28 00:15:02.175  1934  1986 V vold    : /dev/block/vold/public:179_17: UUID="F045-D0FA" TYPE="vfat"
11-28 00:15:02.175  1934  1986 E vold    : public:179_17 failed to create mount points: Transport endpoint is not connected
11-28 00:15:02.175  2372  2485 D VoldConnector: RCV <- {652 public:179_17 vfat}
11-28 00:15:02.175  2372  2485 D VoldConnector: RCV <- {653 public:179_17 F045-D0FA}
11-28 00:15:02.175  2372  2485 D VoldConnector: RCV <- {654 public:179_17 sdcard1}
11-28 00:15:02.175  2372  2485 D VoldConnector: RCV <- {656 public:179_17 /mnt/media_rw/F045-D0FA}
11-28 00:15:02.175  2372  2485 D VoldConnector: RCV <- {655 public:179_17 /storage/F045-D0FA}
11-28 00:15:02.175  2372  2485 D VoldConnector: RCV <- {651 public:179_17 6}
11-28 00:15:02.175  2372  2485 D VoldConnector: RCV <- {400 23 Command failed}
11-28 00:15:02.180  2372  2484 D MountService: Volume public:179_17 broadcasting checking to UserHandle{0}
11-28 00:15:02.180  2372  2484 D MountService: Volume public:179_17 broadcasting unmountable to UserHandle{0}
11-28 00:15:02.180  2372  2392 I ActivityManager: Killing 9966:com.android.shell/2000 (adj 13): empty for 1802s
11-28 00:15:02.215  2549  2549 D StorageNotification: Notifying about public volume: VolumeInfo{public:179_17}:
11-28 00:15:02.215  2549  2549 D StorageNotification:    type=PUBLIC diskId=disk:179_16 partGuid=null mountFlags=VISIBLE
11-28 00:15:02.215  2549  2549 D StorageNotification:    mountUserId=0 state=UNMOUNTABLE
11-28 00:15:02.215  2549  2549 D StorageNotification:    fsType=vfat fsUuid=F045-D0FA fsLabel=sdcard1
11-28 00:15:02.215  2549  2549 D StorageNotification:    path=/storage/F045-D0FA internalPath=/mnt/media_rw/F045-D0FA

Of note is the part "Transport endpoint not connected" and the SD card being flagged as unmountable.

The solution to this problem is:

1. Uninstall whatever app tried to write to the SD card (meaning, whatever app tried to write to your 'removable' sd card while treating it as 'internal storage'. (First back up any necessary data, of course.)

2. Make sure the SD card is physically removed.

3. Reboot the device.

4. Re-insert the SD card. It shouldn't be marked as 'corrupted' anymore.

For this scenario, rest assured, your SD card is certainly NOT corrupted, so don't take Android up on its offer to format your SD card. In my case, I dropped my supposedly corrupted SD card into another identical phone, and it was read without issue. Likewise you do not need to alter the UUID.

This issue in 2021 is still found in the latest Replicant images. So it is still a relevant problem to be watched out for.


All times are GMT -5. The time now is 05:35 PM.