Hello everyone!
since some time ago I was customizing the ROM of Android 5.0. Everything was in order while I didn't try to change the system files. Obviously after flashing device refuse the normal boot and stacked on boot screen.. The reason was selinux context which I've never applied.
The process is:
1. Mount the ROM as EXT4
2. Add/Change files
3. Change the permissions
4. Unmount and flash...The question is:
How to label and chcon the newly added files with Android's default context in a mounted EXT4 image?
PS: Not sure is the right forum. Please suggest a solution.
Thanks!
dFrem said:
Hello everyone!
since some time ago I was customizing the ROM of Android 5.0. Everything was in order while I didn't try to change the system files. Obviously after flashing device refuse the normal boot and stacked on boot screen.. The reason was selinux context which I've never applied.
The process is:
1. Mount the ROM as EXT4
2. Add/Change files
3. Change the permissions
4. Unmount and flash...
The question is:
How to label and chcon the newly added files with Android's default context in a mounted EXT4 image?
PS: Not sure is the right forum. Please suggest a solution.
Thanks!
Click to expand...
Click to collapse
What do u mean u mounted the ROM ext4? The file system should have been defined upon install. If u changed the file system of your system partition I would assume you wiped you accidently wiped the installed os . Selinux status could affect boot but only if you did something that requires permissive status (a custom kernel is a good ready example of the type of flAsh that would need selinux on permissive). Ok so let's assume u didn't mean ROM . You meAnt system partition and you naturraly mounted that (system) as R/W . What permissions did you set on file . 644 is the correct answer if you were trying to install as system file. Wht was it you flashed? It's probably an easy fix bud . Just need more info
mojoswagger1980 said:
What do u mean u mounted the ROM ext4? The file system should have been defined upon install. If u changed the file system of your system partition I would assume you wiped you accidently wiped the installed os . Selinux status could affect boot but only if you did something that requires permissive status (a custom kernel is a good ready example of the type of flAsh that would need selinux on permissive). Ok so let's assume u didn't mean ROM . You meAnt system partition and you naturraly mounted that (system) as R/W . What permissions did you set on file . 644 is the correct answer if you were trying to install as system file. Wht was it you flashed? It's probably an easy fix bud . Just need more info
Click to expand...
Click to collapse
@mojoswagger1980 Thanks for answering. My bad, of course meaning is to mount "system.img" and not the ROM. Will explain.
The image is mounted, adding busybox into system/xbin, chmod 644, (automatically set owner root:root). As expected ls -Z is showing "?" for system/xbin/busybox...
Not changing anything more, flashing this image. File is not accessible or doesn't exists.
No doubts that if I am doing "chcon ubject_r:system_file:s0 system/xbin/busybox" it says first relabel the file... Relabel says there is no such type, user, etc...
What can I do in this case?
PS: Setting permissive 1 with inject-sepolicy doesn't help. May be I am doing something wrong here. Please suggestions.
Related
Hey there?
I've got a question which I can't seem to find anywhere else and YES I have searched this forum and google. However, I may miss it.
Anyway, I've mapped my android phone as a network drive using Samba and changed the smb.conf file to show the System Root directory as well. However, system root is default set as R/O so to mange files USING my computer I need to change the permission to R/W using a file manager (such as root explorer). This is annoying, as I have to keep doing this in order to write to certail directories.
What I wish to do is create a massive guide on all of this to help out the community, however I need one little bit of information.
I would like the / directory (root) to be mounted as R/W as default so that I can quickly edit files on my PC without having to constantly change it to R/O.
If this has been answered before, I do apologize.
Thanks in advance.
Regards,
xxSHABSxx
EDIT:
To make things a bit clearer.
I want something that will automatically mount my phone's root dir into rw upon boot, without custom apps/having to manually mount as rw everytime it reboots. And yes I understand there are apps that do this.
Yes, the root file system is read-only, but it's also volatile. It's restored from the initramfs in the boot image each time you reboot the phone, so only mounting it writeable, doesn't do you very much anyway.
In /init.rc you find a line:
Code:
mount rootfs rootfs / ro remount
This remounts your root read-only. Remove this, and it'll stay writeable. But again, all edits to the root file system are volatile. To change this, you must flash a new boot.img
An easier way would be a root-app remounting it writable again after boot.
kuisma said:
Yes, the root file system is read-only, but it's also volatile. It's restored from the initramfs in the boot image each time you reboot the phone, so only mounting it writeable, doesn't do you very much anyway.
In /init.rc you find a line:
Code:
mount rootfs rootfs / ro remount
This remounts your root read-only. Remove this, and it's stay writeable. But again, all edits to the root file system are volatile. To change this, you must flash a new boot.img
An easier way would be a root-app remounting it writable again after boot.
Click to expand...
Click to collapse
Ahh I figured as much, since Google didn't offer any solutions to me. And flashing is way much more effort than simply having an app that does it for you.
Anyway thanks for the reply!
xxshabsxx said:
Ahh I figured as much, since Google didn't offer any solutions to me. And flashing is way much more effort than simply having an app that does it for you.
Click to expand...
Click to collapse
Or do like I did, move the root to a real ext3 non-volatile file system instead.
How do I add scripts/tweaks to my rom properly? For ex. I want to add the operation kill joy script to my rom which is build from kitchen.
As a general rule of thumb, you would need to mount the /system as RW and the script would be placed into /system/etc/init.d folder with the correct permissions set and then reboot to take effect. Depending on the phone and rom, there might need to be other things done.
es0tericcha0s said:
As a general rule of thumb, you would need to mount the /system as RW and the script would be placed into /system/etc/init.d folder with the correct permissions set and then reboot to take effect. Depending on the phone and rom, there might need to be other things done.
Click to expand...
Click to collapse
No, I mean from a dump rom that I'm editing right now thru the android kitchen. I can add tweaks thru copying those files to the system but I dont feel the tweaks when I flashed them with the rom itself.
Clairelicious said:
No, I mean from a dump rom that I'm editing right now thru the android kitchen. I can add tweaks thru copying those files to the system but I dont feel the tweaks when I flashed them with the rom itself.
Click to expand...
Click to collapse
Gotcha. You might find this article helpful then:
http://apcmag.com/how-to-make-your-own-android-rom-part-4.htm
Hello, i think i made a big mistake, on my phone with root explorer i was unable to mount / and then i tried to mount /system into read only, i remember that i ticked "owner" "group" and "other" but only on read, and my phone just freezed and now the screen is on but it is black and the navigation buttons are on too, please help me
skip
Go to twrp, mount system, go-to inbuilt file manager and chmod 755 the system folder and reboot, or Dirty flash the firmware will do the job.
Next time, do nand-backup before perform sny changes to system. or would be better don't messed up with root partition.
R324D said:
Go to twrp, mount system, go-to inbuilt file manager and chmod 755 the system folder and reboot, or Dirty flash the firmware will do the job.
Next time, do nand-backup before perform sny changes to system. or would be better don't messed up with root partition.
Click to expand...
Click to collapse
You are sure it is going to work ?
Yakia said:
You are sure it is going to work ?
Click to expand...
Click to collapse
Lol
I don't know man, you could try. I'm not a magician...
Soooo little info you provided, I don't know what device you mentioned above? Rooted/unrooted? Custom rom/stock rom? Twrp installed/uninstalled? Almost zero info :laugh:
But basically, yes it'll work. Just do it..
R324D said:
Lol
I don't know man, you could try. I'm not a magician...
Soooo little info you provided, I don't know what device you mentioned above? Rooted/unrooted? Custom rom/stock rom? Twrp installed/uninstalled? Almost zero info :laugh:
But basically, yes it'll work. Just do it..
Click to expand...
Click to collapse
I actually have twrp installed and fully functionnal, but the phone won't boot on os, when i try to boot, it always shows me recovery, and i precise that in /system there is no file, its empty, i don't know why but when i go to storage info i see that the system partition takes 4gb why ? If in file explorer /system is empty, why system takes 4gb ? Maybe it's not really empty ? Anyway i just need help please
Yakia said:
I actually have twrp installed and fully functionnal, but the phone won't boot on os, when i try to boot, it always shows me recovery, and i precise that in /system there is no file, its empty, i don't know why but when i go to storage info i see that the system partition takes 4gb why ? If in file explorer /system is empty, why system takes 4gb ? Maybe it's not really empty ? Anyway i just need help please
Click to expand...
Click to collapse
I tried to help you here, but clearly you didn't read my previous comment.
Boot into TWRP (you said you have it installed), and you have to MOUNT SYSTEM first, or it'll just show you an empty folder without file.
R324D said:
I tried to help you here, but clearly you didn't read my previous comment.
Boot into TWRP (you said you have it installed), and you have to MOUNT SYSTEM first, or it'll just show you an empty folder without file.
Click to expand...
Click to collapse
Where do i mount system ? Sorry if i'm maybe annoying i just want to be sure that i will not fail
Yakia said:
Where do i mount system ? Sorry if i'm maybe annoying i just want to be sure that i will not fail
Click to expand...
Click to collapse
Just boot into twrp, you'll see mount menu as soon as you enter the twrp recovery. Enter mount and check system.
R324D said:
Just boot into twrp, you'll see mount menu as soon as you enter the twrp recovery. Enter mount and check system.
Click to expand...
Click to collapse
When i tick system, i have no "mount" button, i only have a "disable mtp" button, why ? I can give you screens if you want
Hello. I installed emui 9.1 on my mate20pro with the dload method. I unlocked the bootloader again and rooted the system with patched recovery. The phone is rooted, but the system partition remains in ro. I have tried various apps to mount the system in rw, but without success. I have also tried some commands found on the net both through adb and emulator, but nothing to do. I have also tried using rootexplorer which has been granted root permissions, but fails to modify anything, nor to insert or delete files within the system folders. What can be done?
ernia66 said:
Hello. I installed emui 9.1 on my mate20pro with the dload method. I unlocked the bootloader again and rooted the system with patched recovery. The phone is rooted, but the system partition remains in ro. I have tried various apps to mount the system in rw, but without success. I have also tried some commands found on the net both through adb and emulator, but nothing to do. I have also tried using rootexplorer which has been granted root permissions, but fails to modify anything, nor to insert or delete files within the system folders. What can be done?
Click to expand...
Click to collapse
it's the new filesystem called erofs (Extendable Read-Only File System)
So there's nothing to do?
Sorry OP if this is off topic , but its about magisk and root in 9.1
I have the "system partition remains in ro" issue too , its annoying yes , but I have a bigger problem
When "rooted" , the phone app ( dialer ), and the contacts app both get broken and crash .. So I have to fastbootflash twrp and lose root to make those apps to work normally again
Anyone with the same problem ?
I need root so I can change and use the font ( I like ) with a magisk module
ernia66 said:
So there's nothing to do?
Click to expand...
Click to collapse
Magisk can already 'replace on the fly' file from /system systemless-y.
It dies already support erofs.
Check Magisk documentations.
There is also a way to mount custom erofs partition....
which is?
ernia66 said:
which is?
Click to expand...
Click to collapse
Build your own erofs partitions (cf. erofs.mkfs)
Unmount stock ones and mount yours.
I just did some test 48h ago on erofs /cust and it seems to work...
-Mounting other file system type on same folder could even work !
oslo83 said:
Build your own erofs partitions (cf. erofs.mkfs)
Unmount stock ones and mount yours.
I just did some test 48h ago on erofs /cust and it seems to work...
-Mounting other file system type on same folder could even work !
Click to expand...
Click to collapse
Unfortunately I am not able to do it
:crying:
pvillasuso said:
Sorry OP if this is off topic , but its about magisk and root in 9.1
I have the "system partition remains in ro" issue too , its annoying yes , but I have a bigger problem
When "rooted" , the phone app ( dialer ), and the contacts app both get broken and crash .. So I have to fastbootflash twrp and lose root to make those apps to work normally again
Anyone with the same problem ?
I need root so I can change and use the font ( I like ) with a magisk module
Click to expand...
Click to collapse
use search button pls, you will find the solution already posted
ilos said:
use search button pls, you will find the solution already posted
Click to expand...
Click to collapse
Shhh
Here Rootexplorer paying app does not help writing on erofs partitions...
- Or did you meant something else ?
Magisk Doc. :
https://topjohnwu.github.io/Magisk/
So far, out-of-the-box, Magisk is already ready to replace systemless-ly files and paths on /system easily when used with modules.
-Module just need a a small tweak to add Magisk systemless-ly compatibility to other erofs partitions like /cust
Another way would be to bind or mount...
ilos said:
use search button pls, you will find the solution already posted
Click to expand...
Click to collapse
Wow , what , where ???
I did search but maybe I didnt use the right keywords for such an specific issue
Any extra help , would be very appreciated !
oslo83 said:
Build your own erofs partitions (cf. erofs.mkfs)
Unmount stock ones and mount yours.
I just did some test 48h ago on erofs /cust and it seems to work...
-Mounting other file system type on same folder could even work !
Click to expand...
Click to collapse
I'd like to create my own partition but I don't know how to do it. Is there any online guide for beginners that I can try?
oslo83 said:
Shhh
Here Rootexplorer paying app does not help writing on erofs partitions...
- Or did you meant something else ?
Click to expand...
Click to collapse
my reply was not for you but for the off topic before my reply: contact, ph app and message force close after root.
as I said, there is already a solution about force close.
Anyway I can only write in /system/etc and some over folders
oslo83 said:
Build your own erofs partitions (cf. erofs.mkfs)
Unmount stock ones and mount yours.
I just did some test 48h ago on erofs /cust and it seems to work...
-Mounting other file system type on same folder could even work !
Click to expand...
Click to collapse
Hi, I saw that you managed to get a custom erofs partition mounted using magisk. I was wondering if the same could be done for the/product folder because that would allow me to fix the DPI scaling issues found on EMUI 9.0-9.1. Would it be possible to see the code for your magisk module?
Ok, So.
After having a look at what I did with this WorkInProgress...
So far there is 2 main way I thought about and played with:
Method A
A1/
Using the mkfs.erofs tool to make your custom erofs partition and mount it over the original one. (mayne umount it before)
Thanks @ph03n!x for his work on mkfs.erofs.
Thanks @ante0 for his android arm build.
A2/
I did not yet tryed to flash via fastboot or adb these modded erofs images.
Method B
What I'm actually doing is just mounting systemless-y with a magisk module whole folders over erofs one ;
In post-fs-data.sh, I'm doing:
mount -o bind $MODDIR/cust /cust
mount -o bind $MODDIR/version /version
With a ~150MB custom /cust it is working ; It should be tryed/perfected for bigger folders.
Another way, to not replace/spoof the whole folders could be to mount the whole list of custom files at their respective path (-to be tested)
PS: I'm not sure if update-binary module's file should be modded with some:
mount /cust 2>/dev/null
@ line 42
Sources:
https://forum.xda-developers.com/huawei-p30-pro/how-to/erofs-mounting-accessing-img-t3944193
oslo83 said:
Ok, So.
After having a look at what I did with this WorkInProgress...
So far there is 2 main way I thought about and played with:
Method A
A1/
Using the mkfs.erofs tool to make your custom erofs partition and mount it over the original one. (mayne umount it before)
Thanks @ph03n!x for his work on mkfs.erofs.
Thanks @ante0 for his android arm build.
A2/
I did not yet tryed to flash via fastboot or adb these modded erofs images.
Method B
What I'm actually doing is just mounting systemless-y with a magisk module whole folders over erofs one ;
In post-fs-data.sh, I'm doing:
mount -o bind $MODDIR/cust /cust
mount -o bind $MODDIR/version /version
With a ~150MB custom /cust it is working ; It should be tryed/perfected for bigger folders.
Another way, to not replace/spoof the whole folders could be to mount the whole list of custom files at their respective path (-to be tested)
PS: I'm not sure if update-binary module's file should be modded with some:
mount /cust 2>/dev/null
@ line 42
Sources:
https://forum.xda-developers.com/huawei-p30-pro/how-to/erofs-mounting-accessing-img-t3944193
Click to expand...
Click to collapse
I'm rather new to this trying to do something similar on my EMUI9.1 using Magisk, I'm having a problem that i can replace anything in most other folders without much problem like /etc/ for example, but when i try to substitute /vendor/, whatever i put it the folder does not only fail to get substituted, it even disappears from the $MODDIR/system/vendor folder upon restart!
I.e. let's say I create a new file in $MODDIR/system/etc. Upon restart i'm successfully seeing that same file appear /etc.
However when I create a new file under $MODDIR/system/vendor, Upon restart i'm not seeing that under /vendor. ALSO the file is gone from $MODDIR/system/vendor like it was never there.
Any idea what is happening? I've also tried manually mounting in the post-fs-data.sh, where i put the following:
mount -o bind $MODDIR/system/vendor /vendor
That actually caused my system to freeze on the loading screen. I had to reset magisk to non-modded settings in order to get it to run again.
Any help's appreciated.
pvillasuso said:
Sorry OP if this is off topic , but its about magisk and root in 9.1
I have the "system partition remains in ro" issue too , its annoying yes , but I have a bigger problem
When "rooted" , the phone app ( dialer ), and the contacts app both get broken and crash .. So I have to fastbootflash twrp and lose root to make those apps to work normally again
Anyone with the same problem ?
I need root so I can change and use the font ( I like ) with a magisk module
Click to expand...
Click to collapse
i got the solution of above problem from this https://forum.xda-developers.com/huawei-p30-pro/how-to/guide-magisk-root-p30-pro-bl-code-t3938285
Hi I have almost the same issue after updating to EMUI 9.1 the phone hardbricked. It only shows as fastboot on my PC I tried flashing but not sending the img files please help
Build.prop file accidentally got empty and haven't rebooted yet. Any ways to restore it?
Am i screwed?
You have a customer recovery? Then you can dirty flash your rom
I definitely would have done that if i did.
But TWRP was never released for my phone (poco x3 gt)
Depends the device and android version I guess...
I would do getprop and edit the output to build.prop form.
Notice to chmod the file correctly, 644 or whatever..
I think you can reboot safely because build.prop is inside super partition and therefore read-only.
of course you can download stock ROM from xiaomifirmwareupdater and extract build.prop from super.img, but it's more easy to flash super.img from fastboot.
aIecxs said:
I think you can reboot safely because build.prop is inside super partition and therefore read-only.
of course you can download stock ROM from xiaomifirmwareupdater and extract build.prop from super.img, but it's more easy to flash super.img from fastboot.
Click to expand...
Click to collapse
Nvm my phone just got an OTA update.
I just have to restore the root now
aIecxs said:
I think you can reboot safely because build.prop is inside super partition and therefore read-only.
Click to expand...
Click to collapse
And it's empty like how? Weird crap anyway... ok now, so who cares...
Idk but /system /vendor /product /system_ext /odm are ro dynamic partitions inside super partition, either OP did re-duplicate blocks with e2fsck -E unshare_blocks and disabled avb/dm-verity to allow remount rw / system_root (would break OTA), or it simply wasn't written to build.prop at all (magisk systemless overlay)? "empty" could also mean does not exist/no permissions...
https://github.com/Yuyuko1024/device_xiaomi_chopin/blob/lineage-18.1/rootdir/etc/fstab.mt6891
TWRP is available btw
https://forum.xda-developers.com/t/twrp-unofficial-3-6-0-poco-x3-gt-redmi-note-10-pro-5g.4369207