0

As I am aware after Android 4.4 or some sort your storage card is no longer eXposed directly and needs to be carefully interfaced through specific Mount points that need to be aware through vold system
My question is given this situation and the fact that ext4 is very complicated in terms of of access and especially with now SeLinux sitting on top of it it is somehow still possible to render ext4 support when it did not exist initialy as has been the case for lineage and previous similar OS's that would be the case if the mount points are created at boot time and then vold is made aware of them


what I did
since I am rooted ( magisk ) I use su mount master and mounted these manually but trying to then use vold failed because it was too late I found some articles about how how this was achieved in earlier Android versions upto 5.
after 7.6 Android world has become even more paranoid on security and seLINUX couldn't have been more fussier from 7.x onwards Android versions I would like to know if there is a definitive guide about how this can be done .I do not mind recompiling this feature in the kernel. this is a far more rewarding investment then trying to look for custom ROMs and moving away from stock just because you want EXT4support
so how do I I add EXT4support on stock and similar ROMs for Android versions > 7.x and do this the right way where all apps can access my partitions. all my partitions are EXT4 this is quite in contrast to the the second partition app2sd approach that is used to save space. of course I have that as well but I have two more partitions used for extSD ( main external data storage partition ) and one devoted to to another app. totally 3 EXT4 partitions . first one is the main data partition ,2nd is app2sd and third is a special partition devoted to one app. if it matters I am rooted on a Samsung device running stock nougat 7.x.


another thing that I observed and I will update the question accordingly is all of a sudden out of nowhere partitions mounted under /storage are now read only earlier they were not so. I can still read write to them through /mnt/media_rw I wonder what went wrong because lot of apps depend on accessing my partitions through /storage Mount point.

So just to summarise here are the questions:

  • Mount multi ext4 partitioned external card at boot time, as against manual mounting which I can do.
  • Mount it the correct way with the right group ID, so that vold gets to know it has been mounted and all apps and process can freely access the partition.
  • All external partitions under /storage suddenly became read only (internal memory partition is of course read write always). tune2fs confirmed that all partitions are clean. Why does this happen and how can it be fixed?


thanks for response. I put this question that sounded like a narrative since I did not have screenshots or logs at hand if that is what you meant in your opening comment in answer. So here's what I am trying to achieve but run into all kinds of errors.

1) Mount mmck1p2 to /data/sdext2 and I keep getting error failed to mount ...mmcblk1p2 on .....invalid argument & another similar line
failed..... /dev/block/vold/public on .... invalid args. that is via app2sd and my magisk has global option turned on the same partition is already mounted at boot under media_rw and storage


Bind mounting camera DCIM and many other folders in internal storage fails when target is /storage/part# & it earlier worked well. My partitions are clean as per tune2fs report . What happened ?

Thanks again. Answering your Q's here :

1) What are currently mounted filesystems (output of mount)?
o/p is too big to fit in here. PFA

2) Output of /system/bin/id?
for normal user

uid=10112(u0_a112) gid=10112(u0_a112) groups=10112(u0_a112),1015(sdcard_rw),1023(media_rw),1028(sdcard_r),3003(inet),9997(everybody),50112(all_a112) context=u:r:untrusted_app:s0:c512,c768


3) What command exactly did you use to mount mmck1p2 to /data/sdext2? 4) What command exactly did you use to bind mount DCIM folder?

1   mount -o,rw /dev/block/mmcblk1p1 /storage/extsd
2   lp=/sdcard/logger.txt
4   ls./mnt/media_rw
5   ls /mnt/media_rw
6   mkdir -p $_/extsd
7   mount --bind /storage/extsd  $_
8   ls $_

with above run from terminal I am able to see files from terminal only. if run from adb I get the same situation
. Thought adb would be persistent but ain't the case. after that I tried to invoke vold with the hope it would make my mount persistent and visible but no luck there either

dreameltemtr:/ # /system/bin/vold
/system/bin/vold
Aborted
134|dreameltemtr:/ # /system/bin/vold --blkid_context=u:r:blkid:s0 --blkid_untrusted_context=u:r:blkid_untrusted:s0 --fsck_context=u:r:fsck:s0 --fsck_untrusted_context=u:
r:fsck_untrusted:s0
ntext=u:r:fsck:s0 --fsck_untrusted_context=u:r:fsck_untrusted:s0              <
SELinux selinux_android_compute_policy_index : Policy Index[2],  Con:u:r:magisk:s0 RAM:SEPF_SECMOBILE_7.1.1_0003, [-1 -1 -1 -1 0 1]

