yashsingh1/xdaforums huggingface dataset:
[Magisk] VR25:
Yes, only data from source folders listed in config.txt are moved. However, this happens for a given folder only if it is not mounted -- meaning, you don't have to worry about messing things up.

The config construct int_extf (meaning "internal to external folder") "sets" the internal (emulated) SDcard to the folder .fbind in your external SDcard.> /sdcard/Android/> and /sdcard/data/ are included.

Note that neither /data/app nor /data/data are included. These are not part of the emulated/internal SDcard.

Forget about /data/app if you don't have a secondary partition (preferably EXT4 with journaling disabled).

You can save /data/data/packageName to <externalStorage>/loopDevice.img

You'd have to create the .img file with enough size to accommodate your app's data. Example: /sbin/imgtool create /mnt/media*/*/appdata.img 128

128 (size) is interpreted in Megabytes.

After that, add the following line to you config:

loop $extsd/appdata.img /data/data/packageName

Note that the setup above is for a single app. Of course you could use /data/data as mount point, meaning all apps' data get stored on the loop device. However, that's dangerous, especially for system apps! Some or all may misbehave and you might even lose data.

In sum,

Config lines

int_extf --> bind-mounts $extsd/.fbind to $intsd

loop $extsd/appdata.img /data/data/packageName --> mounts EXT4 .img file (loop device) to <mount point>, overlaying contents.

Command

/sbin/imgtool create /mnt/media*/*/appdata.img 128 --> creates a 128MB EXT4 image in the root of your $extsd to accommodate app data.

It is possible. However, due to SELinux restrictions, non-root apps will most likely not have access to it.

The steps are:

0) su

1) mount -o remount,rw /

2) mkdir /sdcard1

3) mount -o remount,ro /

4) echo "bind_mount /mnt/media*/* /sdcard1" >>/data/media/fbind/config.txt

5) fbind --mount

You might need to run setenforce 0 just to make /sdcard1 visible.

That's not true if you're talking about fbind. You don't have to specify your SDcard, unless you have something else in mind. fbind automatically detects it. If you have multiple partitions, it picks the largest.
[Magisk] VR25:
**2018.12.4 (201812040)**

- Detach (autorun|service).sh from the parent shell

- Extended modularization for easier maintenance

- Improved legacy systems support

- SDcard mount wait timeout set to 30 minutes to accommodate ROM initial setup and other long operations

**2018.12.3 (201812030)**

- Ability to easily bind-mount and unmount folders not listed in config.txt

- Automatic FUSE/SDcarsFS handling -- users don't have to care about these anymore; fbind will work with whichever is enabled. ESDFS (Motorola's Emulated SDcard Filesystem) will remain unsupported until a user shares their /proc/mounts.

- Fixed loop devices mounting issues; unmounting these with fbind -u is now supported.

- Improved filtering feature (fbind <option(s)> <pattern|pattern2|...>)

- LUKS unmounting and closing (fbind -u <pattern|pattern2|...>)

- Major cosmetic changes

- New log format

- Redesigned fbind utilities -- run <fbind> on terminal or read README.md for details.

- Removed bloatware

- SDcard wait timeout set to 5 minutes

- Support for /system install (legacy/Magisk-unsupported devices) and Magisk bleeding edge builds

- Updated building and debugging tools

- Updated documentation -- simplified, more user-friendly, more useful
[Magisk] The_Walking_Playground:
Hi [MENTION=5228676]VR25[/MENTION],

Great update. My bind mounts are now working perfectly (for my primary user). Is there any progress on getting the mounts working properly for secondary user accounts?

TWP
[Magisk] rainman74:
Perfect, I'll try it out tonight.

The reason you suspect non-root apps won't have access to it is the folder in the root directory, right?

It would also be enough for me if the directory is created here:

storage/emulated/0/sdcard1

So then that should do it?

1) mkdir /storage/emulated/0/sdcard1

2) echo "bind_mount /mnt/media*/* /storage/emulated/0/sdcard1" >>/data/media/fbind/config.txt

3) fbind --mount
[Magisk] a1zen2:
does not work on android 9 ((((
[Magisk] VR25:
Thanks for the feedback.

Bind-mounts are working for secondary users too.

Have you tried bind_mount $extsd/Download ${intsd/%0/11}/Download?

11 is a secondary user number, as seen in /data/media/.

Yes, but after running su -c setenforce 0, these apps may gain access to that folder.

Yes, but in this case, step 1 is unnecessary. The path is created automatically. Also, "sdcard1" must be .sdcard1 instead (a hidden folder). Otherwise, media apps will mistakenly show duplicates.

[MENTION=5332893]Rom[/MENTION], if your module did that, it would work on Pie.

It does work on Pie.

Please zip and upload /data/media/fbind/.

I want to see how you set things up.
[Magisk] a1zen2:
I can not send the log yet, I returned to Oreo. I can install Android 9, if necessary
[Magisk] VR25:
I thought so. That's ok.

After installing Pie and setting everything up, share the output of grep Download /proc/mounts.

Thanks
[Magisk] a1zen2:
Ok,tnx
[Magisk] rainman74:
I don't understand that now, so how exactly?

1) echo "bind_mount /mnt/media*/* /storage/emulated/0/sdcard1" >>/data/media/fbind/config.txt
2) fbind --mount

or

1) echo "bind_mount /mnt/media*/* .sdcard1" >>/data/media/fbind/config.txt
2) fbind --mount

and then how do I address the path? $ ls .sdcard1 -> that makes little sense, or?

Excuse my stupid questions :silly:
[Magisk] The_Walking_Playground:
Hi [MENTION=5228676]VR25[/MENTION],

I tried the command you suggested. While the folder is getting mounted (as it was before), the secondary user account can't access the folders (unless first accessed directly with root). Is this working on your side without root?

TWP
[Magisk] VR25:
bind_mount $extsd $intsd/.sdcard1 --> that's the line you should add to config.txt

fbind --mount or fbind -m create necessary paths and bind-mount folders.

intsd and extsd are fbind's internal variables whose values correspond to internal and external storage paths, respectively. Generally, you should always use these instead of the actual paths, for compatibility.

It's working without root, but I only tested LOS built-in file manager (Files).

Will see how other apps behave...
[Magisk] Rom:
I confirm that my module works on Pie, as several users have already feedback on XDA and Tg :good:

Hey RR devs, please spead-up to merge you current dev on Pie and let this Oreo sh*t to die, unsustainable expectation, even yoga can't do anything about it anymore :angel::silly:
[Magisk] The_Walking_Playground:
Hi,

I tested using the same app, on Lineage 16.0. The folder contents cannot be read, and screenshots cannot be saved when I have the Pictures folder bind mounted for the secondary user. Are you running on Pie as well? What can I provide to help figure this out? There must be something inherently different in our setups.

TWP
[Magisk] VR25:
Right, but is it working with SDcardFS too (without forcing FUSE mode)?

A few reports suggest that some Pie systems don't support FUSE.

I'm on Nougat 7.1.2.

Does permissive SELinux help?

___

[MENTION=8756890]The_Walking_Playground[/MENTION], you can provide /proc/mounts after everything is mounted.

Thanks
[Magisk] The_Walking_Playground:
Hi,

The ROM I'm currently running has SELinux set to permissive by default. On Pie I know the SELinux rules are more strict, even when permissive. I'm not sure if that's a factor here or not. /proc/mounts is attached. Thanks!

TWP
[Magisk] Rom:
My one don't works with SDCardFS, FUSE is forced with.

It's not impossible, because FUSE can be partialy removed from the sources before the compilation now with Pie.

For now, the majority of the feedback i get mean that it works.
[Magisk] The_Walking_Playground:
Hi [MENTION=5228676]VR25[/MENTION],

I'm wondering if the issue is the uid/gid for the bind mounted folders? They seem to correlate to the primary user and not the secondary user, which would explain why I can't access them from the secondary accounts. I included the primary user output of 'id' in the original attachment. Below is the output from one of my secondary user accounts:

~$ id
uid=1010156(u10_a156) gid=1010156(u10_a156) groups=1010156(u10_a156),3003(inet),20156(u0_a156_cache),50156(all_a156),1009997(u10_everybody) context=u:r:untrusted_app_25:s0:c522,c768
~$

I'm not sure how the folders appear on Nougat as far as uid/gid, nor am I sure how you would fix it of that is indeed the issue. Is there an easy way for me to check and see if that fixes it?

TWP
[Magisk] VR25:
We're on the same page.

Try remounting user 10's Download folder as follows:

su

mount -o remount,gid=1009997 /mnt/runtime/read/emulated/10/Download

mount -o remount,gid=1009997 /mnt/runtime/write/emulated/10/Download

___

In my system, the mount group ID is 9997 for both users (0 & 11). Didn't check 11's id output.
[Magisk] The_Walking_Playground:
Hi,

I tried the above commands, and confirmed that in /proc/mounts the gid of the user 10 Download folder is now 1009997. However the stock File Manager still can't read the content of the folder. There must be more involved. I'm just not sure what :confused:.

TWP
[Magisk] rainman74:
That does work :) But I don't get write access, not even with setenforce 0.

This error message appears:

ls ./.android_secure: Permission denied

sdcard1.sh

#!/bin/sh
echo mount sdcard1
echo 'bind_mount $extsd $intsd/sdcard1' >/data/media/fbind/config.txt
fbind --mount
[Magisk] munted:
Hi VR25, firstly thanks so much for creating this.

I notice a lot of people asking questions so I thought I'd help make a guide like the one I recently made here: https://xdaforums.com/showpost.php?p=78255334&postcount=382

From start to finish, using simple instructions is this what you should do? (I have a rooted Sony XZ1 Compact with Magisk if that makes a difference)

First make a Google Cloud backup of your Whatsapp

Go to https://xdaforums.com/apps/magisk/module-magic-folder-binder-t3621814 and download the latest zip, at the time of writing this is fbind-2018.12.4.zip

Open Magisk and go to modules, click the + button and navigate to the zip file and install

Reboot phone

Force close the Whatsapp app

Open a File Explorer app with Root access

Copy the Whatsapp folder from the Internal SD card to the External SD card

Then go to /data/media/fbind/info

Create a file called config.txt

Put this line in it:

from_to WhatsApp .WhatsApp

Next download a terminal app from the Google Play store e.g. Termux and give it root access

Then in the terminal app run the following commands

su -c fbind -mb

from_to WhatsApp .WhatsApp

bind_mnt $extsd/WhatsApp $intsd/.fbind/Whatsapp

If you want to autorun at startup there's a few options, you can:

*use Termux:Boot (paid)

*use init.d

*or if your phone doesn't support init.d, instead use an app to run /system/etc/fbind/autorun.sh

(Need to write a more detailed explanation of using these 3 methods but let's get the main instructions correct first)
[Magisk] a1zen2:
https://mega.nz/#!AkVS2SqD!JXowHup6Q7NLgnOL_Ec6I_K0ERzwm89U6h1oVbK090E
[Magisk] MrMmmkay:
Hi.

Sorry to say, but the .4 version does not work at all for me now, see screenshot and logs attached.

Could you make an option to set the time when fbind mounts the bindings? On my XZ1C it takes more than a minute before I can run the fbind -b command in terminal emulator, maybe that is the problem with automount?
[Magisk] LinoX:
Can't install 2018.12.4 on Magisk 15.3

Can't install 2018.12.4 on Magisk 15.3 with Magisk Manager 6.0.1

Log file:

- Copying zip to temp directory
- Installing fbind-2018.12.4.zip
update-binary[53]: setup_flashable: not found
- Mounting /system, /vendor
Archive: /data/user/0/com.topjohnwu.magisk/cache/install.zip
inflating: common/addon.d.sh
inflating: common/cleanup.sh
inflating: common/core.sh
inflating: common/fbind
inflating: common/sample_config.txt
inflating: common/service.sh
inflating: config.sh
inflating: module.prop

fbind 2018.12.4
VR25 @ xda-developers

******************************
Powered by Magisk (@topjohnwu)
******************************
- Creating /magisk_merge.img with size 64M
open: Read-only file system
- Mounting /magisk_merge.img to /dev/tmp/magisk_img
Cannot mount image!
! /magisk_merge.img mount failed...
! Installation failed
[Magisk] czecx:
I have one question about this module.

I have installed it on my Huawei P9.

I moved my app data from intsd to extsd and after that I have created a command on config.txt

from_to xdiagpro .fbind/xdiagpro

Than reboot my phone and check on file manager if the paste was mounted on intsd, ok. But when I try to launch the app xdiagpro it won't start and crash.

What I do wrong?

Sorry for my English.
[Magisk] czecx:
Log file is attached
[Magisk] 白い熊:
[MENTION=5228676]VR25[/MENTION] on the latest version — there seem to be some issues with extsd_path

I have the whole SD as an ext4 LUKS volume mounted via the “part” command to /media/sdb1 — so far so good, it mounts it there.

I have “extsd_path /media/sdb1” set.

Now when I run “fbind -m” for every from_to pair I get an error of the form:

</mnt/runtime/default/sdb1/xxx> </mnt/runtime/default/emulated/0/xxx>

mount: mounting /mnt/runtime/read/sdb1/xxx on /mnt/runtime/read/emulated/0/xxx failed: No such file or directory

mount: mounting /mnt/runtime/write/sdb1/xxx on /mnt/runtime/write/emulated/0/xxx failed: No such file or directory

/mnt/runtime/default/sdb1 exists.

/mnt/runtime/read/sdb1 and /mnt/runtime/write/sdb1 both don't exist — that's why it can't mount.

Shouldn't it be using /media/sdb1 instead of both /mnt/runtime/read/sdb1 and /mnt/runtime/write/sdb1 ?
[Magisk] srams008:
Hi guys. I am not android techy, but somehow managed to root my nokia1 and flash also. But folder mount is not compatible with oreo 8.1.

I am really confused about using fbind module.

If possible can someone make video and publish in youtube about its full usage.

I want to bind whatsapp from internal sd to external sd

Internal path :storage/emulated/0

Extsd path :/storage/externalsdcard1/
[Magisk] Dark_Phoenix004:
Hi, it's good that you've done so many things.

I've also done the same but less complex.

Create a folder in SD card with any name.(Let's say WA)

Make a .nomedia file in that "WA" folder (to avoid media duplication)

Move WhatsApp folder from internal storage to WA folder.

Edit fbind config.txt and add from_to WhatsApp WA/WhatsApp

Reboot your phone. Done. It'll automatically mount on boot. So no need to use any external apps or scripts for automount.
[Magisk] bnwg:
Yes. I have same issue.
[Magisk] VR25:
**2018.12.7 (201812070)**

- extsd_path is fully compatible with SDcardFS.

- Notes: due to poor internet connectivity, my online availability is currently limited (except on Facebook). I updated README.md and sample_config.txt for those who're having a hard time understanding how to set things up.

**2018.12.6.1 (201812061)**

- Fixed fbind --log

- [Recovery] flash the same version again to disable the module

**2018.12.6 (201812060)**

- fbind -f/--fuse toggle force FUSE yes/no (default: no). This is automatically enabled during installation if /data/forcefuse exists or the zip name contains the word "fuse" (case insensitive). When enabled, it is a temporary workaround for multi-user bind-mounts. The setting persists across upgrades.

- Updated documentation

___

P.S., posting here is a pain atm.
[Magisk] 白い熊:
[MENTION=5228676]VR25[/MENTION] flashed the latest now. Now for every bindmount in my prior example I get two error lines of “Segmentation fault” however the binds are mounted.

Didn't inspect the script — what's the two steps that it performs after bindmounting? It's segfaulting for me now annoyingly…
[Magisk] otyg:
[MENTION=5228676]VR25[/MENTION]

I have Magisk 18 with Android 9.0 PIE rom (Havoc-OS) , when I go to install the Fbind module it just hangs at 'extracting module files' (waited 3 minutes), but if I close Magisk and re-open the module shows installed , when I reboot the phone it hard locks after about 30-60 seconds and self reboots, however if I quickly go into magisk and disable the module the phone works fine after it reboots.

I'm not sure how to log this or get it working, but I would really like to get this working on PIE, any suggestions would be great.

btw I also tried installing from TWRP which appears to install, but still face the same reboot issue.

Edit:

attached logs.

Edit2:

deleted my config.txt and device works with module, going to experiment with config.txt and see whats going on, yeah as soon as I add 'obb' in the config.txt it causes the reboot
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION], [MENTION=5207466]otyg[/MENTION], SDcardFS quirks...

For every bind mount, there are two additional bind-mounts.

/mnt/runtime/default is the root path (part of the first mount)

/mnt/runtime/read and /mnt/runtime/write are the extras needed for read-write access.

It seems you two would be better off using FUSE for now.

Proceed as follows:

1) Run fbind --fuse

