3

In short: if I mount my Ext4 8GB SD card, only root (SU) can see it. The rest of users (so, the rest of apps) don't detect it.

As long as my Ext4 SD card is not correctly mounted (Android always yields Damaged SD card. Format it... blah blah blah), I followed this guide to mount it. And it works:

SD Card is at /dev/block/mmcblk1, so first partition is at /dev/block/mmcblk1p1.
I performed the (not very clear for me) prior ADB process:

su
setprop service.adb.tcp.port 5555
adb kill-server
stop adbd
start adbd
HOME=/sdcard adb start-server
adb connect localhost
adb -s localhost:5555 shell
exit
stop adbd
cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys
start adbd

And then the card is correctly mounted by doing (as root):

# mount -t ext4 /dev/block/mmcblk1p1 /storage/extSdCard && sleep 5 && /system/bin/vold

Note how it works as SU but not as normal user:

root@unknown:/ # ls /storage/sdcard1
lost+found
root@unknown:/ # exit
u0_a98@unknown:/ $ ls /storage/sdcard1
ls: can't open '/storage/sdcard1': Permission denied

I have tested the above steps via SSH (remote shell).
The SD Card has been formatted from Windows using Minitool Partition Wizard.

I have tested too:

  • Editing the /system/etc/permissions/platform.xml file manually (adding <group gid=”media_rw” />) to WRITE_EXTERNAL_STORAGE section, as referred here.
  • SDFix.
  • Using Xposed framework with HandleExternalStorage module.

But the apps (Total Commander, Ghost Commander, or any other program) have no access to the Ext4 SDCard.

What else could I try?
Workarounds to make apps read (and write) SD Card accepted too.

Extra data 1:

Note the output of the mount command for both users:

root@unknown:/ # mount | grep "sdcard" -i
/dev/block/mmcblk1p1 /storage/sdcard1 ext4 rw,seclabel,relatime,data=ordered 0 0
root@unknown:/ # exit
u0_a98@unknown:/ $ mount | grep "sdcard"
u0_a98@unknown:/ $ mount | grep "mmcblk"

As can be seen, the root user has a mounted device that the normal user has not (!). I did not know this could happen on Linux.

2

Mounting

Try logging in as a root user with proper mounting permissions using

su -mm

Make sure that a directory exists that receives the mount:

mkdir /mnt/arch1

You can also create an empty folder inside your internal storage and use that mount point instead if Apps won't allow you to browse in the / root directory.

Mount your ext4 partition using

mount -t ext4 -o noatime /dev/block/mmcblk1p2 /mnt/arch1

whereas mmcblk1p2 is the second partition of my sdcard in my case. You can replace /mnt/arch1 with any other path you wish.

My first partition is formatted (and acting as extSdCard) with FAT32 as a fallback, so Apps write their stuff there while my ext4 partition is "safe" and to prevent OSes accidentally formatting the whole SD-Card when inserting it.

You should now be able to browse inside that mount point using either your terminal (rooted and non-rooted) or your apps.

To automatically mount the partition on startup, you can use this line

su -mm -c mount -t ext4 -o noatime /dev/block/mmcblk1p2 /mnt/arch

in Tasker for example.

Unmounting / mount information

Please note that mount points of -mm in turn aren't visible to the "regular" root (without -mm). To unmount the partition, you would have to login with -mm again and use umount /dev/block/mmcblk1p2 or umount /mnt/arch1 from there.

Checking whoami won't reveal being logged in with or without -mm.

What I can't answer

Unfortunately I have no idea how to mount it in that way that your ext4 partition is displayed as real external storage by standard file managers. You would have to do the workaround by creating a directory inside your internal storage mentioned earlier.

How I figured it out

I experienced the exact problem. I gave the fact that other apps can't access the mount a further thought. Maybe the root user is not supposed to mount partitions for use with Android apps. I noticed a directory called media_rw is owned by media_rw (yes, same names) so I thought about suing as a media_rw user and applying the above steps.

While reading the help page with su --help within Android, I stumbled across this part:

-m, -p,
-mm, --mount-master          connect to a shell that can manipulate the
                             master mount namespace - requires su to be
                             running as daemon, must be first parameter

So tried logging in as a root user with the -mm option instead, mounted my partition from there and surprise - I was able to see my stuff in Total Commander and open media files from there with VLC.

My device in particular is the Planet Computers Gemini, using stock Android 7.1.1 (Nougat) rooted with SuperSU.

1

@djsumdog and @Sopalajo de Arrierez Sorry for the delayed response.

Things got re-orgonized and stream lined. By unifying those that use the fstab files. Such as the init, vold, and recovery all under /fstab.<device> now. Some of which is managed by vold and just off the top of my head it sounds like a permissions issue because with root it's like an override with its R/W powers. Linux used to have an issue with android when formatting due to this but I do not know if it was fixed.

" DEVICES MAY PROVIDE EXTERNAL STORAGE BY EMULATING A CASE-INSENSITIVE, PERMISSIONLESS FILESYSTEM BACKED BY INTERNAL STORAGE. "

" When configuring a device-specific init.rc script,the EXTERNAL_STORAGE environment variable must be defined as the path to the primary external storage. The /sdcard path must also resolve to the same location, possibly through a symlink. If a device adjusts the location of external storage between platform updates, symlinks should be created so that old paths continue working."

"One possible implementation is provided by the FUSE daemon in system/core/sdcard, which can be added as a device-specific init.rc service":

virtual sdcard daemon running as media_rw (1023)
service sdcard /system/bin/sdcard <source_path> <dest_path> 1023 1023
    class late_start

"Where source_path is the backing internal storage and dest_path is the target mount point."

Reference

0

Thanks for this discussion. Here is what "kind of" works on my Android 5.1 TV computer:

su -mm -c mount -t ext4 -o noatime /dev/block/mmcblk0p1 /storage/sdcard1 &&  sleep 5 && /system/bin/vold
chown -R root:sdcard_r /storage/sdcard1
chmod 771 /storage/sdcard1

I say "kind of" because this is still not seen as a true, external storage card by Android or file manager apps (and the like). However, all apps can read/write/traverse the folder tree and do what they need to. You do NOT have to be root except to do this. As things stand for me now, I have to re-issue this upon every re-start of Android. But using Tasker makes this pretty easy to accomplish.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.