also to mount partition # 2 via app2sd there is a mount script that the app writes to /system/bin/etc or /data/app2sd dir's depending on the opts you choose. It uses the similar approach except that
-- I used its own binary for the bind mount functionality
-- I will do periodic tests to see if certain partitions get mounted
-- It will run these periodically ( kind of patched many scripts together ) hoping that one will work
-- I attempts to mount via block device ( /dev/block/mmcxxx) as well as vold ( /dev/block/vold/nnn)
Here is that script & you will see what I just said . Again PFA since there is a ceiling to max chars on a post.

4) What are exact error messages? –
exact messsages are 2 lines from app2sd gui attention box

- Failed to mount /dev/block/ mmcblk1p2 to /data/sdext2 invalid argument <br>
- Failed to mount /dev/block/vold/public/179:34 to /data/sdext2 invalid argument<br>

On the last part where I cant write to external partitions mounted under /storage That instance of ROM install was abortive . It caused repeated boot-loops after 10 mins so I just restored my Nandroid backup. So I cant dig out more details .

11
  • You can format external SD card as ext4 and mount it manually wherever you want. ext4 support is present on every ROM - stock or custom - since the first release of Android. What exactly your question is? Dec 4, 2019 at 4:07
  • Thank you for responding Irfan I can found it manually as I have written so Dec 4, 2019 at 7:52
  • Thank you for responding Irfan I can found it manually as I have written so . There are 3 questions sorry if it was not clear 1 ) it needs to mount at boot time and read write 2 ) the mounting information needs to be transferred so as to say to v o l d process so all other processes and apps can access that external data storage partition Dec 4, 2019 at 7:58
  • 3 ) another thing that I observed and I will update the question accordingly is all of a sudden out of nowhere partitions mounted under /storage are now read only earlier they were not so. I can still read write to them through /mnt/media_rw I wonder what went wrong because lot of apps depend on accessing my partitions through /storage Mount point. Dec 4, 2019 at 8:55
  • please clarify if you looking for non-rooted solution. i guess your problem isn't the file system it is more related to app permissions. have a look at android.stackexchange.com/search?q=WRITE_EXTERNAL_STORAGE
    – alecxs
    Dec 4, 2019 at 13:55

1 Answer 1

2

I don't think I understand your question fully. It's not clear what and how you have tried so far and faced what constraints or limitations in achieving what you want to. But precisely answering your questions:

Mount multi ext4 partitioned external card at boot time, as against manual mounting which I can do

Mounting external SD card is handled by vold. You can disable that in fstab and define an init service or put an init.d script to mount the partitions on boot the way you want.

Mount it the correct way with the right group ID, so that vold gets to know it has been mounted and all apps and process can freely access the partition

Since Android 6, in Portable Storage mode, vold mounts external SD card at /mnt/media_rw/[UUID] and then emulates that to /storage/[UUID]. Apps with WRITE_MEDIA_STORAGE permission (which is mapped to GID media_rw (1023)) have filesystem level write access to external SD card. But third party apps cannot write to SD card because the said permission has signature|privileged protection level. Emulation makes it possible for apps to read whole SD card but write only to their private directories. Also apps may use Android APIs (like SAF) to save files on SD card. See details in How to move files to external SD card?

This whole phenomenon is deeply integrated in Android framework - Java and native. So if you want to change this behavior, you need to modify Android source and rebuild ROM. Or don't rely on vold and mount partitions yourself with correct permissions as I mentioned earlier.

All external partitions under /storage suddenly became read only

There can be multiple possible reasons, you can check kernel log or Android log to see what exactly happens when you do mount -o rw,remount. Mounting read-only can be a sign of errors due to flash chip degradation. Or may be the partition(s) simply reached their maximum mount count, so you need to run fsck.

1
  • THanks for replying. I gave these details you asked for much as I could dig em out. What I want to get from all this is on a ROM that does not support ext4 for sdcard like CM or Lineage , how can I have this functionality so that every time I dont have to flash a new Lineage ROM & then deal with its other short comings. Hope i am clear by now. Now for this instance I dont see /etc/init.d folder there is a init folder & even if I remount rw. Reboot will del scripts . i can put them in xbin but not sure if they will be executed. Dec 7, 2019 at 1:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .