ts-binds
ts-binds basically make use of “bind” parameter of the “mount” available in your Android environment
Development Abandoned!
This project has been abandoned. This is because I personally do not require ts-binds anymore. Refer announcement post here: https://forum.xda-developers.com/showpost.php?p=79150883&postcount=237
What does it do
Essentially, this "binding" method is widely used to save space on internal storage!
Derived from a very long-living trick for users who are struggling with the internal storage space available on their phones, while at the same time has the benefit of inserting an SD card, ts-binds will make use of already available functions on your device, to mirror a path to another path, effectively making both paths indistinguishable.
For example, if you mirror the `Download` folder on Internal with the `Stuff from Internet` folder on your SD Card, the same list of cat pictures will be shown on both directories when navigated via a file manager, and any changes will take effect on both paths but only the folder in the external path is physically modified.
This saves space because the files physically reside on the external storage instead of internal storage.
Further read
To maintain a similar "Description" of the module, I had to trim down the OP of the thread. There are a total of 3 places where I host the module's description To read documentation, please go to my website
Alternative modules with the same purpose
Magic Folder Binder (really advanced compared to this module!)
Magisk Foldermount (may be abandoned)
Links
Documentation
→ DOWNLOAD ZIPs (Also available in Magisk Repo)
GitHub
Changelogs
Verbose changelog for Magisk releases
Nice work!
Module has been accepted into the repository. Now it is available for install and update via Magisk.
Since the creation of this thread, there has been 4 newer versions, the latest being 1.0.4.
Hi @TechnoSparks!
I have the following problem:
I had set folder list line like this:
folderbind ogi "$sd/Ogi" "$int/Ogi"
and after reboot my log file looks like this:
Log initialised at: Sat Aug 12 19:50:30 CEST 2017
2017-08-12 19:50:30:
Difference found between cached and original user list
2017-08-12 19:50:30:
Updated cached list
2017-08-12 19:50:30:
sdcard 7788-9789 mounted
2017-08-12 19:50:30:
Binding all entries
2017-08-12 19:50:31:
Bind aborted: Folder '/mnt/media_rw/7788-9789/Ogi' as source doesn't exist!
2017-08-12 19:50:31:
All entries were processed
2017-08-12 19:50:31:
Script execution completed
What could be wrong?
Thank you.
---------- Post added at 06:58 PM ---------- Previous post was at 06:57 PM ----------
ogisha said:
Hi @TechnoSparks!
I have the following problem:
I had set folder list line like this:
folderbind ogi "$sd/Ogi" "$int/Ogi"
and after reboot my log file looks like this:
Log initialised at: Sat Aug 12 19:50:30 CEST 2017
2017-08-12 19:50:30:
Difference found between cached and original user list
2017-08-12 19:50:30:
Updated cached list
2017-08-12 19:50:30:
sdcard 7788-9789 mounted
2017-08-12 19:50:30:
Binding all entries
2017-08-12 19:50:31:
Bind aborted: Folder '/mnt/media_rw/7788-9789/Ogi' as source doesn't exist!
2017-08-12 19:50:31:
All entries were processed
2017-08-12 19:50:31:
Script execution completed
What could be wrong?
Thank you.
Click to expand...
Click to collapse
BTW, both folders exist.
ogisha said:
Hi @TechnoSparks!
I have the following problem:
I had set folder list line like this:
folderbind ogi "$sd/Ogi" "$int/Ogi"
and after reboot my log file looks like this:
Log initialised at: Sat Aug 12 19:50:30 CEST 2017
2017-08-12 19:50:30:
Difference found between cached and original user list
2017-08-12 19:50:30:
Updated cached list
2017-08-12 19:50:30:
sdcard 7788-9789 mounted
2017-08-12 19:50:30:
Binding all entries
2017-08-12 19:50:31:
Bind aborted: Folder '/mnt/media_rw/7788-9789/Ogi' as source doesn't exist!
2017-08-12 19:50:31:
All entries were processed
2017-08-12 19:50:31:
Script execution completed
What could be wrong?
Thank you.
---------- Post added at 06:58 PM ---------- Previous post was at 06:57 PM ----------
BTW, both folders exist.
Click to expand...
Click to collapse
Hello
This seems to be a very odd issue, but it could be that ts-binds cannot access the folder via the hardcoded address of "/mnt/media_rw/". this is a perfect opportunity for me to troubleshoot this. Thank you for the report.
It would be great if you could run these commands (without the hashtags) on your terminal emulator and report back with the output (whether text or screenshots, your choice):
Code:
# if [ -d "/storage/7788-9789/Ogi" ]; then echo Exists; else echo Nope; fi
# ls -a1 /mnt
it would also be a great addition if you could copy the file "/proc/mounts" and attach it here.
And may I know what device are you using and the respective ROM version?
TechnoSparks said:
Hello
This seems to be a very odd issue, but it could be that ts-binds cannot access the folder via the hardcoded address of "/mnt/media_rw/". this is a perfect opportunity for me to troubleshoot this. Thank you for the report.
It would be great if you could run these commands (without the hashtags) on your terminal emulator and report back with the output (whether text or screenshots, your choice):
it would also be a great addition if you could copy the file "/proc/mounts" and attach it here.
And may I know what device are you using and the respective ROM version?
Click to expand...
Click to collapse
Commands' output:
HWEVA:/ $ su
HWEVA:/ # if [ -d "/storage/7788-9789/Ogi" ]; then echo Exisge/7788-9789/Ogi" ]; then echo Exists; else echo Nope ; fi <
Nope
HWEVA:/ # ls -a1 /mnt
.
..
appfuse
asec
expand
ext_sdcard
media_rw
obb
runtime
sdcard
secure
user
HWEVA:/ #
mounts file attached:
https://mega.nz/#!VF8wHIAb!hVPzmAVoBEWhLUehostkfb7kXOAELVA4iSsqMiooY3E
Device's information:
BOARD
EVA-L09
BOOTLOADER
unknown
BRAND
HUAWEI
CPU_ABI
arm64-v8a
DEVICE
HWEVA
DISPLAY
EVA-L09C432B386
FINGERPRINT
HUAWEI/EVA-L09/HWEVA:7.0/HUAWEIEVA-L09/C432B386:user/release-keys
HARDWARE
hi3650
HOST
wuhjk0154cna
ID
HUAWEIEVA-L09
MANUFACTURER
HUAWEI
MODEL
EVA-L09
PRODUCT
EVA-L09
SERIAL
MWS7N17104001072
TAGS
release-keys
TYPE
user
UNKNOWN
unknown
USER
test
CODENAME
REL
INCREMENTAL
C432B386
RELEASE
7.0
SDK_INT
24
RADIO
21.258.05.00.030
Root Access:
Access Granted
SU:
su found
UID/GID:
uid=0(root)
gid=0(root)
groups=0(root)
context=u:r:su:s0
Utils:
busybox
toybox
toolbox
Path:
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/system/vendor/bin:/vendor/xbin:/system/vendor/xbin:/product/bin:/product/xbin
Path:
/sbin/
Version:
13.3:MAGISKSU (topjohnwu)
Permissions:
rwxrwxrwx
Owner:
root:root
SELinux:
Enforcing
Path:
[/system/xbin/]
Permissions:
r-xr-xr-x
Owner:
root:shell
Thank you!
ogisha said:
Commands' output:
HWEVA:/ $ su
HWEVA:/ # if [ -d "/storage/7788-9789/Ogi" ]; then echo Exisge/7788-9789/Ogi" ]; then echo Exists; else echo Nope ; fi <
Nope
HWEVA:/ # ls -a1 /mnt
.
..
appfuse
asec
expand
ext_sdcard
media_rw
obb
runtime
sdcard
secure
user
HWEVA:/ #
mounts file attached:
https://mega.nz/#!VF8wHIAb!hVPzmAVoBEWhLUehostkfb7kXOAELVA4iSsqMiooY3E
Device's information:
BOARD
EVA-L09
BOOTLOADER
unknown
BRAND
HUAWEI
CPU_ABI
arm64-v8a
DEVICE
HWEVA
DISPLAY
EVA-L09C432B386
FINGERPRINT
HUAWEI/EVA-L09/HWEVA:7.0/HUAWEIEVA-L09/C432B386:user/release-keys
HARDWARE
hi3650
HOST
wuhjk0154cna
ID
HUAWEIEVA-L09
MANUFACTURER
HUAWEI
MODEL
EVA-L09
PRODUCT
EVA-L09
SERIAL
MWS7N17104001072
TAGS
release-keys
TYPE
user
UNKNOWN
unknown
USER
test
CODENAME
REL
INCREMENTAL
C432B386
RELEASE
7.0
SDK_INT
24
RADIO
21.258.05.00.030
Root Access:
Access Granted
SU:
su found
UID/GID:
uid=0(root)
gid=0(root)
groups=0(root)
context=u:r:su:s0
Utils:
busybox
toybox
toolbox
Path:
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/system/vendor/bin:/vendor/xbin:/system/vendor/xbin:/product/bin:/product/xbin
Path:
/sbin/
Version:
13.3:MAGISKSU (topjohnwu)
Permissions:
rwxrwxrwx
Owner:
root:root
SELinux:
Enforcing
Path:
[/system/xbin/]
Permissions:
r-xr-xr-x
Owner:
root:shell
Thank you!
Click to expand...
Click to collapse
EDIT: never mind, when i return from work today i will create an exclusive simple troubleshooting script for you! This is to ease the troubleshooting.
----
I have to say something weird is happening. The terminal should say the directory exists on the location i mentioned.
From the way you present your things, it seemed that you know what you are doing and is good with terminal. Could you report if you can "ls Ogi" when you changed the working directory to "/mnt/media_rw/7788-9789", "/storage/7788-9789" and "/mnt/ext_sdcard"?
Out of curiosity, I have seen issues in regards to sdcardfs with Magic Folder Binder module, and is wondering if your issue also has to do with it. Please run "grep sdcardfs /system/build.prop" and return me the output. Just some extra for fun note: My module isn't really ready to handle issues with sdcardfs and i may need to implement Magic Folder Binder's methods (persist off for build prop entry)
Also make sure the Ogi folder still exists tho lel ?
Sorry for having the commands not enclosed in the code tags. I am replying to this on the go
TechnoSparks said:
EDIT: never mind, when i return from work today i will create an exclusive simple troubleshooting script for you! This is to ease the troubleshooting.
Click to expand...
Click to collapse
Thanks. ?
--
I have to say something weird is happening. The terminal should say the directory exists on the location i mentioned. From the way you present your things, it seemed that you know what you are doing and is good with terminal. Could you report if you can "ls Ogi" when you changed the working directory to "/mnt/media_rw/7788-9789", "/storage/7788-9789" and "/mnt/ext_sdcard"?
--
Here comes the output:
HWEVA:/ $ su
HWEVA:/ # cd /mnt/media_rw/7788-9789
sh: cd: /mnt/media_rw/7788-9789: No such file or directory
2|HWEVA:/ # cd /storage/7788-9789
sh: cd: /storage/7788-9789: No such file or directory
2|HWEVA:/ # cd /mnt/ext_sdcard
HWEVA:/mnt/ext_sdcard # ls Ogi
HWEVA:/mnt/ext_sdcard #
BTW, both Ogi folders are empty.
--
Out of curiosity, I have seen issues in regards to sdcardfs with Magic Folder Binder module, and is wondering if your issue also has to do with it.
--
Magic Folder Binder did not work for me.
The developer was not interested in investigating the problem. ?
--
Please run "grep sdcardfs /system/build.prop" and return me the output. Just some extra for fun note: My module isn't really ready to handle issues with sdcardfs and i may need to implement Magic Folder Binder's methods (persist off for build prop entry)
--
Here comes the output:
HWEVA:/ $ su
HWEVA:/ # grep sdcardfs /system/build.prop
1|HWEVA:/ #
--
Also make sure the Ogi folder still exists tho lel ?
--
Yeah, both do and both are empty. ?
--
Sorry for having the commands not enclosed in the code tags. I am replying to this on the go
--
No problem at all. ?
Thank you. ?
ogisha said:
Thanks.
--
I have to say something weird is happening. The terminal should say the directory exists on the location i mentioned. From the way you present your things, it seemed that you know what you are doing and is good with terminal. Could you report if you can "ls Ogi" when you changed the working directory to "/mnt/media_rw/7788-9789", "/storage/7788-9789" and "/mnt/ext_sdcard"?
--
Here comes the output:
HWEVA:/ $ su
HWEVA:/ # cd /mnt/media_rw/7788-9789
sh: cd: /mnt/media_rw/7788-9789: No such file or directory
2|HWEVA:/ # cd /storage/7788-9789
sh: cd: /storage/7788-9789: No such file or directory
2|HWEVA:/ # cd /mnt/ext_sdcard
HWEVA:/mnt/ext_sdcard # ls Ogi
HWEVA:/mnt/ext_sdcard #
BTW, both Ogi folders are empty.
--
Out of curiosity, I have seen issues in regards to sdcardfs with Magic Folder Binder module, and is wondering if your issue also has to do with it.
--
Magic Folder Binder did not work for me.
The developer was not interested in investigating the problem.
--
Please run "grep sdcardfs /system/build.prop" and return me the output. Just some extra for fun note: My module isn't really ready to handle issues with sdcardfs and i may need to implement Magic Folder Binder's methods (persist off for build prop entry)
--
Here comes the output:
HWEVA:/ $ su
HWEVA:/ # grep sdcardfs /system/build.prop
1|HWEVA:/ #
--
Also make sure the Ogi folder still exists tho lel
--
Yeah, both do and both are empty.
--
Sorry for having the commands not enclosed in the code tags. I am replying to this on the go
--
No problem at all.
Thank you.
Click to expand...
Click to collapse
Thank you for the output. It seemed that I may have found the issue. My script unreliably pulled the wrong sdcard serial ID when the "grep"ing was run. In your mounts the line:
Code:
/dev/block/bootdevice/by-name/system /dev/magisk/dummy/system/bin/79b77788-9789-4a7a-a2be-b60155eef5f4.sec ext4 ro,seclabel,relatime,data=ordered 0 0
came first before the sdcard mounting line:
Code:
/dev/block/vold/public:179:193 /mnt/media_rw/7EB2-43FD vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
The first line contains sequences of which matches my regular expression here:
Code:
sdname=$(grep -m 1 -Eo "[0-9A-F]{4}-[0-9A-F]{4}" /proc/mounts)
Possible fix: Reliably get the whole "media_rw" line before extracting SD card's serial
Please test the following pre-release: https://drive.google.com/file/d/0ByQKilNkFEpAaW02RGJoRUZGcUU/view?usp=sharing
TechnoSparks said:
Thank you for the output. It seemed that I may have found the issue. My script unreliably pulled the wrong sdcard serial ID when the "grep"ing was run. In your mounts the line:
came first before the sdcard mounting line:
The first line contains sequences of which matches my regular expression here:
Possible fix: Reliably get the whole "media_rw" line before extracting SD card's serial
Please test the following pre-release: https://drive.google.com/file/d/0ByQKilNkFEpAaW02RGJoRUZGcUU/view?usp=sharing
Click to expand...
Click to collapse
Thank you. I have tested it. Log file now looks like this:
-----
Log initialised at: Tue Aug 15 19:30:54 CEST 2017
2017-08-15 19:30:55:
Cached the user list
-----
Anything I copy to internal Ogi folder does not show up in external Ogi folder. ?
Thank you again. ??
ogisha said:
Thank you. I have tested it. Log file now looks like this:
-----
Log initialised at: Tue Aug 15 19:30:54 CEST 2017
2017-08-15 19:30:55:
Cached the user list
-----
Anything I copy to internal Ogi folder does not show up in external Ogi folder.
Thank you again.
Click to expand...
Click to collapse
Thank you for the report again and apologies for the new issue. I have able to pinpoint the issue and it seems to be a grammar error for bash.
I have corrected the issue and this is another test package for you to test: https://drive.google.com/open?id=0ByQKilNkFEpAaW02RGJoRUZGcUU
The reason why the content didn't show up was because no binding process were made. As you can see in the log, there is no "Binding all entries". Hopefully this one will finally squash the issue!
As you may notice, the "beta" also contains some changes, mainly just some cleanup and a new description.
TechnoSparks said:
Thank you for the report again and apologies for the new issue. I have able to pinpoint the issue and it seems to be a grammar error for bash.
I have corrected the issue and this is another test package for you to test: https://drive.google.com/open?id=0ByQKilNkFEpAaW02RGJoRUZGcUU
The reason why the content didn't show up was because no binding process were made. As you can see in the log, there is no "Binding all entries". Hopefully this one will finally squash the issue!
As you may notice, the "beta" also contains some changes, mainly just some cleanup and a new description.
Click to expand...
Click to collapse
Everything went fine according to log file.
Now Ogi folder on internal sdcard has disappeared and file 0 bytes long named Ogi appeared.
Folder Ogi on external sdcard stayed untouched.
Thanks again. ?
ogisha said:
Everything went fine according to log file.
Now Ogi folder on internal sdcard has disappeared and file 0 bytes long named Ogi appeared.
Folder Ogi on external sdcard stayed untouched.
Thanks again.
Click to expand...
Click to collapse
This is abnormal. For the first patch, I could blame myself for not testing it myself before publishing it to you. The reason was because i did a simple test on the terminal on nested command substitution ( $() ) and it worked, so I called it a job done. However I didn't expect it to not work if the nested command substitution is placed as a conditional, hence the past issue. The second revision fixed this by well, not using nested command substitution. The second version is personally tested and my folders are now binded correctly and working as expected like 1.0.4
Also, please tell me what file manager are you using.
I think this must have to do with the ROM or the kernel, since the modifications that I did to try to fix your previous issues was just related to how SD card serial ID is pulled. Let's check if the system recognises the folder via terminal.
Code:
cd /storage/emulated/0
ls -al | grep Ogi
check if the output is similar to this:
Code:
drwxrwx--x 1 root sdcard_rw 131072 2017-08-17 04:25 Ogi
Emphasis on the "drwxr-xr-x". If yours is similar, then continue below. Otherwise please report that it didnt.
Great! It seems that most probably it has something to do with the ROM, but not with the kernel. Next, I'd like for you to "cd" into it, then create a text file by running this simple line:
Code:
echo date > text.txt
Now, check if the text file exists on SD Card folder, by using a file manager.
TechnoSparks said:
This is abnormal. For the first patch, I could blame myself for not testing it myself before publishing it to you. The reason was because i did a simple test on the terminal on nested command substitution ( $() ) and it worked, so I called it a job done. However I didn't expect it to not work if the nested command substitution is placed as a conditional, hence the past issue. The second revision fixed this by well, not using nested command substitution. The second version is personally tested and my folders are now binded correctly and working as expected like 1.0.4
Also, please tell me what file manager are you using.
I think this must have to do with the ROM or the kernel, since the modifications that I did to try to fix your previous issues was just related to how SD card serial ID is pulled. Let's check if the system recognises the folder via terminal.
check if the output is similar to this:
Emphasis on the "drwxr-xr-x". If yours is similar, then continue below. Otherwise please report that it didnt.
Click to expand...
Click to collapse
I am using MiXplorer file manager. I had tried Total Commander, but results are the same.
Here is the output:
HWEVA:/ $ cd /storage/emulated/0
HWEVA:/storage/emulated/0 $ ls -al | grep Ogi
ls: ./Ogi: Cross-device link
1|HWEVA:/storage/emulated/0 $
Obviously, there is no text file. ?
BTW, when I delete Ogi file on internal sdcard, put folderbind line in folder list under comment and reboot, Ogi folder on internal sdcard reappears.
Great! It seems that most probably it has something to do with the ROM, but not with the kernel. Next, I'd like for you to "cd" into it, then create a text file by running this simple line:
Now, check if the text file exists on SD Card folder, by using a file manager.
Click to expand...
Click to collapse
Output:
1|HWEVA:/storage/emulated/0 $ cd Ogi
/system/bin/sh: cd: /storage/emulated/0/Ogi: Cross-device link
2|HWEVA:/storage/emulated/0 $ cd ./Ogi
/system/bin/sh: cd: /storage/emulated/0/Ogi: Cross-device link
2|HWEVA:/storage/emulated/0 $
Thank you for your patience.
ogisha said:
I am using MiXplorer file manager. I had tried Total Commander, but results are the same.
Here is the output:
HWEVA:/ $ cd /storage/emulated/0
HWEVA:/storage/emulated/0 $ ls -al | grep Ogi
ls: ./Ogi: Cross-device link
1|HWEVA:/storage/emulated/0 $
Obviously, there is no text file.
BTW, when I delete Ogi file on internal sdcard, put folderbind line in folder list under comment and reboot, Ogi folder on internal sdcard reappears.
Output:
1|HWEVA:/storage/emulated/0 $ cd Ogi
/system/bin/sh: cd: /storage/emulated/0/Ogi: Cross-device link
2|HWEVA:/storage/emulated/0 $ cd ./Ogi
/system/bin/sh: cd: /storage/emulated/0/Ogi: Cross-device link
2|HWEVA:/storage/emulated/0 $
Thank you for your patience.
Click to expand...
Click to collapse
Sorry for the length of time i took to reply. I have been busy
Hmm.. This is not a bug, but rather an incompatibility. Huge chances that your kernel may contain modifications different from the norm. But let's see if I can workaround from the current method, since the terminal says it's a cross-device link. For this, I need a single file /proc/mounts to be inspected. Can you hand me that file, please?
I am also assuming that your kernel does support binding folders (default and expected behaviour across linux kernels).
TechnoSparks said:
Sorry for the length of time i took to reply. I have been busy
Hmm.. This is not a bug, but rather an incompatibility. Huge chances that your kernel may contain modifications different from the norm. But let's see if I can workaround from the current method, since the terminal says it's a cross-device link. For this, I need a single file /proc/mounts to be inspected. Can you hand me that file, please?
I am also assuming that your kernel does support binding folders (default and expected behaviour across linux kernels).
Click to expand...
Click to collapse
Please see what you can do.
Mounts attached.
Thank you.
ogisha said:
Please see what you can do.
Mounts attached.
Thank you.
Click to expand...
Click to collapse
After a closer look, it seems that your device really does have sdcardfs turned on!
Let's use a simple buildprop entry to turn it off, hopefully it will work (although i know this seems so simple). You may use this new beta: https://drive.google.com/open?id=0ByQKilNkFEpAcmVxbkhsaUhSRHM
TechnoSparks said:
After a closer look, it seems that your device really does have sdcardfs turned on!
Let's use a simple buildprop entry to turn it off, hopefully it will work (although i know this seems so simple). You may use this new beta: https://drive.google.com/open?id=0ByQKilNkFEpAcmVxbkhsaUhSRHM
Click to expand...
Click to collapse
It still the same like previous.
Thank you.
ogisha said:
It still the same like previous.
Thank you.
Click to expand...
Click to collapse
Please try again with a newer version: https://drive.google.com/uc?id=0ByQKilNkFEpAcmVxbkhsaUhSRHM&export=download
TechnoSparks said:
Please try again with a newer version: https://drive.google.com/uc?id=0ByQKilNkFEpAcmVxbkhsaUhSRHM&export=download
Click to expand...
Click to collapse
Still not working. :crying:
Related
Boot-Time Auto-Superlog! [12 Apr 2013]
USERS --- TESTERS --- DEVSPlumb the depths of Middle Droid with Auto-Superlog!
So…
Your device doesn't finish booting
It reboots on its own (and you may not know it)
An application or feature crashes (and you may not know it)
Generally speaking, any manually-launched app or tool could miss key events leading to random reboot or application crash.
Problem addressed with Auto-Superlog!
cm10-auto-superlog-v1.0.zip (3MB): http://www.mediafire.com/?cf5f9rq4z7p6gep
This flashable zip is tested working on my Atrix running CWM Recovery 5.0.2.0 and CM10 SuperLite. It should also work on epinter’s CM10 4.1.x builds and on close relatives. Not sure about 4.2.x yet.
In this exciting age of alpha-beta ROM testing, my lightweight Auto-Superlog, presently built on epinter’s versatile CM10 boot image (for demo purposes), can help just about anyone, whether end-user, tester or developer!
In fact it is already helping me track down abnormal battery drain and shutdown problems!
Alternatively instead of flashing the boot-time version, you can extract “auto-superlog.sh” from the flashable zip and manually execute it at run time.
Features
Automatically launches at boot-time under “class_start core” --- just after ROM filesystems are mounted, thus maximizing the likelihood of capturing key events, even if phone does not finish booting
Comprehensive log set includes: system build properties (getprop), kernel configuration file (from /proc/config.gz), kernel dmesg and system logcat --- all in sync, all in ASCII text format, and all stored in a single gzipped, time-stamped tar file on $EXTERNAL_STORAGE/auto-superlog for easy access and analysis.
Android events are quietly, nimbly and continuously streamed via kernel “dmesg” and system “logcat” commands. The dmesg log is pushed at 2-second intervals (default) with a 1MB ring buffer which is cleared on each pass. Logcat is configured to log “main” and “system” events with a generous 10MB buffer to help in discerning error trends.
Access real-time dmesg and logcat output right on your device by tapping the /data/auto-superlog directory using a (root) file explorer.
Log file contents are time stamped using absolute time ([YYYY-]MM-DD HH:MM:SS), enabling users to correlate Android events with the outside world
Filename timestamps show when your system was rebooted
Self-cleaning feature: On reboot, your most recent superlog is gzipped and archived to $EXTERNAL_STORAGE and then is removed from /data/auto-superlog so only your most recent superlog remains on the /data partition.
Shell script: auto-superlog.sh is stored under /system/bin, enabling users to extract and execute it at run-time and/or customize.
How to kill dmesg and logcat? Use the ps and grep commands: http://stackoverflow.com/questions/3117095/stopping-an-android-app-from-console (It’s a sheepish way of saying “mechanization of this feature is still in work” lol)
Instructions
Nandroid Backup current ROM (security blanket)
Flash zip if running epinter CM10 4.1.x or close relative (e.g. SuperLite)
Reboot and relax.
…OR, if you don’t want to flash the zip, but still want the run-time features of auto-superlog, simply extract /system/bin/auto-superlog.sh from zip and do this…
copy auto-superlog.sh to /system/bin (Tip: mount /system/bin as read-write (rw), then revert to ro when done)
chmod 0755 /system/bin/auto-superlog.sh
sh /system/bin/auto-superlog.sh (using Script Manager or other tool, as root)
Click to expand...
Click to collapse
After launching the script, just tap the Home button to resume other activity as the loggers are now running in background. Then you will have real-time streaming dmesg and logcat (as well as getprop and kernel config) at your fingertips --- literally.
The advantage of flashing the zip (if it’s compatible with your ROM) is that you are more likely to capture key events leading to a failed boot, random reboot or application crash.
Screenshots
Boot Image Source Code
This is the only change I made to CM10 boot.img...
Code:
ramdisk/init.olympus.rc ...
# sendust7 (12 Apr 2013)
service auto-superlog /system/bin/sh /system/bin/auto-superlog.sh
class core
# class main
# class late_start
user root
group system
# disabled
oneshot
# sendust7 (12 Apr 2013)
Documentation
dmesg: http://unixhelp.ed.ac.uk/CGI/man-cgi?dmesg+8
logcat: http://developer.android.com/tools/debugging/debugging-log.html#outputFormat
Android Encryption: http://source.android.com/tech/encryption/android_crypto_implementation.html
from Android Encryption…"This magic was accomplished by requiring all services to be in 1 of 3 groups: core, main and late_start. Core services are never shut down after starting. main services are shutdown and then restarted after the disk password is entered. late_start services are not started until after /data has been decrypted and mounted.”
Click to expand...
Click to collapse
Thoughts and Ideas: This has been a fun project so far. Time permitting, I may be able to service bug fixes and add more goodies like event filtering.
Disclaimer: Standard disclaimers apply.
Credits:Emerson Pinter (CM10 for Atrix 4g), Cyanogenmod Team
Very nice!
The OS considers the internal SD as EXTERNAL_STORAGE in assigning the env variable which is perhaps the reason you should too:
Booted without external sd mounted:
Code:
[email protected]:/ $ echo $EXTERNAL_STORAGE
/storage/sdcard0
Booted with external sd mounted:
Code:
[email protected]:/ $ echo $EXTERNAL_STORAGE
/storage/sdcard0
Possibly just tweak this part of your script:
Before
Code:
/system/bin/mount -t vfat /dev/block/mmcblk1p1 $EXTERNAL_STORAGE
After
Code:
/system/bin/mount -t vfat /dev/block/mmcblk0p18 $EXTERNAL_STORAGE
This then sends the archive to a location that will always exist (sdcard0).
I mention as I don't always have external SD mounted.
Sent from my MB860 using Tapatalk 2
Thanks sendust7
Good job !
I am currently working unsuccessfully on an application with XposedBridge and I have a lot of questions. I will start with the simple ones.
1. How can I get the debug.log file?
I cannot find the debug.log file. I have tried the phone shell as well as two adb ways :
A. adb shell data/data/de.robv.android.xposed.installer/log/debug.log
B. adb shell "su -c 'cat data/data/de.robv.android.xposed.installer/log/debug.log'"
C. adb shell cat data/data/de.robv.android.xposed.installer/log/debug.log
adb says : " No such file or directory "
The phone shell can cd to /data and /data/data but not after. Cannot ls neither of the data's. Says access denied. So does adb when I try adb ls.
The phone, Moto E XT1023, is rooted. Despite, shell cannot read some directories. I have posted a question why here but no one seems to care to answer.
I had to go to ES File Explorer. Managed to get to /data. ES says folder empty. Managed to get to Emulator/0/de.robv.android.xposed.installer or something alike. There was a subdirectory called files. Inside was the installer. No debug.log.
Searched all directories with ES for debug.log. Nothing found. I am sure many people on this forum have had these experiences. Please, reply.
2. Once I create the XposedBridge class in a separate file of the project and once I do whatever XposedBridge is supposed to do ( override methods, insert code before and or after the methods, etcetera ) the overridden methods or the methods with code run before and or after or the overridden data WILL CONTINUE TO BE OVEERRIDEN until the app exits. IS THIS TRUE?
3. Is there any simple, yet powerful and comprehensive manual or reference or, the best, a tutorial?
4. CAN I SPECIFY ANOTHER DIRECTORY FOR THE DEBUG.LOG.FILE?
5. In case I am able to make a directory \data\data manually, would this make the Xposed save debug.log there?
Please, be kind to answer these questions as I have been banging head for approximately a week.
Thanks.
OK. I am so happy I have managed to partially answer the first question which is not only related to XposedBridge but is a global root reach question for rooted phones, so I cannot even think of any other questions for now. I DO NOT HAVE A DEBUG.LOG BUT I HAVE ERROR.LOG AND I KNOW HOW TO READ THESE. Here is how in case anyone is interested :
In order to be able to reed XposedBridge log files :
1. Go to the specialised Moto E adb ( may work with a standard one too ).
2. Type :
************
* adb root *
************
to ensure root access.
3. The Dollar Sign $ must appear as the sign before commands. $ means the adb shell
environment has been entered.
4. After $, type :
******
* su *
******
5. The Sharp Sign # must appear as the sign before commands. # means root has been
entered. Once root has been entered, there is a full access to the phone. Thus :
**************************************************
* cd /data/data/de.robv.android.xposed.installer *
**************************************************
can be excuted and the directory /data/data/de.robv.android.xposed.installer will be
entered.
6. Type :
******
* ls *
******
to see the contents of this directory.
7. In case error.log or debug.log files are there, type :
*****************
* cat error.log *
*****************
and or
*****************
* cat debug.log *
*****************
to view these files.
8. Type :
********
* exit *
********
to return to the safer $ prompt.
9. Type :
********
* exit *
********
to exit adb.
Note : adb root may not run while a project is developed. The rest works, though.
I still do not have any debug.log. May be the XposedBridge lines do not run. Will check with some simple method from the manual.
Here is what I have found out, though. I have created an empty text file called debug.log on the computer and transferred the file to the main root of the device, the /sdcard directory, themn copied the file to /data/data/de.robv.android.xposed.installer/log just to see what happens. Nothing happens. The file is empty.
Here is what I have found out which may be helpful. PLEASE, COMMENT :
****
COMMANDS TO READ THE LOG FILES :
adb shell
su
cd /data/data/de.robv.android.xposed.installer/log
cat error.log
****
USE cp SOURCE DESTINATION after su shell, the # prompt, to copy files from one
directory to another on the device.
****
IMPORTANT NOTES :
****
All Xposed classes must be put in xposed_init, otherwise Android Studio 1.2 reports them as never used.
****
In built.gradle, have :
/* SSB : Added manually so the gradle builds with the XposedBridgeApi-54.jar which is
in the app -> libs but not to include the jar in the apk. */
dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
}
THESE HAVE BEEN PUT MANUALLY.
****
Update : I have been able to clean the code and have managed to find why I do not have a debug.log. This is because the two XposedBridge classes I have ( one is initialisation of zygote and the other is the work file with hooks and replacements ) are not loaded. The error.log shows : Didn't find class " package ( strts without a com. ) NameOfThePackageWithoutComDot.NameOfTheExposedClass in the NameOfThePackageWithoutComDot-2.apk "
THIS IS SAID FOR THE TWO CLASSES.
PLEASE, RESPOND.
This thread will allow you to set up init.d (and services.d) scripts on your phone so they can run at boot time.
Prerequisites
- understanding of what "init.d" scripts mean ...
- your phone must be rooted (see https://www.xda-developers.com/oneplus-6t-unlock-bootloader-root/)
- you must have a working Magisk (see https://forum.xda-developers.com/apps/magisk)
- linux knowledge (I am not a Windows guy but instructions below should easily apply to Windows / PowerShell)
- adb knowledge
If this scares you, stop reading and go play with something else.
Attached zip file contains
- a magisk.img file
- a directory with init.d scripts
- a directory with services.d scripts
You can use the scripts provided or not use (some) of them, or write your own.
What's the difference between init.d and services.d scripts?
The idea is to have 2 directories on your phone with scripts:
Code:
/system/etc/init.d/
/system/etc/services.d/
The init.d scripts are run early in the boot (when Magisk initializes). The scripts in /system/etc/services.d/ will run a bit "later", to be precise: when sys.boot_completed = true.
Important warrning: even when sys.boot_completed = true, this does NOT guarantee that /sdcard is mounted. Your script can "sleep" until /sdcard is mounted if it relies on things on /sdcard. See for example the code in /system/etc/services.d/LS99maxvolumewarning which will show how you can do that.
Scripts in init.d should NOT rely on any of the file systems being mounted !
The framework will run all scripts in parallel. So be careful that you do not write scripts which depend on eachother!
The framework will run all scripts as background processes so that they do not hinder the normal boot of your phone.
Prepare the basic setup
To use the scripts (or your own), you must first create the directories init.d and services.d; to do that open a linux shell and do:
Code:
> adb shell
$ su
# mount -o rw,remount /system
# mkdir /system/etc/init.d/
# mkdir /system/etc/services.d/
# chown 0.0 /system/etc/init.d
# chown 0.0 /system/etc/services.d
# chmod 755 /system/etc/init.d
# chmod 755 /system/etc/services.d
# sync; exit
Putting the scripts on your phone
Download the attached zip file (initd.zip); create a directory in your linux file system and unzip, e.g.
Code:
> mkdir mydir
> cd mydir
> unzip ~/initd.zip
> adb push init.d/ /sdcard/
> adb push services.d/ /sdcard/
> adb shell
$ su
# mount -o rw,remount /system
# mv /sdcard/LS00* /system/etc/init.d/
# mv /sdcard/LS99* /system/etc/services.d/
# chown 0.0 /system/etc/init.d/*
# chown 0.0 /system/etc/services.d/*
# chmod 755 /system/etc/init.d/*
# chmod 755 /system/etc/services.d/*
# sync
# exit
$ exit
Installing the magisk image on your phone
First important remark: I need to turn this really into a proper magisk "module" but I need to study that first. Open a linux shell and do:
Code:
> cd mydir
> gunzip magisk.img.gz
> adb push magisk.img /sdcard/
> adb shell
$ su
# cd /data/adb
# mv magisk.img magisk.img.orig
# cp /sdcard/magisk.img .
# chown 0.0 magisk.img
# chmod 644 magisk.img
# sync
# exit
$ exit
That's all !!! If you now reboot your phone your init.d and services.d scripts will run.
How can I tell this is working?
Each script has a log file in /data/; whose name is LS00 (for init.d) or LS99 (for services.d) appended with the name of the script. That log file is passed as "$1" into the script and the script code can write to this log file using:
Code:
LOGFILE=$1
echo "Hi I am writing to the log" | tee -a $LOGFILE
To check that the log files are there, open a linux shell and do:
Code:
> adb shell
$ su
# ls /data/LS*
And you should see something like:
Code:
16 /data/LS00blockdev 4 /data/LS99bootclean 4 /data/LS99maxvolumewarning 4 /data/LS99sysctl
4 /data/LS00governors 4 /data/LS99callrecording 4 /data/LS99network 4 /data/LS99trimcaches
4 /data/LS00kerneltweaks 4 /data/LS99cputweaks 4 /data/LS99overlays 4 /data/LS99turnoffnightmode
4 /data/LS00procgate 4 /data/LS99enablecallrecording 4 /data/LS99remounts 4 /data/LS99workqueue
4 /data/LS00readahead 4 /data/LS99hdparm 4 /data/LS99resetprop
4 /data/LS00resetprop 4 /data/LS99magiskhide 4 /data/LS99sqlite
To check the contents of the log files, do:
Code:
> adb shell
$ su
# cat /data/LS*
And you will see logging info:
Code:
>> Starting /system/etc/init.d/LS00procgate at 19700110-17:21:12
-- remounting: mount -o remount,hidepid=2,gid=3009 /proc
<< Ending /system/etc/init.d/LS00procgate at 19700110-17:21:12
>> Starting /system/etc/services.d/LS99maxvolumewarning at 20181201-07:34:00
-- slept for 4 seconds waiting for /sdcard/Android
-- disabling max volume warning
<< Ending /system/etc/services.d/LS99maxvolumewarning at 20181201-07:33:58
What's next
Write your own scripts (and share them). Note that scripts must be owned by root (chown 0.0) and have 755 linux permissions (chmod) to run.
How does it really work?
No secrets ... magisk.img is actually a magisk module which runs the scripts. To see the inner details, do the following after you have installed the magisk image and rebooted your phone:
Code:
> adb shell
$ su
# ls -l /sbin/.core/img/template/
total 12
0 -rw-r--r-- 1 root root 0 2018-03-12 21:19 auto_mount
4 -rw-r--r-- 1 root root 935 2018-08-06 17:59 post-fs-data.sh
4 -rwxr-xr-x 1 root root 498 2018-08-05 10:11 scriptwrapper*
4 -rw-r--r-- 1 root root 2750 2018-08-11 12:07 service.sh
Magisk will run the post-fs-data.sh first and service.sh later. Check the code of both of these files to understand how init.d and services.d are ran (using run-parts). If you want more details please read: https://topjohnwu.github.io/Magisk/guides.html#scripts.
Disable ALL scripts from running
If you want to disable any script from running do:
Code:
> adb shell
$ su
# touch /data/noinitrd
To undo this and get your scripts running again, do:
Code:
> adb shell
$ su
# rm /data/noinitrd
What do my init.d scripts do?
Code:
LS00blockdev: change properties of block devices (non rotational, no kernel io stats, ...)
LS00governors: set all CPU governers (to schedutil; which is actually the 6T default)
LS00kerneltweaks: a few basic kernel tweaks + stop debug of kernel modules
LS00procgate: protections against the procgate security vulnerability (thanks to @topjohnwu)
LS00readahead: change the readahead amount on logical disk devicesw
LS00resetprop: reset model, brand, manufacturer (only useful if you would want to get your phone appear externally as a Pixel; check the code)
What do my services.d scripts do?
Code:
LS99bootclean: clean junk and log files
LS99cputweaks: improve scaling governor
LS99enablecallrecording: enable call recording (must be done at every device boot)
LS99execonce: a whole series of settings; this is only executed ONCE
LS99hdparm: increase readahead on /system and /data
LS99magiskhide: hide some packages from seeing root
LS99maxvolumewarning: remove the high volume warning (I am not sure this will always work !!!)
LS99network: TCP transmit queue and congestion control
LS99overlays: enable all overlays automatically (if you use substratum then no need to enable them manually)
LS99remounts: improve file system performance of multiple partitions
LS99resetprop: increase memory used by dalvik
LS99sqlite: REINDEX and VACCUM sqlite database files (the script only runs every 3rd day)
LS99sysctl: optimize linux kernel settings and TCP/IP performance
LS99trimcaches: trim android cache files
LS99turnoffnightmode: reset the night mode to OFF (night mode conflicts with dark mode in newer Google apps)
LS99workqueue: tune kernel work queue
Thanks man I have been trying to get boot scripts to run.
jacksummers said:
Thanks man I have been trying to get boot scripts to run.
Click to expand...
Click to collapse
excuse me for the ignorance, but what is the use of this mod?
Sent from my [device_name] using XDA-Developers Legacy app
isoladisegnata said:
excuse me for the ignorance, but what is the use of this mod?
Sent from my [device_name] using XDA-Developers Legacy app
Click to expand...
Click to collapse
At the end of OP he's got a summary of what the different scripts do.
I am stuck here > unzip ~/initd.zip
It keeps saying:
1|OnePlus6T:/mydir # unzip /initd.zip
unzip: can't open /initd.zip[.zip]
Any ideas I extracted initd to the directory where my platform tools are and where I do my system updates am I supposed to extract it somewhere else? How do I create a directory in my linux shell using windows cmd promts?
kirschdog1 said:
I am stuck here > unzip ~/initd.zip
It keeps saying:
1|OnePlus6T:/mydir # unzip /initd.zip
unzip: can't open /initd.zip[.zip]
Any ideas I extracted initd to the directory where my platform tools are and where I do my system updates am I supposed to extract it somewhere else? How do I create a directory in my linux shell using windows cmd promts?
Click to expand...
Click to collapse
Looks like a simple typo "/initd.zip" implies that the file is located in the root directory. "~/initd.zip" would be in your "home" directory. Since I don't know if "/mydir" is defined as your home directory and presuming initd.zip is located there try "unzip /mydir/initd.zip" (no quotes).
Still not working
Base2 said:
Looks like a simple typo "/initd.zip" implies that the file is located in the root directory. "~/initd.zip" would be in your "home" directory. Since I don't know if "/mydir" is defined as your home directory and presuming initd.zip is located there try "unzip /mydir/initd.zip" (no quotes).
Click to expand...
Click to collapse
1|OnePlus6T:/ # cd mydir
OnePlus6T:/mydir # unzip ~/initd.zip
unzip: can't open //initd.zip[.zip]
1|OnePlus6T:/mydir # unzip /mydir/initd.zip
unzip: can't open /mydir/initd.zip[.zip]
Any ideas? How to get this working? I tried both commands to no avail.
kirschdog1 said:
I am stuck here > unzip ~/initd.zip
It keeps saying:
1|OnePlus6T:/mydir # unzip /initd.zip
unzip: can't open /initd.zip[.zip]
Any ideas I extracted initd to the directory where my platform tools are and where I do my system updates am I supposed to extract it somewhere else? How do I create a directory in my linux shell using windows cmd promts?
Click to expand...
Click to collapse
You have to create the directory mydir on your linux machine, not on your phone.
Base2 said:
Looks like a simple typo "/initd.zip" implies that the file is located in the root directory. "~/initd.zip" would be in your "home" directory. Since I don't know if "/mydir" is defined as your home directory and presuming initd.zip is located there try "unzip /mydir/initd.zip" (no quotes).
Click to expand...
Click to collapse
No, not a typo. mydir is on your PC, not on the phone !
foobar66 said:
No, not a typo. mydir is on your PC, not on the phone !
Click to expand...
Click to collapse
How do I create the directory? I'm using a windows device using adb command prompts?
kirschdog1 said:
How do I create the directory? I'm using a windows device using adb command prompts?
Click to expand...
Click to collapse
Search how to create directories in PowerShell ... I am not a Windows guru :crying:
foobar66 said:
Search how to create directories in PowerShell ... I am not a Windows guru :crying:
Click to expand...
Click to collapse
Ok thank you.ill hold off as it appears to be above my pay grade.
foobar66 said:
You have to create the directory mydir on your linux machine, not on your phone.
Click to expand...
Click to collapse
This won't work anymore as magisk doesn't use magisk.img anymore
How to change the home directory for the user root on an Android phone
When working a lot in a shell via adb on an Android phone it's usefull to be able to store some user dependent config files in the home directory of the user. So let's see how that can be implemented on a phone running Android.
Note: The config was done and tested on a phone running OmniROM (based on Android 12)
The home directory for all user used in an (adb) shell on Android is the root directory "/".
Using a home directory for more then one user is not really usefull and in addition on Android "/" is mounted read-only so more or less useless as home directory.
Therefor this should be changed . Unfortunately there is no /etc/passwd file in Android to configure the home directory for a user.
Well, there is an /etc/passwd file (probably for compatibily reasons) but it's empty:
Code:
[email protected]_I006D:/ $ ls -l /etc/passwd
-rw-r--r-- 1 root root 0 2009-01-01 01:00 /etc/passwd
[email protected]_I006D:/ $
And as far as I know there is no other config file to configure the home directory of the user in the Android OS.
So we must implement some work around to get this working.
The shell on Android behaves like normal shells on Linux and executes the file /etc/profile when starting a new session.
In Android /etc is a symbolic link to /system/etc:
Code:
[email protected]_I006D:/ # ls -ld /etc
lrw-r--r-- 1 root root 11 2009-01-01 01:00 /etc -> /system/etc
[email protected]_I006D:/ #
And in the default config there is no file called profile in that directory:
Code:
[email protected]_I006D:/ $ ls -l /etc/system/profile
ls: /etc/system/profile: No such file or directory
[email protected]_I006D:/ $
Because /system is also mounted read-only we need the magic tool Magisk again to create the file /system/etc/profile.
To create the file /system/etc/profile create these directories and files on the phone as user root (assuming Magisk is already installed on the phone):
Code:
[email protected]_I006D:/ # find /data/adb/modules/initshell/
/data/adb/modules/initshell/
/data/adb/modules/initshell/system
/data/adb/modules/initshell/system/etc
/data/adb/modules/initshell/system/etc/profile
[email protected]_I006D:/ #
and reboot the phone. After the reboot there should be the writable file /etc/profile:
Code:
[email protected]_I006D:/ # ls -l /etc/profile
-rw-rw-rw- 1 root root 1100 2022-07-14 14:51 /etc/profile
[email protected]_I006D:/ #
which is in reality the file
Code:
/data/adb/modules/initshell/system/etc/profile
Now you can edit the file /etc/profile as user root until it fullfills your requirements (be aware that all changes in that file are now persistent).
To test the changes open a new adb session (you should not close the current adb session to be able to fix an error in the profile if opening a new adb session fails).
This file can now be used to define the home directory for the user. The home directory should be on one of the writable filesystem, e.g. in /data:
Code:
# add in /etc/profile
HOME="/data/home/root"
export HOME
and the result is:
Code:
[email protected]_I006D:/ # id
uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),1078(ext_data_rw),1079(ext_obb_rw),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:su:s0
[email protected]_I006D:/ # echo $HOME
/data/home/root
[email protected]_I006D:/ #
Note that there is not really a writable filesystem for the user shell so this approach to change the home directory is mainly usable for the user root.
The file /etc/profile can also be used to init some other settings for (adb) sessions (e..g. change the PATH, etc) . This feature can be used for sessions for non-root users also.
For additional user dependent configs you can also create the file .profile in the home directory of the user; the file ${HOME}/.profile will be executed after the execution of the file /etc/profile.
Notes:
Be aware that creating a profile for the user root and changing the home directory for the user root might have some side effects on other processes using the shell!
Therefor it's recommended to use the command "tty -s" to test if the profile is executed in an interactive session:
Code:
#
# check if we're running in an interactive session
#
if ! tty -s; then
#
# this is not an interactive session - so we're just doing nothing at all
#
:
else
#
# running in an interactive session
#
...
fi
You can also check if the parent process is the adb daemon to not do anything in non-adb sessions.
Code:
ps -fp $PPID| grep adbd >/dev/null
if [ $? -ne 0 ] ; then
#
# not running in an adb session
:
else
#
# running in an adb session
...
fi
For testing purpose I suggest to open at least two shells via adb to be able to fix an error in case opening a new shell fails due to a bug in the profile.
If opening a shell session fails due to an error in the /etc/profile and you do not have another open shell either delete the file /data/adb/modules/initshell/system/etc/profile with a filemanager with root access on the phone or boot the phone from a recovery image (like TWRP) and delete or edit the file /data/adb/modules/initshell/system/etc/profile.
I initially looked at this feature to enable a persistent command history for the shell on the Android phone. But after some google searches I found out that persistent history shells are disabled for the shell binary on Android. So this will not work without recompiling the shell binary.
The attached example for the profile (rename the attached file profile.txt to profile) will use the directory /data/home/root as home directory for the user root and will not change the home directory for other users. The profile will do nothing if not running in an interactive session.
The directory /data/home/root will be created by the profile if it does not yet exist.
As always, if the config is working you should create a real Magisk Module for the profile.
The Magisk Module attached, initshell.zip, can be used to create a Magisk Module with your own profile:
To create a new Magisk Module with your own /etc/profile do:
Code:
# create an empty working directory
#
TEMPDIR="/tmp/newdir"
mkdir "${TEMPDIR}"
cd "${TEMPDIR}"
# unpack the zip file in the new directory
#
unzip ../initshell.zip
# now edit the file ${TEMPDIR}/system/etc/profile
# also (optional) edit the files config.sh and module.prop in the new directory to document your changes
# the script customize.sh from the module will be executed once when the module is installed. You might add the code
# create the home directories or any other code here
#
# and recreate the zip file
#
zip -r ../initshell.zip .
Note:
Both attached files are also available from my web site: http://bnsmb.de/My_HowTos_for_Android.html
How to make files in /system writable
In Android 12 and newer /system is mounted read-only can not be remounted read-write anymore.
Sometimes it's useful that one or more files in /system are writable (for example for develop tasks or for testing)
This can be implemented using Magisk (see How to change files in the directory /system for more details)
Example :
Make the file /system/etc/vimrc writable
Note:
In Android 12 /etc is a symbolic link to /system/etc.
Open a (adb) shell as user root and do
Bash:
# create a dummy Magisk module
#
mkdir -p /data/adb/modules/writable_system/system/etc
# copy the file that should be writable to the Magisk module directory
#
cp /system/etc/vimrc /data/adb/modules/writable_system/system/etc/
# make the file in the Magisk module directory writable
#
chmod +w /data/adb/modules/writable_system/system/etc/vimrc
Now reboot the phone.
After the reboot the file /system/etc/vimrc is writable by the user root, Example:
Code:
ASUS_I006D:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
ASUS_I006D:/ #
ASUS_I006D:/ # ls -l /system/etc/vimrc
-rw-r--r-- 0 root root 3350 2022-11-04 11:36 /system/etc/vimrc
ASUS_I006D:/ # tail -2 /system/etc/vimrc
\ | wincmd p | diffthis
endif
ASUS_I006D:/ #
ASUS_I006D:/ # echo '" Test Comment' >>/system/etc/vimrc
ASUS_I006D:/ #
ASUS_I006D:/ # tail -2 /system/etc/vimrc
endif
" Test Comment
ASUS_I006D:/ #
Only the user root can access the directory /data/adb. Therefor the files configured using this approach are only writable by the user root.
To make a file in /system writable for non-root users use this method:
Open a (adb) shell and execute as user shell:
Bash:
#
# create a directory that is writable for the user shell
#
mkdir /data/local/tmp/writable_system
mkdir /data/local/tmp/writable_system/etc
#
# copy the file that should be writable to that directory
#
cp /system/etc/vimrc /data/local/tmp/writable_system/etc
The next commands must be executed as user root:
Bash:
# create dummy Magisk module
#
mkdir -p /data/adb/modules/writable_system/system/etc
#
# create a symbolic link to the file in the writable directory in the directory with the dummy Magisk module
#
ln -s /data/local/tmp/writable_system/etc/vimrc /data/adb/modules/writable_system/system/etc
Now reboot the phone.
After the reboot the file /system/etc/vimrc is writable by the user shell, Example:
Code:
ASUS_I006D:/ $ id
uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),1078(ext_data_rw),1079(ext_obb_rw),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid),3012(readtracefs) context=u:r:shell:s0
ASUS_I006D:/ $
ASUS_I006D:/ $ tail -2 /system/etc/vimrc
\ | wincmd p | diffthis
endif
ASUS_I006D:/ $
ASUS_I006D:/ $ echo '" Test Comment' >>/system/etc/vimrc
ASUS_I006D:/ $
ASUS_I006D:/ $ tail -2 /system/etc/vimrc
endif
" Test Comment
ASUS_I006D:/ $
Important:
The writable directory can also be in a sub directory in /sdcard. But be aware that /sdcard is mounted late in the boot process so it might be that the overwritten file in /system will be used by the OS when the bind mount points to a non-existent file if using a sub directory in /sdcard.
The changes to the file done using these methods are "persistent" as long as Magisk is installed in the boot partition.
To restore the file with the original contents after each new reboot of the phone without removing the writable config open a (adb) shell as user root and execute:
Bash:
#
# restore the file /data/adb/modules/writable_system/system/etc/vimrc from the original file /system/etc/vimrc
#
# this must be done before Magisk creates the bind mounts
#
echo "cp /system/etc/vimrc /data/adb/modules/writable_system/system/etc/vimrc">/data/adb/post-fs-data.d/restore_vimrc.sh
chmod 755 /data/adb/post-fs-data.d/restore_vimrc.sh
Now the file in the dummy Magisk module will be restored with the contents of the original file from /system after each reboot
To temporary access the original file from /system just stop the Magisk daemon, Example:
Code:
ASUS_I006D:/ # echo '"Test Test' >>/etc/vimrc
ASUS_I006D:/ #
ASUS_I006D:/ # tail -1 /etc/vimrc
"Test Test
ASUS_I006D:/ #
ASUS_I006D:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
ASUS_I006D:/ #
ASUS_I006D:/ # magisk --stop
ASUS_I006D:/ #
ASUS_I006D:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
ASUS_I006D:/ #
ASUS_I006D:/ # tail -1 /etc/vimrc
endif
ASUS_I006D:/ #
Note
Stopping the Magisk daemon will disable all bind mounts done by Magisk.
Restarting the Magisk daemon will not re-create the bind mount - to re-activate the bind mount for the writable file after stopping the Magisk daemon the phone must be rebooted.
To make more then one file writable in a sub directory in /system you can also replace the complete folder using these commands as user root:
Bash:
#
# make all files in /system/etc writable by the user root
#
mkdir -p /data/adb/modules/writable_system/system/etc/
cd /system/etc
find . | cpio -pdum /data/adb/modules/writable_system/system/etc/
touch /data/adb/modules/writable_system/system/etc/.replace
Now Magisk will replace the directory /system/etc with the directory /data/adb/modules/writable_system/system/etc after the next reboot
Notes
You should test these commands with a not important file like /system/etc/vimrc before changing important files.
It is NOT recommended to use this approach on productive phones.
See How to change any file or directory using Magisk for another approach to change files on read-only mounted filesystems.
Trouble Shooting
As always: If something does not work like expected check the Magisk log file /cache/magisk.log and also check the infos in this post.
Does this method require root on device?
FormulaSea said:
Does this method require root on device?
Click to expand...
Click to collapse
yes
Is there any method don't require root?
This looks interesting. Are you using OverlayFS for this? Looks like you did quite the research on this
Read-only is boring even as root. It's time for some RW baby
FormulaSea said:
Does this method require root on device?
Click to expand...
Click to collapse
I don't know a method to do this without root access.
But you can disable the root access in Magisk after implementing the changes . You could even uninstall tne Magisk app afterwards (but not the Magisk part from the boot partition)
regards
Bernd
lebigmac said:
This looks interesting. Are you using OverlayFS for this? Looks like you did quite the research on this
Read-only is boring even as root. It's time for some RW baby
Click to expand...
Click to collapse
I don't know what exactly you mean by "OverlayFS" - I use MagiskModules to modify files in /system and as far as I know Magisk used bind mounts to implement it.
>>Read-only is boring even as root.
Correct, but if you made the changes directly in /system, they would not survive the next OS upgrade.
One of the great advantages of this feature of Magisk is that it survives an OS upgrade - so as long as the change is compatible with the installed OS version, it only needs to be done once.
regards
Bernd
Thanks it worked on the audio folders on my 7t pro but didn't work on the boot animation folder. Both folders appear in the adb though with there files. Let me know op if you figure out how to do the boot animation folder it's moved to /my_product/ instead of /system/ I see that the my product folder and boot animation appear in the adb modules like the audio folder does and I swapped files the same way as with my audio modding but the changes for boot didn't take effect.
cbomb1337 said:
Thanks it worked on the audio folders on my 7t pro but didn't work on the boot animation folder. Both folders appear in the adb though with there files. Let me know op if you figure out how to do the boot animation folder it's moved to /my_product/ instead of /system/ I see that the my product folder and boot animation appear in the adb modules like the audio folder does and I swapped files the same way as with my audio modding but the changes for boot didn't take effect.
Click to expand...
Click to collapse
/my_product is not in the list of folders supported by Magisk so that may not work
Please post the output of these commands (executed as root user):
df -h
mount
ls -ald /*
ls -lZd /my_product
and a
ls -ldZ $( find /data/adb/modules/ )
and
cat /cache/magisk.log
(or attach the log file to the post if too big)
regards
Bernd
Here is this the correct log file. Thank you for responding to me.
cbomb1337 said:
Here is this the correct log file. Thank you for responding to me.
Click to expand...
Click to collapse
can you also post the output of the OS commands listed?
I Don't know how.
It didn't let me add the log here. Sorry that's it's cut and paste I tried a few termux commands to save a log but the were blank. I don't understand how to do it right.
Edit here I managed to upload the log to drive
https://drive.google.com/uc?id=1uWurf_462b5uLC_D21SFcgLcBWiXQZOn&export=download
bnsmb said:
can you also post the output of the OS commands listed?
Click to expand...
Click to collapse
Linefeeds are missing in that file so it's very hard to interpret the file contents correct
Can you do in a adb shell on the phone:
Bash:
(
set -x
set -v
su -
echo
df -h
echo
mount
echo
ls -ald /*
echo
ls -lZd /my_product
echo
ls -ldZ $( find /data/adb/modules/ )
echo
) > /sdcard/Download/oscmds.log 2>&1
then
Bash:
gzip /sdcard/Download/oscmds.log
and post / upload the file
/sdcard/Download/oscmds.log.gz
regards
Bernd
and
Here is the gzip I wasn't sure what was going on after entering that first command the termux was frozen for a few minutes. Also With the folders in the module folder and them being a copy of the original folder is it ok to delete them as a whole folder to remove the rw and revert it of needed. I tried it and didn't see any issues doing it but wanted to know if it reverted it properly and does deleting the module folders make me lose anything original that was in it or is my stock stuff safe because it's through magisk.
cbomb1337 said:
Here is the gzip I wasn't sure what was going on after entering that first command the termux was frozen for a few minutes. Also With the folders in the module folder and them being a copy of the original folder is it ok to delete them as a whole folder to remove the rw and revert it of needed. I tried it and didn't see any issues doing it but wanted to know if it reverted it properly and does deleting the module folders make me lose anything original that was in it or is my stock stuff safe because it's through magisk.
Click to expand...
Click to collapse
Looks like /my_product is a directory in the root filesystem but on the other hand there is a mount point called /mnt/vendor/my_product so I'm not sure about that.
If /my_product is really only a separate directory in the root filesystem the only method to change it is to manipulate the ramdisk used for booting the phone (only if the phone is using a ramdisk, of course).
Can you check if there are other directories called my_product:
find / -type d -name my_product 2>/dev/null
And, if there are any, compare the files in that directory with the files in the directory /my_product?
regards
Bernd
The only folder that has the same boot animation files is the /dev/ ones and the mnt one like you said.
It's all good if it can't be done i just found a magisk module before which works for flashing my boot animation
cbomb1337 said:
The only folder that has the same boot animation files is the /dev/ ones and the mnt one like you said.
Click to expand...
Click to collapse
Then it can't be done using the standard Magisk feature for making r/o mounted filesystems read-write.
cbomb1337 said:
It's all good if it can't be done i just found a magisk module before which works for flashing my boot animation
Click to expand...
Click to collapse
OK, do you have the URL?
And you could just check the contents of the zip file with the Magisk Module on how it's implemented
regards
Bernd
bnsmb said:
Then it can't be done using the standard Magisk feature for making r/o mounted filesystems read-write.
OK, do you have the URL?
And you could just check the contents of the zip file with the Magisk Module on how it's implemented
regards
Bernd
Click to expand...
Click to collapse
I read the module it mentions binding. I don't understand none of it :/ I upload the module here and removed the boot animation to make it small.
cbomb1337 said:
I read the module it mentions binding. I don't understand none of it :/ I upload the module here and removed the boot animation to make it small.
Click to expand...
Click to collapse
Cool -- that's the solution I also found in the meantime (and successfully tested it on my Zenfone 8)
In principle the module does for the bootanimation file what Magisk does if you replace some directories or files in /system
I will write a general HowTo how that works today or in the next days
regards
Bernd