Search This thread

theredbaron1834

Senior Member
Aug 1, 2015
265
71
Sony Xperia XA2
Google Pixel 5
Well, I'm not really intended to be a coder or something. Same as @VR25 I usually busy with real life things. I have to dive into fbind time to time because I really need this tool, at least until I buy new phone. I heard VR25 work on some complete new framework which is will be used in fbind as well along with his other projects, so my "fixes" most likely will not be merged in future fbind releases. But if this will not happen in near future, I'll try to contact VR25 and/or cooperate/fork this tool to make it available officially in magisk repo. Thanks for idea.


I thank you very much for tthe work you have done however. It is very much appreciated, and a much better solution then my hackame script and an app to launch it after boot.
 

fcoaaron89

Member
Jun 25, 2016
22
3
Hi! I'm using fix4 in Android 9 (EMUI 9.1 in Huawei Mate 10) with Magisk 20.4 and I'm having a little problem, it mounts well the WhatsApp folder from external SD to internal, but WhatsApp cant write anything to the folder (downloads of media fails). When I check permissions of mounted folder in a terminal emulator, I see rwxr-xr-x and root:everybody permissions, when other folders have root:sdcard_rw. But comparing with other phone running Android 8, the main problem I see is that the folder should mount with rwxrwx--x permissions, so the group "everybody" can write to the folder, I suppose that the current user is included in that group.

Can this be fixed in config so it mounts with correct permissions at boot time?
 

Hooin Kyoma

Member
Jun 23, 2012
35
81
When I check permissions of mounted folder in a terminal emulator, I see rwxr-xr-x and root:everybody permissions, when other folders have root:sdcard_rw. But comparing with other phone running Android 8, the main problem I see is that the folder should mount with rwxrwx--x permissions, so the group "everybody" can write to the folder, I suppose that the current user is included in that group.
Hi. fbind actaully calling `mount -o rbind ...` when binding external folders to internals. So permissions of binded folder are same as permissions of external folder. Is your external storage is default Android's fat/exfat auto-mounted SD card? Or a mounted partition/image of yours? What intial permissions of external WhatsApp folder before binding?
I have Huawei Nova 2, will try your scenario with EMUI (9 or 8, not sure) tonight or tomorrow when I get spare time.
 

fcoaaron89

Member
Jun 25, 2016
22
3
Hi. fbind actaully calling `mount -o rbind ...` when binding external folders to internals. So permissions of binded folder are same as permissions of external folder. Is your external storage is default Android's fat/exfat auto-mounted SD card? Or a mounted partition/image of yours? What intial permissions of external WhatsApp folder before binding?
I have Huawei Nova 2, will try your scenario with EMUI (9 or 8, not sure) tonight or tomorrow when I get spare time.

Hi. I didn't think about looking at the permissions of the source folder, I'll check it.

However, in Android 8 I have seen that the permissions of the source folder are rwxr-xr-x and the destination rwxrwxr-x, but there I am using the original fbind of this post, without the fixes. Also, the Android 8 device is a LG G6, not EMUI, but fbind was working properly in EMUI 8 on the Huawei Mate 10.
 

Attachments

  • Capture+_2020-06-10-14-27-44.jpg
    Capture+_2020-06-10-14-27-44.jpg
    231.5 KB · Views: 201

fcoaaron89

Member
Jun 25, 2016
22
3
Hi. I didn't think about looking at the permissions of the source folder, I'll check it.

However, in Android 8 I have seen that the permissions of the source folder are rwxr-xr-x and the destination rwxrwxr-x, but there I am using the original fbind of this post, without the fixes. Also, the Android 8 device is a LG G6, not EMUI, but fbind was working properly in EMUI 8 on the Huawei Mate 10.

I checked the source folder permissions and are correct: rwxrwxr-x, but for some reason after mounting, the destination have rwxr-xr-x. The source folder is in a FAT partition of microSD card, if I remember well.

I attach screenshots of the source folder permissions before mounting, of what happens when mounting with "fbind -m" and the destination folder permissions after mounting.
 

Attachments

  • photo_2020-06-10_18-04-44.jpg
    photo_2020-06-10_18-04-44.jpg
    146 KB · Views: 207
  • photo_2020-06-10_18-04-49.jpg
    photo_2020-06-10_18-04-49.jpg
    77.6 KB · Views: 204
  • photo_2020-06-10_18-04-54.jpg
    photo_2020-06-10_18-04-54.jpg
    160.8 KB · Views: 201
  • photo_2020-06-10_16-38-39.jpg
    photo_2020-06-10_16-38-39.jpg
    147.3 KB · Views: 201
Last edited:

xdaprogramm

Member
Mar 20, 2019
32
1
Hi guys, I made new "fix3" version if anyone interested:
Also, here is another interesting tool for binding folders: https://bindfs.org (but see "known issues" at bottom). May be I'll try switch to it if encounter problems with permissions in next android updates. If I don't buy new phone with 128+ gigs of internal memory soon :)

Bindfs works for me when done from ADB - then when I use the file explorer I see the Download folder that I want to bind with external, is instead the external.
But if ADB debugging is disabled, phone turns off, cable is disconnected or just time passes and the bind is lost.

I wanted to make it work away from PC within the phone. I tried Terminal Emulator - works but only in the terminal. I can see the original Download folder, it is not bound to the external SD even though in the terminal if I ls Download it will list the external SD desired folder, Thus apps like Exagear will also not see the bind, unlike when done bindfs from ADB, which as I said can get lost and if you are away from PC won;t have the bind for long.

Trying to use your fbind fix4 , looking for ways to keep folders bound even if phone is locked, no adb debugging etc.
 
Last edited:

aceediq

Member
Dec 5, 2018
8
1
Its not exactly portable, but a walkthrough of sorts might help others.

