yashsingh1/xdaforums huggingface dataset:
[Magisk] VR25:
Mudule Updated

Check post #2.

Those who are experiencing issues with "mount," try the following (assuming you've already played with mount namespace settings in Magisk v13 Beta and it didn't work):

1. Disable Magisk v12 built in busybox

2. Flash osm0sis' awesome busybox installer from here (official attachment), or find it in the official thread here.

If you still experience issues after that, I wonder what exactly is causing "mount -o bind" to not work properly...

[MENTION=4544860]osm0sis[/MENTION], do you happen to have dealt with a similar issue?
[Magisk] VR25:
Got it.
[Magisk] 白い熊:
Great—generally I can report it's awesome, been using the ext4 card for e day no issues.

The file system is much faster, obviously as it's not the super slow exfat anymore —have to mount manually after boot, but great. Thanks a lot!

Tapatalk を使用して私の SM-N9200 から送信
[Magisk] VR25:
You're welcome!

Here's a new version:

v2017.8.18

* Fixed "intobb path" typo

* [EXPERIMENTAL] Added "data_data" function to bind /data/data to $extsd/.data (ext2,3,4 partition only)

* [TEST-FIX] Wait for alternate partition to show up in /dev/block before attempting to auto-mount it to $extsd_path

* Auto "fsck -fy" alternate partition

* Check README for more info
[Magisk] 白い熊:
It doesn't work. The script is getting stuck somewhere, maybe you've opened an endless loop somewhere—no command completes, even “fbind -log” doesn't complete, just sits there with no output…

Tapatalk を使用して私の SM-N9200 から送信
[Magisk] 白い熊:
Fri Aug 18 19:01:24 CEST 2017

###BEGIN FBIND LOG###

>>> Checking for configuration updates...

- Configuration updated.

^^^

That's the full log, so gets stuck right there…

---------- Post added at 07:12 AM ---------- Previous post was at 07:04 AM ----------

I've been inspecting the service.sh script - don't see anything apparent...
[Magisk] VR25:
v2017.8.18.1

* Major optimizations

* Faster bind engine

* Bug fixes
[Magisk] 白い熊:
Same problem, doesn't complete…

Tapatalk を使用して私の SM-N9200 から送信
[Magisk] VR25:
Will look closer into that. Perhaps I should partition my sdcard for faster debugging. By the way, there's suposed to be another log file (mount_altsd.log) just for the alternate partition mount. Do you have it?
[Magisk] 白い熊:
Got it - you don't have to: you have an error in the scripts where you test for partition existence.

You can't test with

-f

it's not a regular file, you have to test with

-b

because it's a block device.
[Magisk] VR25:
Exactly. I just realized that.
[Magisk] 白い熊:
OK, doesn't get stuck now. However doesn't bind the dirs on boot again - still not-existent, doesn't wait for when the partition is mounted - will check what's up.
[Magisk] VR25:
I have an idea. Will add something and see how it goes...
[Magisk] 白い熊:
It's simple - you just need to ad a sleep loop, testing for $3 in /proc/mounts right after the two lines where you first e2fsck and then mount the partition. That way it's not gonna proceed further until it's fully mounted.

---------- Post added at 10:08 AM ---------- Previous post was at 10:06 AM ----------

Also, can you, in the fbind script, tee the e2fsck to the log, so that we see it actually checked the partition?

---------- Post added at 10:39 AM ---------- Previous post was at 10:08 AM ----------

OK - scratch both, the fsck is teed to mount_altsd.log that's good.

Sleeping on nonexistent $3 in /proc/mounts doesn't work, since it seems to appear in /proc/mounts rightaway but the dirs still don't bindmount and say it's nonexistent - it seems there will have to be a fixed time wait - I'll try with a couple of seconds. Unless you have something else in mind.

---------- Post added at 10:53 AM ---------- Previous post was at 10:39 AM ----------

Fixed sleep of 5 seconds doesn't work, 60 does, so somewhere in between…

Tapatalk を使用して私の SM-N9200 から送信
[Magisk] janarp:
hey... i want that my downloads goes to SD card

my config;

from_to Download .fbind/Download

from_to MagiskManager .fbind/MagiskManager

but nothing happened when downloading something all stuff still goes to internal storage... what I'm doing wrong.. BTW my SD card format is extFAT
[Magisk] 白い熊:
30 seconds sleep works…

---------- Post added at 08:40 PM ---------- Previous post was at 07:44 PM ----------

15 doesn't work, 20 works.
[Magisk] 白い熊:
[MENTION=5228676]VR25[/MENTION], I don't think it's a good idea to bind the full /data/data dir—I'm afraid many things will be failing on boot.

Instead, I recommend to parameterize it—and allow to bindmount single directories within.
[Magisk] 白い熊:
On further testing 20 seconds fixed sleep doesn't work, sometimes mounts are missed during boot - so now testing 25 seconds, 30 seems to be good.
[Magisk] 白い熊:
Had to go back to 30 seconds, 25 would not be long enough on some reboots.

[MENTION=5228676]VR25[/MENTION], in the meantime, tried pausing it via an until sleep loop, right after mount, which tested “df | grep $extsd”, but doesn't work, doesn't pause the script long enough, some directories will still not mount due to “non-existence”. I don't know why this is—so far the only successful approach is via a fixed sleep.
[Magisk] 白い熊:
Bingo! It occurred to me that due to mount's unclear error message, it's unclear which directory doesn't exist when the mount fails—is it the origin or the destination. And so it is: it's actually reverse, the internal SD actually gets mounted very late on boot and so doesn't exist…

So with,

until mountpoint /storage/emulated; do sleep 0.5; done

in the script, right after running e2fsck and mount of the external SD it now mounts everything fine on boot!
[Magisk] 白い熊:
Also, @VR25, you forgot to add data_data section to fbind, it's only in service.sh

Please parameterize it, or add a parameterized variant too like you have with obb.
[Magisk] pat357:
exFAT is no problem, mine is also exFAT and everything works.

Why do you think it goes to int. storage ?

It's normal you see the downloaded files in the internal, but in reality they are stored on the ext SD.

Did you do :

su
fbind -mb

Do you have the directory .fbind on your ext SD card ?

Are the 2 directories ./fbind/MagiskManager and /.fbind/Download under this .fbind directory present ?

Do they have any content ?
[Magisk] janarp:
nope I don't have. bind folder on SD card... I try later that... thanks
[Magisk] pat357:
just do from the terminal (I use Termux from PS) :

su

fbind -mb

and it should work.
[Magisk] 白い熊:
OK, I tried it just to make sure - it fails spectacularly, the whole system FC's, you don't wanna see it... :eek:)

So you don't wanna leave it non-parameterized at all.

Modified it to a parameterized version, along the lines of obbf, and mounts smooth - the moved app works. All's good.
[Magisk] pat357:
What did you change to make it work ?

What do you mean by "parameterized" ?

I'm just curious to know ;)
[Magisk] 白い熊:
I rewrote the mount script to take parameters, [MENTION=5228676]VR25[/MENTION] knows what I mean…
[Magisk] VR25:
Sorry for the long wait.

My internet connection is still extremely slow (it's actually been even worse these days). Can't even load a basic web page decently.

For now, I'm just trying to upload stuff. Will answer posts later.

v2017.8.23

* Redesigned for easier maintenance. $MODPATH/service.sh & $MODPATH/system/xbin/fbind now use/"source" a common, standalone core, which contains all the functions required for the module to work.

* Major optimizations

* Enhanced debugging tools.

* [TEST-FIX] auto-mount alternate partition --> altpart() $1=block_device, $2=mount_point $3=file_system, $4="fsck OPTION(s)" (filesystem dependent, optional).

* Ability to specify an alternate extsd_path (i.e., /mnt/media_rw/NAME) --> for path other than the standard /mnt/media_rw/XXXX-XXXX. SD cards with filesystems other than "fat32" or "exfat" generally have longer names.

* Updated reference.

* Added options to see the README and changelog on terminal (fbind -ref & -chlog).

* Not a change, but please... ALWAYS read the reference (README.txt & config_example.txt) before installing/updating. Not answering dumb questions anymore.
[Magisk] 白い熊:
The unification into “core” is a step forward - on other fronts it seems a step-back, alternate partition/fsck check - still commented WIP. data_data also...
[Magisk] VR25:
Yup, I see the picture. That's actually a test to evaluate whether or not this is a good idea overall.

I didn't read your posts until today. You came up with very nice things there!

Everything you found out is exactly the same I stumbled upon. We're on the same page since day 1.

Anyway, even though the module version is 2017.8.23, all the most significant changes were actually made several days ago.

I didn't have enough time to finish the aforementioned portions. Also, as I stated, my internet connection is beyond terrible. That makes it extremely hard to get in touch at times.

Since you're thinking what I'm thinking, the next version will include all the changes you mentioned.

I'll exclude wait_emulated() from data_data(), though -- to bind that part as early as possible. ;)
[Magisk] 白い熊:
Yep, it's unnecessary there, as it doesn't need the internal storage…
[Magisk] VR25:
v2017.8.24

* Massive optimizations

* Parameterized app_data() to bind individual app data (safer).

* Added ability to "copy -a" /data/data/$1 to $extsd/.data from terminal (fbind -m).

* Added app_data() Cleanup Extension (post-fs-data.sh) to safely rm "/data/data/$1/*".

* Updated wait_emulated() for altpart().

* Better log & fbind toolkit output

* Updated reference

Notice that data_data() changed to app_data().
[Magisk] 白い熊:
Very nice—I like how the wait_altsd is implemented intelligently…

What always gets me is the change of variable names :@) But it's a good exercise—makes you read the readme…

Did you remove the altsd mount log?
[Magisk] VR25:
I always try to make everything as intuitive as possible. ;)

altsd mount log is no longer in a separate log file. It's now in the main -- debug.log.
[Magisk] 白い熊:
So far I have not identified any errors - all is working good!

I have two requests, if I may:

- Please cat the e2fsck output to the log as well, I'd like to see that it checked the partition and all is good

- The stupid Spotify app adds an Android/data/com.spotify.music dir to every bound directory as it thinks it's a separate card. You have the kill options for int and ext SD, however it's not practical to list the Android subdir to be killed for every ext dir that gets mounted. Could you implement an option that will go through all the ext dirs mounted and if they have an Android subdir, it'll “rm -r” it? There is no reason a mounted dir would legitimately have this subdir, the only exception would be the whole ext SD which obviously would have it.

- If you wanted to be extra safe you could add it parameterized - whereby it would check for the full parameter - “Android/data/com.spotify.music” in this case and then delete the full path, if otherwise empty, leaving behing e.g. “Android/trash” if you wished to have it.

This would be a great help.
[Magisk] VR25:
- I thought the fsck log was already there! :silly:

- Oh, Spotify, Spotify... what a dumb behavior you have, Spotify!

Anyway, I'll look on these two & more optimizations next.

Glad to actually have someone so interested in adding new features/debugging. That keeps me busy doing one of the things I like the most.
[Magisk] 白い熊:
Let me check regarding the fsck log, I didn't notice any fsck output in the log when I checked now...

My phone is now off - as I'm restoring my mount directories on the ext SD - as I added the kill lines to the config.txt for all the dirs - to kill the Spotify stuff and forgot the Android at the end - DUH! Man, at least we checked the kill on altsd works as it nicely deleted all the dirs! Lol...

OK, just checked - you must've forgotten about fsck, as you've commented it out in the script - residue from testing, the mount doesn't run fsck now...

OK, my bad, I thought there's a default fsck if no option is specified - didn't realize I have to specify it manually in the config - your way is better though, makes for finer control. Thanks.
[Magisk] Yom:
Non Magisk fbind

Hi VR25!

Just love your excellent work! Fbind works flawless!

Problem is that Magisk is a heartless ***** on my phone... Loses root, hangs on splash screen on boot...

Could you please advise how I can get fbind to run without Magisk? Can it be called from an init.d script?
[Magisk] VR25:
Glad I didn't miss the fsck log.

Those nasty Spotify folders, lol... I feel the pain. A new version with a proper "serial killer" for files/folders with such a virulent behavior is ready. Will upload soon.

First, you should try different magisk version, starting from the latest STABLE. I know... it's a pain, but well worth it.

Second, I can modify fbind to work without Magisk after you've gone through the aforementioned procedure. I'm a bit skeptical in regards to init.d, though. For some reason, it's being killed off very fast. You could use an app to emulate it, but you simply can't get the same performance/latency.
[Magisk] VR25:
v2017.8.26

* More optimizations

* Redesigned kill() -- additional features (find_rm) & more compact/intuitive (check REDME's "Config Syntax" section)

* Enhanced "update_prep.sh" to be more widely compatible with older module versions.

* Updated reference (README.txt & config_example.txt)
[Magisk] 白い熊:
I think the '-xr' kill implementation is not very good - the usage via find is time consuming - on my 512gb SD it takes 10 seconds, and I don't have a complicated directory structure in place - if there's gonna be many nested dirs, this'll wastefully search all the structure unnecessarily. I'd propose to change to just 'rm -rf' the file in directories that are bindmounted - this is easy to do - you already record them /magisk/fbind/.config/bind so it'll be fast and won't unnecessarily search anywhere else.

Also the '! -path "$3"' doesn't work as you think it does: if $3 is '$extsd/Android' it'll still find the subdir and delete - to make it skip, it'd have to be '$extsd/Android/data/com.spotify.music' - you have to specify the complete path to make find exclude it. That's cumbersome...

Plus also keep in mind: you wanna delete the Android folder - wherein the further data/com.spotify.music lies - you don't wanna leave the Android/data part behind - but obviously you don't want to search and delete all 'Android' folders per se...
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION], I should've put more though into that. Thanks for the reminder!

Here's v2017.8.26.1

* Added kill -b -- auto-remove nasty [Android] subdirs from extsd bound folders. No args needed. More efficient, performance & resources-wise than kill -r/ir/xr.

* Added fbind -c -- run cleanup()

* Updated reference
[Magisk] 白い熊:
The zip file is damaged, cannot be extracted...

---------- Post added at 09:53 AM ---------- Previous post was at 09:48 AM ----------

Also, I couldn't inspect it yet obviously - but just a thought on 'kill -b': there needs to be a way to add exceptions - more than one - to the default delete of Android directories. This is because for instance I mount the card to /mnt/sdb1 - there's obviously an Android folder there, as Spotify uses it as external storage - that's the one place where I want to not delete it.

But then I have the root of the card again bindmounted within the internal sd to a directory in its root - for quick access - and then I have one more directory where I mount often used directories - on the internal sd again as you can't have symlinks there. So all these directories are the same SD root - so I need to be able to specify them as exceptions, so the Android directory doesn't get deleted...
[Magisk] VR25:
I see...

Will work on that.
[Magisk] 白い熊:
[MENTION=5228676]VR25[/MENTION], I have another request, if I may—and I can experiment and test it for you:

We have the statically compiled cryptsetup from LUKS Manager—an abandoned app in the store, the binary works though, just tested it. I compiled a static cryptsetup too some time ago, but can't find it now...

Assuming you will have it the path somewhere, can you ad a cryptsetup variant to enable mounting LUKS volumes?

It would only work with autobind on boot disabled, since you need to input the password on decrypt—but that's OK.

It would only be slightly tricky, as you have to separate the mount from the luksOpen phase, as you need to insert the fsck between these steps—but it's doable without major issues.
[Magisk] VR25:
Interesting idea...

Lets try that!

Could you upload the binary here?

Now, about "kill - b"...

{ obb() { mntpt $intobb && rm -rf $extobb/Android; }
obbf() { mntpt $intobb/$1 && rm -rf $extobb/$1/Android; }
target() { mntpt "$intsd/$1" && rm -rf "$extsd/$1/Android"; }
from_to() { if mntpt "$intsd/$1" && [ "$1" != "-e" ]; then rm -rf "$extsd/$2/Android"; fi; }
app_data() { mntpt /data/data/$1 && rm -rf $extsd/.data/$1/Android; }
source $bind_list
echo "Nasty [Android] folders"; } 2>/dev/null
source $cleanup_config

# Optional cleanup script
[ -f $fbind_dir/cleanup.sh ] && source $fbind_dir/cleanup.sh

Have you analyzed that part yet? What do you think of the end portion?

I've been a little busy lately, but the greatest factor standing between me and development progress is my beyond poor internet connection.

Here's the next version's major changelog (WIP)

* fbind -rollback now able to restore /data/data/* as well (safely)

* app_data() can now work without an alternate partition (usually /dev/block/mmcblkp2), assuming /dev/block/mmcblkp1 has a Linux filesystem (i.e., ext2,3,4, f2fs) & extsd_path() is in use (obviously)

* Added "from_to -e" (extended from_to) -- yes, it does exactly what the name suggests. Check README &/or config_example.txt for more info.

* Added support for optional cleanup script ($intsd/fbind/cleanup.sh) to be sourced by "kill -b"

* fbind -a (add line(s)), -dd (add app_data line(s)) & -r (remove line(s) are now interactive.
[Magisk] 白い熊:
Very nice! I think with “-e” the exceptions are implemented in a very smart way.

Here's the binary - it works, I checked it, it'll open the LUKS volumes and then they can be mounted on the phone.

Where are you, BTW, that your internet connection is so poor?
[Magisk] VR25:
My $PWD is /milkyway/solarsystem/earth/africa/angola

I managed to push the latest version to Magisk modules repo. My internet speed & reliability are a bit better now.

Here's the changelog:

v2017.8.30

* fbind -rollback is now able to restore /data/data/* as well (safely).

* app_data() can now work without an alternate partition (usually /dev/block/mmcblkp2), assuming /dev/block/mmcblkp1 has a Linux filesystem (i.e., ext2,3,4, f2fs) & extsd_path() is in use (obviously).

* Added "from_to -e" (extended from_to) -- yes, it does exactly what the name suggests. Check README &/or config_example.txt for more info.

* "kill -b" also cleans up "from_to -e" folders. At the end, it "sources" an optional cleanup script ($intsd/fbind/cleanup.sh).

* Interactive fbind -a (add line(s)) WIP --> -dd (add app_data line(s)) & -r (remove line(s)

* Added "cryptsetup" (LUKS) support (WIP).
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION], the attached zip contains screenshots of the main changes you may want to look at.
[Magisk] Nightwing0815:
Hey there!

Something doesn't work on my phone...

Config:

from_to Test1 .fbind/Test1
from_to Test2 /Test2
from_to Test3 Test3
from_to "$intsd"/Test4 "$extsd"/Test4

#from_to Downloads .fbind/Downloads
#from_to WhatsApp .fbind/WhatsApp
obb
kill -i Podcasts
kill -i Alarms
kill -i com.cmcm.whatscalllite
kill -i Documents
kill -i Movies
kill -i Notifications
kill -i Music
kill -i Ringtones
kill -ix Keku
kill -i .mobvista700
kill -i Android/obj
kill -i Android/SLOWDNS_TEMP_DIR
kill -i Android/TROID_TEMP_DIR
kill -i Android/.playstor.srf
kill -i Android/data/.um
kill -b

Terminal:

htc_pmeuhl:/ $ su
htc_pmeuhl:/ # fbind -mb

[from_to() "Test1" ".fbind/Test1"]
! Nothing to move. Skipping...

[from_to() "Test2" "/Test2"]
! Nothing to move. Skipping...

[from_to() "Test3" "Test3"]
! Nothing to move. Skipping...

[from_to() "/data/media/0/Test4" "/mnt/media_rw/9C33-6BBD/Test4"]
Moving [/data/media/0//data/media/0/Test4/*] to [/mnt/media_rw/9C33-6BBD//mnt/media_rw/9C33-6BBD/Test4]...
cp: /data/media/0//data/media/0/Test4/*: No such file or directory
cp: bad '/data/media/0//data/media/0/Test4/*': No such file or directory
/system/xbin/fbind: /magisk/fbind/.config/bind[4]: cd /data/media/0//data/media/0/Test4: not found
! rm source files failed!

[obb()]
Moving [/data/media/obb/*] to [/mnt/media_rw/9C33-6BBD/Android/obb]...
cp: /data/media/obb/*: No such file or directory
cp: bad '/data/media/obb/*': No such file or directory

- Done!

>>> bind_folders()

[/data/media/0//data/media/0/Test4] <--> [/mnt/media_rw/9C33-6BBD//mnt/media_rw/9C33-6BBD/Test4]
mount: '/mnt/media_rw/9C33-6BBD//mnt/media_rw/9C33-6BBD/Test4'->'/data/media/0//data/media/0/Test4': No such file or directory

[/data/media/obb] <--> [/mnt/media_rw/9C33-6BBD/Android/obb]mount: '/mnt/media_rw/9C33-6BBD/Android/obb'->'/data/media/obb': No such file or directory

- Done!

htc_pmeuhl:/ #

I'd prefer binding folders directly to externa SD, not there in a .fbind folder...

Thanks for help!

ToM
[Magisk] VR25:
Fixed!

Simply replace "/magisk/fbind/core.sh" file by the attached one (remove the .txt extension). No need to reboot nor set permissions.

Or... re-download, reinstall the module & reboot.

You can change that ".fbind" dir as you wish. Don't forget the dot, though -- if you're binding media folders (it lets you avoid duplicates).
[Magisk] Nightwing0815:
Thanks!

Okay, i now have a few questions...:angel:

folders, that i'll moving and binding from intsd to extsd: do they remain in intsd after cp / rm / bind? i think, it was like this...

why isn't there a function to migrate data, if a folder in target destination exists? lets assume, you'll do a fresh install of your rom and you'll have to do new (existing) bindings.

next is: why is the fbind folder with its settings in intsd?? Is it possible, to make a comma separated array with directory names in it, to choose by self, what should be excluded? dir_2_del(name_1, name_2, name_3, ... )

what are the obb?

please specify, what nasty files / folders are...

Thanks in advance :o

ToM
[Magisk] 白い熊:
[MENTION=5228676]VR25[/MENTION], I don't know why you need cryptsetup.sh

Instead of:

=====

###WIP### cryptsetup (LUKS) support ( bin path: $module_path/system/xbin/cryptsetup)

if [ $fbind_dir/cryptsetup.sh ]; then

echo

source $fbind_dir/cryptsetup.sh

[ "$4" ] && $4 $1

mount -t $3 -o noatime,rw $1 $2

echo

else

=====

why don't you just do:

=====

if grep -v '#' $config_file | grep -q 'cryptsetup=true'; then

MOUNTPOINT=`echo $1 | sed 's/.*\///'`

echo

cryptsetup luksOpen $1 $MOUNTPOINT

if [ "$4" ]; then

$4 /dev/mapper/$MOUNTPOINT

fi

mount -t $3 -o noatime,rw /dev/mapper/$MOUNTPOINT $2

echo

else

=====

This would be a nice clean mount, with check and all...
[Magisk] Didgeridoohan:
[MENTION=5228676]VR25[/MENTION] [MENTION=4237286]白い熊[/MENTION]

I must say I really enjoy taking part of your back and forth with this module.
[Magisk] 白い熊:
Also, [MENTION=5228676]VR25[/MENTION], the “-e” is not what I thought it was gonna be—I thought you will implement exceptions this way.

Anyhow, this is the way to go, to make deleting the rogue folders intelligent: you've already made it just go through the mounted list—good. Now, if you'll add any other kill switch to from_to etc. and it'll be kept in the mounted list, then the script, when going through the list, to get where to delete will not delete in these folders—and again it'll be intelligent, nothing will have to be searched…
[Magisk] Captain_Throwback:
[MENTION=5228676]VR25[/MENTION]

Any way to add Multiuser support for this module? I added another account to my device and realized that for that user, the fbind folder on /sdcard doesn't exist. I assume that's because it's in /data/media/0 and not /data/media/11, where my second user's "sdcard" is. I'm just not sure how to set up a second user, since there's only one Magisk image and the setup is in there and not in a folder unique to each user.