2) Reboot

If you face a bootloop, your system doesn't support FUSE. Undo the changes:

1) Flash the same fbind version from recovery. This will disable it.

2) Once booted, rename /sbin/.core/img/fbind/system.prop back to "FUSE.prop" and reboot.

I'll investigate these issues.

Thanks :)
[Magisk] 白い熊:
OK — unlike the prior version, immediately after asking for the passphrase, and I assume after mounting the LUKS volume, I get the following error:

/system/xbin/fbind: /dev/fbind/tmp.3[1]: ext4: not found

And then the mounts with segfaults proceed.

Also unlike the prior version — the mountpoint is created in neither of: /mnt/runtime/default /mnt/runtime/read and /mnt/runtime/write

The “ext4: not found” error BTW also happens under FUSE.
[Magisk] otyg:
ok I tried this method and all seemed good running fbind --fuse, rebooted ok, but once I edited config.txt and added 'obb' I got the forced reboots again...
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION], are you using the correct syntax?

part blockDevice--L mountPoint "e2fsck -fy"

Filesystem is automatically detected.

[MENTION=5207466]otyg[/MENTION], run fbing -f or --fuse to undo the changes related to FUSE.

Remove the obb line, reboot and test whether the following command mounts obb: fbind -b $extobb $obb

Of it doesn't, try again with permissive SELinux.
[Magisk] otyg:
Selinux is set to permissive by default on this rom

# fbind -b $extobb $obb

mkdir: can't create directory '': No such file or directory

mkdir: can't create directory '': No such file or directory
[Magisk] xtam:
[MENTION=5228676]VR25[/MENTION]

how to use fbind with rclone?

https://forum.rclone.org/t/what-is-the-status-of-rclone-mount-on-android/4578/4

rclone is software which uses fusermount to mount google drive.

but even if folder is mounted in android, it is accessible only to process, who spawned this rclone mount.

So for example in termux

rclone mount remote: /storage.emulated/0/local

this /storage.emulated/0/local is properly listed if i do ls in the same termux window.

But file managers cant access it.

Unless i spawn file manager from termux.

how to use fbind in this case?
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION], since you've been using cryptsetup for a while, do you known whether echoing the passphrase to it works? I'm thinking on automating the decryption.

Also, I've been thinking on supporting file based encryption with encfs. There are static binaries out there and a Magisk module already. Unfortunately, encfs doesn't work on my system.

It'd be great if you tested that possibility.
[Magisk] VR25:
[MENTION=5207466]otyg[/MENTION], my bad... these variables won't work.

Try, fbind -b /mnt/runtime/default/sdCardName/Android/obb /mnt/runtime/default/emulated/obb
[Magisk] otyg:
fbind -b /mnt/runtime/default/0000-0000/Android/obb /mnt/runtime/default/emulated/obb

Then phone reboot