Starting from Android with magisk. You need the magisk module "exSDCard access enabler", which gives you a rw mount to use as a bind. Next you need an script boot launcher, as lineage has removed init.d support. After a lot of trouble I found I like "init.d light", which is in the fdroid repos [here](https://f-droid.org/en/packages/x1125io.initdlight/). The next part sucks, but for a autolaunched script to boot, you need to go into magisk settings and change" mount namespace mode" to global. This isn't ideal, security issues and all that. However, this is really all I use root for atm, and the only for it to work I can find without using adb every boot, so I am ok with it.

Now everything is ready for a script. Each phone will be different based on your sd card and wants. However, it will be something like "mount --rbind /mnt/media_rw/XXXXXXXX/Games/ /mnt/runtime/default/emulated/0/Games", with XXXXXXXX is unique to your sd card.

You just get all the mounts you want in a empty file, it "might" need to have the ext of .sh. then copy it to wherever init.d light says (it depends on the phone).

The big issue I have found is it takes about 20 sec after boot to have them mounted. However, it seems to work fine, even have Android bindmounted with no issue so far.


Can you please give the exact commands for the mount commands you used...I am trying to make scripts too
 

theredbaron1834

Senior Member
Aug 1, 2015
265
71
Sony Xperia XA2
Google Pixel 5
Can you please give the exact commands for the mount commands you used...I am trying to make scripts too

The latest fbind works great for me, so I switched to it. However, my old script:

Code:
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Android/ /mnt/runtime/default/emulated/0/Android/"
su -c "mount --rbind /mnt/media_rw/4A09-17FB/DCIM/ /mnt/runtime/default/emulated/0/DCIM/" 
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Download/ /mnt/runtime/default/emulated/0/Download/"
su -c "mount --rbind /mnt/media_rw/4A09-17FB/DraStic/ /mnt/runtime/default/emulated/0/DraStic/" 
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Games/ /mnt/runtime/default/emulated/0/Games/"
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Pictures/ /mnt/runtime/default/emulated/0/Pictures/ "
su -c "mount --rbind /mnt/media_rw/4A09-17FB/PSP/ /mnt/runtime/default/emulated/0/PSP/ "
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Videos/Youtube/ /mnt/runtime/default/emulated/0/YTD/ "

Also if anyone else wants help via scripts, please pm me, as fbind is still usable now, and I don't want to hide the info behind support for scripts. Glad to help, just please pm.
 

aceediq

Member
Dec 5, 2018
8
1
The latest fbind works great for me, so I switched to it. However, my old script:

Code:
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Android/ /mnt/runtime/default/emulated/0/Android/"
su -c "mount --rbind /mnt/media_rw/4A09-17FB/DCIM/ /mnt/runtime/default/emulated/0/DCIM/" 
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Download/ /mnt/runtime/default/emulated/0/Download/"
su -c "mount --rbind /mnt/media_rw/4A09-17FB/DraStic/ /mnt/runtime/default/emulated/0/DraStic/" 
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Games/ /mnt/runtime/default/emulated/0/Games/"
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Pictures/ /mnt/runtime/default/emulated/0/Pictures/ "
su -c "mount --rbind /mnt/media_rw/4A09-17FB/PSP/ /mnt/runtime/default/emulated/0/PSP/ "
su -c "mount --rbind /mnt/media_rw/4A09-17FB/Videos/Youtube/ /mnt/runtime/default/emulated/0/YTD/ "

Also if anyone else wants help via scripts, please pm me, as fbind is still usable now, and I don't want to hide the info behind support for scripts. Glad to help, just please pm.

The latest fbind??? Is it fix4? Can i see the script/config used?

Thanks so much for the script...i just need to put in a file, edit to my needs and add the script extension, right?

Another thing, have you succesfully, either with fbind or your scripts, mounted whatsapp to extSD?
 

theredbaron1834

Senior Member
Aug 1, 2015
265
71
Sony Xperia XA2
Google Pixel 5
1. Yes, fix4 works perfect for me on the latest lineageos 17.1 on an XA2, and Magisk fully ipdated.

Code:
target Android
target Download
target Games
target PSP
target DraStic
target Pictures
target Wagic
target DCIM
target ADM
from_to YTD Videos/Youtube

2. That, and run it. I used Init.d lite, from the fDroid app store, to run it on boot.

3. I don't use whatsapp, but I don't see why it wouldn't work, at least with fbind, as it should change before the app can run, whereas a sceipt might not.
 
  • Like
Reactions: aceediq

aceediq

Member
Dec 5, 2018
8
1
1. Yes, fix4 works perfect for me on the latest lineageos 17.1 on an XA2, and Magisk fully ipdated.

Code:
target Android
target Download
target Games
target PSP
target DraStic
target Pictures
target Wagic
target DCIM
target ADM
from_to YTD Videos/Youtube

2. That, and run it. I used Init.d lite,
from the fDroid app store, to run it on boot.

3. I don't use whatsapp, but I don't see why it wouldn't work,
at least with fbind, as it should change before the app can run,
whereas a sceipt might not.


Thanks....uhmmm...i have an issue, when i move the script to init.d
partition it automatically disappears after reboot, any solution?
App used: universal init.d enabler

When i tried init.d lite, nothing mounts

MagiskSU 19.3, Redmi Go

---------- Post added at 10:47 PM ---------- Previous post was at 09:57 PM ----------

1. Yes, fix4 works perfect for me on the latest lineageos 17.1 on an XA2, and Magisk fully ipdated.

Code:
target Android
target Download
target Games
target PSP
target DraStic
target Pictures
target Wagic
target DCIM
target ADM
from_to YTD Videos/Youtube

2. That, and run it. I used Init.d lite, from the fDroid app store, to run it on boot.

3. I don't use whatsapp, but I don't see why it wouldn't work, at least with fbind, as it should change before the app can run, whereas a sceipt might not.


Tried fbind....flawless but i have a problem...a folder wouldn't bind because
the folder name is spaced e.g "flm user files"

How do i resolve this?
 
Last edited:

theredbaron1834

Senior Member
Aug 1, 2015
265
71
Sony Xperia XA2
Google Pixel 5
1. Yes, fix4 works perfect for me on the latest lineageos 17.1 on an XA2, and Magisk fully ipdated.




Thanks....uhmmm...i have an issue, when i move the script to init.d
partition it automatically disappears after reboot, any solution?
App used: universal init.d enabler

When i tried init.d lite, nothing mounts

MagiskSU 19.3, Redmi Go

---------- Post added at 10:47 PM ---------- Previous post was at 09:57 PM ----------

1. Yes, fix4 works perfect for me on the latest lineageos 17.1 on an XA2, and Magisk fully ipdated.




Tried fbind....flawless but i have a problem...a folder wouldn't bind because
the folder name is spaced e.g "flm user files"

How do i resolve this?


For fbind, try adding quotes. Ie,:

Code:
 target "flm user files"

Or

Code:
 target 'flm user files'

Linux uses quotes this way at least, so hopefully that is all that is needed.

For a script, you need to change the mount namespace in magisk to global mamespace too. I can't use universal initd enabler on my system, no init partition, thus my lite use, so no help there. Lite should work with global namespaces, as long as you move the sh to the right folder, and have it usable.
 
  • Like
Reactions: aceediq

Top Liked Posts

  • There are no posts matching your filters.
  • 41
    ### No, I'm Not Dead! ###

    I know, I know... it's been quite a while. Well, yeah, maybe longer than that...

    Not gonna write a book on this. Lets just say it's HARD to access the internet on a regular basis from my current location. Plus, I've been busy with general life matters.
    That said, my online presence will still remain limited for a while. It won't be that much limited anymore, though. So... yay!



    ### Latest Changes ###

    F2FS Loopback Bug Workaround
    Magic GApps
    Magisk Manager for Recovery Mode
    Moto Z Play Dual SIM Mode Enabler
    Sysconfig Patcher
    Systemless Camera NX Mod
    - Fixed modPath detection & bad PATH variable issues (Magisk V16.6).
    - Updated documentation

    Magic Charging Switch (mcs)
    - Enhanced debugging function.
    - Fixed "automation config still calling `cs` instead of `mcs`."
    - Fixed modPath detection & bad PATH variable issues (Magisk V16.6).
    - Updated charging switches database (more devices supported)
    - Reliability improvements
    - Updated documentation

    Magic Folder Binder (fbind)
    - Ability to unmount loop devices and partitions on demand (i.e., fbind -u 'pattern1|pattern2|pattern...').
    - Better loop device mounting logic ("ugly bugs" fixed)
    - Bind-mount folders automatically regardless of --L (LUKS) flag's usage.
    - Dedicated logs dir -- /data/media/fbind/logs (easier & advanced debugging)
    - Deprecated `fbind -l` in favor of `fbind -i` (outputs much more information)
    - Fixed "misleading [N/A] mount status".
    - Fixed modPath detection & bad PATH variable issues (Magisk V16.6).
    - Fixed "rm -rf not affecting hidden files/folders" in data moving functions.
    - Ignore `app_data` line whose target apk is missing (to avoid app data loss).
    - Option to mount app_data in ext4 .img file (loop device)
    - Shipping with a comprehensive, noob-friendly tutorial (tutorial.txt, /data/media/fbind/info/tutorial.txt)
    - Reliability improvements (better data loss protection algorithms)
    - Updated documentation
    - Using `rsync -a` for advanced copy operations, instead of `cp -a`.



    ### Last, but Far from Least ###

    Will update each project's thread and repository & answer queries at my earliest (uh... maybe a little late) convenience.
    Meanwhile, everything you need is in the attached zip. Yes, all modules are there, along with a md5sum.

    P.S., To everyone who donated and/or contributed in other ways,
    -- Thank you very much!
    19
    Is this project discontinued? Last update almost a year ago.

    Ok, I downloaded latest version (2019.1.23) and installed it on my Lineage OS 17.1 (Android 10) with Magisk v20.2, and... spent two days for manage it to work... Meh, it'd be better to not even start.

    Fist of, it simply hasn't been installed properly on my system (no binaries, no scripts, only info/config examples), so I downloaded latest update-binary, saved it as is (without modifications), and manually converted config.sh to install.sh (using aka "legacy script" logic) (fix1-fix2) customize.sh (fix3).

    Secondly, fstype binary doesn't detect FAT (vfat/exfat/sdfat) on my system, so I added extra check to part() function in core.sh: in case if fstype has not detected FS, let mount detect it automatically (omit -t).

    Next, grep /storage/emulated /proc/mounts | grep -Eiq ' sdcardfs | fuse ' || exit 1 line in wait_until_true() function instanly exit script on boot, I guess it's because it starts too early on my system. So I replaced "exit" with waiting loop.

    After all this modifications and countless hours of tries and errors I finally got what I wanted - move (bind) some internal folders to encrypted second partiton of my external SD card.

    /data/adb/fbind/config.txt:
    Code:
    part -o umask=0 /dev/block/mmcblk1p2--L,MyLoNgPaSsWoRd /mnt/sdcrypt
    extsd_path /mnt/sdcrypt
    target DCIM
    target Audio
    target TitaniumBackup

    I found using umask=0 on FAT is a most painless way to deal with apps permissions to use binded folders. Less secure though. I logically understand that fbind should take care of access to binded folders, but it looks like something changed lately in Android's storage "magic", which is not clear to me, so... umask=0. Tried other mountpoints like /mnt/media_rw/sdcrypt or /storage/sdcrypt, tried ext4 instead of exfat, but all that caused even more problems with permissions. I'd appreciate any advice about better mountpoint and options to use.
    Got an infinite bootloop when I used to use FUSE (which is happen automatically when I add something like "intsd_path /storage/emulated/0" in config.txt), thanks god we have TWRP.

    I attached modified zip-file in case if anyone interested (not sure If I had right to do this tho, I will remove it if OP or moderators ask), magisk-only.
    DISCLAIMER: I'm very new to module coding and coding in general, I'm just an experienced Linux user, so I can't guarantee that my modifications are 100% correct and universal, test it on your own risk.

    UPD: new "fix2" version with some fixes.
    UPD2: new "fix3" version: magisk 20.4 support and others changes.
    UPD3: new "fix4" version: small bugfixes and simplified code (info).
    17
    13
    Hi guys, I made new "fix3" version if anyone interested:
    - magisk 20.4 support (magisk 20.0+ is requied starting from this version)
    And some fixes for those who using partitions and/or images:
    - loop and part now support both EXT2/3/4 and FAT/exFAT file systems, and loop accepts mount options (loop -o ...) like part does
    - better detection file system of partitions and loop images (using blkid if fstype fails)
    - fixed problems with permissions when mounting (ex)FAT and EXTfs partitions/images (using better mount options, sdcardfs and more of android storage "views" black magic)
    You can part/loop directly to target folder (part /dev/block/mmcblk1p2 $intsd/Viber) or mount it aside (part /dev/block/mmcblk1p2 /mnt/flash), declare as $extsd (exstsd_path=/mnt/flash) and then bind/target folders (target Viber, from_to Viber .Viber, etc)

    Tested with Carbon 8.0 (Android 10, AOSP-based) on my ancient Xperia Z3 Compact
    zip-file attached to my original post

    JUST FOR INFO (UPDATED after "fix4" released in my next post below):
    Hardcoded mount options for initial mounting of partitions and loop images:
    for all FS: nosuid,nodev,noexec,context=u:eek:bject_r:sdcardfs:s0
    + for (ex)FAT: uid=0,gid=1023gid=9997,umask=0007
    + for EXT2/3/4: changing owner:group of root directory to 0:1023 0:9997 and perms to rwxrwxr-x - you should know this if you use mounted EXTfs-devices somewere else. This will allow you to create and delete newly created or empty folders in the root of mounted EXFfs storage, but for existed folders you need to do chown -R 0:9997 <mountpoint> and chmod -R 775 <mountpoint> by hand at least once.
    These changes should help with access to mounted storages in recent androids.
    And additional options when binding devices and folders: gid=9997,mask=6
    Also, here is another interesting tool for binding folders: https://bindfs.org (but see "known issues" at bottom). May be I'll try switch to it if encounter problems with permissions in next android updates. If I don't buy new phone with 128+ gigs of internal memory soon :)