Empty file in /vendor or /system after creating or modifying file - General Questions and Answers

Hi,
I have a rooted Galaxy S21 with Magisk installed. When creating or modifying a file in the /vendor or /system folders, (after changing the permission from read-only to read-write and afterwards back) the file gets empty (size 0) and there is no way of reversing the contents of a modified file, that got empty after modifying it. Does anyone know why? I just want to know the reason, why the files get empty. I did not find anywhere in the internet the reason behind it. Does it have something to do with dm-verity?
Btw: I know already that you can create a Magisk Module to fix this
Best regards

Related

how can i write a file to the / directory

i want to save a file to the / directory of my phone.
when using adb in recovery mode with $su and mount -a, it seems as if i'm able to us cp to move a file to it, ls shows the file afterwards.
but after booting, the file is gone.
i tried it with a update.zip, same result.
anybody has an idea why this is so and if there is a solution to my problem?
thanks
use root explorer from the market....you can simply copy the file you need to the "/" directory with this app!
I think / is in RAM. There are system and data partitions on internal flash, but there isn't / one, right?
@androgiallo i don't know about root explorer, bur SU File Manager & Terminal couldn't do the trick ...
@Brut.all to be honest, i don't know what you're talking about ... does your reply mean it's futile or rather that there might be a solution?
btw, thanks for maps[brut] and even more for apktool.
der_bert said:
@Brut.all to be honest, i don't know what you're talking about ... does your reply mean it's futile or rather that there might be a solution?
Click to expand...
Click to collapse
I mean "/" isn't persistent - I think it is created in the RAM when you turn on your device, then you could change its contents, but after rebooting it's gone.
For sure there is a way to install something there. If I'm right about that RAM, then there should be somewhere some image of initial contents of "/" partition (they are copied to RAM at boot) - probably in boot.img . So it's possible, but not that easy as just copying a file to "/".
These are just my guesses, maybe I'm wrong.
Ahh and why do you want to place some file to "/"? Why not to e.g. /data/?
i use a keyfile for my password manager and i have to enter the path to it manually every time i open the database, so i want to keep the path as short as possible ...

[Help] Changes to /system won't stick, even after mounting as rw

I've posted about this on StackExchange here (http://android.stackexchange.com/q/157846/126804) but it seems no one can/bothers to answer it. More details are available in the link.
I'm currently trying to convert some user apps into system apps. I've successfully moved the apps into /system/app by making a NAND image and mounting it on Linux, but it throws an error when I try to launch those apps (ClassNotFoundException, something about missing dex). I've already set the permissions the same as the other apps inside /system/app.
Another thing that I've noticed is that I can make any change to /system (copying files, editing, renaming, etc.), but everything gets wiped after a reboot. The same happens with another partition named /custpack (this is what the OEM uses to fill the phone with boatware). I've also tried to place the apps there, but same thing.
How can I debug this?

No longer able to copy files to /System

Recently had some issues with my device that caused me to to come back from a soft brick. Since then I have not been able to copy or replace files in the /System directory.
Items that have been tried and do not result in access:
Re-flash ROM (RR)
Taken back to stock image and then Re-flashed ROM (RR)
Flashed a new version of Magisk
Tried mounting the /system and making rw
Used RootExplorer and ES to change permissions to rw (chmod 777)
With all these, I try and overwrite files in system and they fail. Items with non conflicting names will appeared moved, but upon reboot all files are missing.
Ultimately what I am trying to do is move additional .ogg files into the media folder within system.
Any and all help appreciated.
Edit: Finally was able to mount /system and replace/add files after fully uninstalling Magisk and then flashing Magisk-v16.1(1610).zip
If I understand correctly, you can't modify /System with Magisk. With SuperSU, you can.
shopealope said:
If I understand correctly, you can't modify /System with Magisk. With SuperSU, you can.
Click to expand...
Click to collapse
yes you can modify /system with magisk. I do it all the time. Usually delete some aosp apps I don't need and they are in system/apps.

I Can't Get Root Back

I have a Motorola Edge (regular not +) running LineageOS 17.1 (20210528). I had it rooted and decided I wanted to use the hosts file for ad blocking. I couldn't figure out how to get the OS to allow me to modify the host file. While I was doing so, I some how corrupted to OS and couldn't boot into it. That was easily fixed by flashing the the OS, but now I can't get root back. When I reboot after I flash the patched boot.img (to both partitions), I get "Can't load Android system. Your data maybe corrupt..." (This happens when I try to boot into both partitions). Before I see the error message, it goes into a bootloop.
I'd also like to know how to modify the hosts file.
Thanks
Heat84 said:
I'd also like to know how to modify the hosts file.
Click to expand...
Click to collapse
Once phone is rooted
1. You mount Android's directory /system/etc as RW
2. Pull out the hosts file what is located therein to PC
3. Edit the hosts file according to your needs
4. Make sure hosts file gets saved in UNIX-file format
5. Push back the hosts file to Android's /system/etc directory
6. Make hosts file RW
Thanks. Any clue about the rooting problem?
I forgot to mention that I patched boot.img with Magisk.
TWRP has a file system repair function. Does that have anything to do with this?

even with root no write permissions in the file browser.

I need your help, I successfully rooted my LG Velvet 5G with TWRP and Magisk. Now I want to edit files with a root browser / file manager. But it doesn't work with a single file browser despite root rights! If I want to change xml files, it does not work in spite of the set write and read rights! Even if I extract the XML and edit it on the PC and then want to insert it back into the system, it is there, but it is then empty. Is there still write protection in spite of root? It's Android 10. Please help me. best regards
The partition where the files you want to operate on as 1st thing of all things must be mounted as RW.
Many thanks for the answer. How do I install the source code (kernel) I haven't done it yet. can it be because of that? mount as rw is not successful. Here are the instructions, did I forget something? Https: //forum.xda-developers.com/t/recovery-3-5-0-caymanlm-lm-g900em-unofficial-twrp-for-lg-velvet-5g. 4193275 /

Categories

Resources