not sure if this helps but here is my cat /proc/mounts
[Magisk] VR25:
[MENTION=3525574]xtam[/MENTION], first, try mounting under the global mount namespace: su -Mc rclone mount remote: /storage.emulated/0/local

If that works, then fbind will work with rclone too (with some tweaking).
[Magisk] VR25:
[MENTION=5207466]otyg[/MENTION], funny system you got there...

Try

fbind -b /mnt/media_rw/0000-0000/Android/obb /mnt/runtime/default/emulated/obb

I'm curious as to whether other bind-mounts work...
[Magisk] otyg:
yeah that command completed successfully, obb(s) also show up in the /mnt/runtime/default/emulated/obb folder now
[Magisk] xtam:
it works, but only if i mount it on /mnt/rclone

so on /mnt/rclone i have full google drive.

(with global mount name space su -M).

Not possible to mount to /storage/rclone nor /storage/emulated/rclone

not possible also to /storage/emulated/0/rclone

not possible to/storage/emulated/0/Download/rclone

also tried

fbind -b /mnt/rclone /storage/emulated/rclone

and also failed, no content inside /storage/emulated/rclone but inside /mnt/rclone is ok.
[Magisk] 白い熊:
Indeed! On some prior version I had to manually specify ext4 before the fsck string — that's why the error :@)

---------- Post added at 02:48 PM ---------- Previous post was at 02:45 PM ----------

Yes it does — via a plain echo and a pipe, no problem.

I can test it —point me in the concrete direction — what you have in mind — which binary etc.
[Magisk] VR25:
[MENTION=5207466]otyg[/MENTION], nice...

I'll update the module accordingly.

Meanwhile, instead of <obb> use the config line <bind_mount /mnt/media_rw/0000-0000/Android/obb $obb>
[Magisk] VR25:
[MENTION=3525574]xtam[/MENTION], try

fbind -b /mnt/rclone /mnt/runtime/default/emulated/0/rclone
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION], cool...

There's a Magisk module in the repo (by TechnoSparks), conveniently named encfs. It's got everything we need. The binaries are built by DualJoe, the same who built the static cryptsetup we use. You know the thread...

Anyway, to get started, you have to install that module.

Test it by running su -Mc encfs --public <LUKS>/encfs /mnt/runtime/default/emulated/0/encfs
[Magisk] The_Walking_Playground:
Hi [MENTION=5228676]VR25[/MENTION],

Any more ideas on this? I hate not being able to bind mount the folders for my secondary users. I'm willing to provide any logs or output you want.

TWP
[Magisk] VR25:
Yes, today I found something new. The next version will comply with it.

For a quick test, run fbind -b /mnt/media_rw/*/someFolder /mnt/runtime/default/emulated/11/someFolder
[Magisk] The_Walking_Playground:
Hi,

So this is interesting. When using that command, I can see the folder contents in the default file manager, but I'm unable to save anything to the folder. Is this related to the "read" and "write" versions of the runtime folder? Is there any way to allow writing? Or would bind mounting to the "write" folder work?

TWP

EDIT: I tried the above and the result is the same. Read-only access. If I try to download a file, I get a message that storage is missing. So something still isn't right, though this is definitely a step in the right direction.

EDIT 2: I also just noticed that in my "mount" output, the secondary user bind mounts show up using the vold reference rather than the /mnt/media_rw path that the primary user gets mounted with. I wonder if that could be the issue.
[Magisk] VR25:
Interesting, indeed...

The command is supposed to mount that folder three times (default, read and write).

Lets test this raw...

After running the command, try the following:

0) Exit the root shell.

1) Get the numeric gid of user11 with the id command.

2) Remount the 3 mount points with the new group ID. Additionally, read and write must have mask=6, as follows:

su -Mc mount -o remount,rw,gid=value /mnt/runtime/default/emulated/11/someFolder

su -Mc mount -o remount,rw,gid=value,mask=6 /mnt/runtime/read/emulated/11/someFolder

su -Mc mount -o remount,rw,gid=value,mask=6 /mnt/runtime/write/emulated/11/someFolder