I found a guide for fixing permissions on an EXT4 filesystem on a MicroSD card. The AOSP/CyanogenMod ROMs I've tried will mount this, but the permissions are messed up. The guide used to work fine on KitKat, but I recently bought a Note 4, rooted it, and flashed SlimRemix, which is 5.1.x Lollipop, and the guide no longer fully works.
What I'm trying to do is change the permissions of /mnt/media_rw/sdcard1 to 777 (default is 755). It appears to be owned by "media_rw" group/user. Changing from 755 to 777 works, and I have no trouble reading/writing it. But the permissions get set back to 755 on reboot. I'm not sure of the cause.
As a temporary solution, I found that I can use init.d scripts (/system/etc/init.d) to run commands automatically at boot. My ROM will also run on boot any scripts located in /data/local/userinit.sh and/or userinit.d (same path).
However, I'm having trouble executing multiple commands. What I have now:
!/system/bin/sh
su && chmod 777 -R /mnt/media_rw/sdcard1
Permissions of the file are set correctly to 755. It appears to only run the su portion then stops, no permission changes occur. If executed without su I get "Permission denied", as expected. I can use Script Manager app, omit the "su &&" bit, then (in SM) mark the script as "Execute", "su", and "on boot" and it works. But since I have native support for automatic script execution on boot, I would rather not use an app to accomplish this.
I recognize a better solution would be to find a way to permanently change permissions, and if someone knows how this can be done then I'd appreciate the info, but a script will suffice for my purposes. Can someone point out what I'm doing wrong? Thanks!