[ROOT]Gaining write access on system partition - Xperia Z1 Compact General

The latest update to .368 restricts access to /system, in particular 'mount -o remount,rw /system' won't give write access.
With the SuperSU 'supolicy' tool and a current busybox there is an easy way around the protection:
Code:
/system/xbin/supolicy --live \
"allow init_shell unlabeled file {execute execute_no_trans}"\
"allow {init_shell kernel} {device unlabeled mmc_block_device} blk_file {getattr read write open ioctl}"\
"allow init_shell kernel process setsched"\
"allow init_shell {rootfs labeledfs} filesystem {mount umount remount}"
mknod /dev/loop2 b 7 2
losetup /dev/loop2 /dev/block/mmcblk0 -o 96468992
mount -t ext4 /dev/loop2 /system
The number in the losetup command is the position of the system partition in bytes in the internal memory. (This number in blocks (bytes = blocks * 512) is displayed in the expert mode of fdisk)
This works because we do not use the device corresponding to the system partition but construct an equivalent device.

Chainfires adbd Insecure app. Try the app first but if you still can't mount and push files read this thread - [HOW TO]Make your favorite kernel adbd insecure to run ADB as root on /system
Click to expand...
Click to collapse
I can now just adb remount and have access to the system.

I could not write to /system because I somehow lost the XZDualRecovery during the last update. When installed that does the magic at startup and enables a "remount,rw" of /system. In particular it has nothing to do with .368 as I initially suspected.
The flashable zip of the XZDualRecovery contains the necessary scripts and modules.
The method proposed in my initial post has the advantage, that it builds on (heavily used) features of the (Linux) kernel and is independent of the kernel version. Kernel modules on the other hand often only work with the kernel they were compiled for.

Far from an expert, so please let me know what I'm missing. Ran all commands successfully, rebooted, but still seems like no system rw access. Does this actually create that access, or does this only enable the ability to get access, and now there's another step? Thanks

Those commands grant immediate write access, but this is not persistent.
If you need a persistent solution, you should install the XZDualrecovery (which you should do anyway!).
Then a "mount -o remount,rw /system" gives you write access.

njhuiz said:
Those commands grant immediate write access, but this is not persistent.
If you need a persistent solution, you should install the XZDualrecovery (which you should do anyway!).
Then a "mount -o remount,rw /system" gives you write access.
Click to expand...
Click to collapse
Thanks, I'll give it a try, (switched ROMs at the moment, but not for long).

I have an unlocked Bootloader, root (working!) and XZDualRecovery. I' running prerooted 5.1 Android Stock ROM. I can't write to system... I tried many commands via ADB.
Is there any workaround?

FrikandelChris said:
I have an unlocked Bootloader, root (working!) and XZDualRecovery. I' running prerooted 5.1 Android Stock ROM. I can't write to system... I tried many commands via ADB.
Is there any workaround?
Click to expand...
Click to collapse
This works for me - [2014.11.10][ROOT] adbd Insecure v2.00, install it, tick Enable insecure adb, then run...
Code:
[B]adb remount[/B]
...and that should allow you.

mount -o remount,rw /system
Works for me on 5.1 with XZDualRecovery installed (locked BL, Xposed installed, Linux adb host).

I just spent a long time trying to get write access on my Z1C, too. I'm on MX ROM and wanted to debloat some of the software.
Turns out I just had to set the SE Linux from Enforced to Permissive, then using the mount -o remount,rw /system went fine.
Code:
su -c setenforce 0
mount -o remount,rw /system
exit
EDIT:
The "su -c setenforce 0" should make the change to Permissive permanent. Will check.
EDIT 2:
I had to get the app SELinuxModeChanger (http://forum.xda-developers.com/showthread.php?t=2524485) in conjunction with the adbd Insecure app to finally get it to work reliably, now...

I tried all the solution in this post but I failed every time... Someone to explain me how I have to do?
Envoyé de mon D5503 en utilisant Tapatalk

xander59 said:
I tried all the solution in this post but I failed every time... Someone to explain me how I have to do?
Envoyé de mon D5503 en utilisant Tapatalk
Click to expand...
Click to collapse
Did you try all of them, (terminal commands in op, adb insecure app, mount -o remount command, selinux permission change..)? If so, and you still can't rw, I'd say it might be a problem with your ROM. I have used RockZ1 and MX ROM recently, and initially had issues, but at least one of these things worked for me.

In fact, I read again the topic and I have the version 21 of dual recovery, so I have the r/w permission... But i can't still see an app when I'm moving its to /system/app and set right permission
Envoyé de mon D5503 en utilisant Tapatalk

With a root browser or a terminal app you should be able so see all files... which app did you use?

xander59 said:
In fact, I read again the topic and I have the version 21 of dual recovery, so I have the r/w permission... But i can't still see an app when I'm moving its to /system/app and set right permission
Envoyé de mon D5503 en utilisant Tapatalk
Click to expand...
Click to collapse
Not sure about that... I've definitely had apps that won't install or won't open before. I'm not sure what makes something compatible or not. Maybe email developer.

It was an issue to kill the app before moving it to system app
Envoyé de mon D5503 en utilisant Tapatalk

SGP621-RICDefeat
The SGP621-RICDefeat.zip will work on latest .216 stock. It's not a flashable zip but it contains a install.bat file, wich will remove the write to system protection. Then you can download an app from play store to mount system as RW and RO.
Don't remember where i found it though, but it was somewhere in the Z1 compact forum.

XperienceD said:
This works for me - [2014.11.10][ROOT] adbd Insecure v2.00, install it, tick Enable insecure adb, then run...
Code:
[B]adb remount[/B]
...and that should allow you.
Click to expand...
Click to collapse
well when i try to tick the enable insecure adb it says could not patch,,
i am currently on 14.6.A.1.236

ok well kingroot saves the day.,

Look at this. Worked for me. Very easy. http://forum.xda-developers.com/z3-...-sgp621-lollipop-23-1-0-690-noba-ftf-t3058400

Related

Rooted Hero Fails adb remount, can't move files from SD

I rooted my hero last night and tried out a few different ROMs but eventually decided to revert to stock and make some manual changes. I used nandroid to restore to just after the root (1.56.651.2). I was able to remove some apps using adb, but the adb remount command fails (permission denied), and I'm unable to push a new bootscreen on to the phone. I also tried a Root File Manager and pre-kitchen as alternatives for the bootscreen, and neither one works. The Root Manager won't paste the files from SD into /system/media/ and pre-kitchen just reboots the phone.
Any suggestions?
Any chance this has something to do with downloading only up to SDK Platform 1.5? I'm at a total loss. I RUU'd my phone, did a clean root at startup using adb shell, and I still have the same problem. The adb remount command won't work, and I can't push anything into the system directory. For what it's worth, when I still had Root Manager installed I was able to toggle RO R/W in any directory with no problem, and I could move files around within the ROM... but I couldn't move anything into it from the SD. I'm new at this, so I have no idea what the problem might be. Anyone else had this problem or have any suggestions?
If anyone else runs into this problem, this solution worked for me:
adb shell
# su
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
# chmod 777 /system (Or any subdirectory you want to push to inside system)
# exit
adb push <local file> <device location>
Restore modified permissions when done.
Though I'm still not sure why this is necessary in place of adb remount.
I'm pretty sure the adb remount command will not work on the stock rom. You should be able to do it with just this command instead:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
dametzg said:
I'm pretty sure the adb remount command will not work on the stock rom. You should be able to do it with just this command instead:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Click to expand...
Click to collapse
Thanks... didn't realize stock wouldn't accept adb remount. If I use the above line from within shell, that doesn't help me push anything on to the phone though... so I needed to enable global permission and then do the push. Oddly enough I tried the same approach last night using Root Manager, and the transfer from SD still failed, even after I applied 777 to the dir I was trying to modify. The current solution may be kind of tedious, but at least it works.
you really shouldn't do 777 on your filesystem, ANY app can then write to your system, overwrite things, or install malicious code. Just remount manually and you should be able to push anything you want, just remember that w/ the stock rom you also don't get a full busybox either.
I'm not positive, but I would think after you remount, you should be able to "adb push" to /system. I suppose it might be specific to that shell, but I would think not.
You just may have to do it once each time you boot your phone.
Edit - err nevermind... you're having permission errors.... um... change adbd on the phone to run as root? not sure how off the top of my head...

Problems with adb push

I am running custom rom Rooted 2.1 v0.3.
Ever since flashing to the custom rom, when i try to push a file, such as:
adb push bootanimation.zip /system/media
I get the error:
Failed to copy.... Read-only file system.
I didn't have this error before flashing to the rom. Does this have something to do with superuser whitelist?
I have tired:
mount -oremount,rw /dev/block/mtdblock3 /system
and it didn't work and I tired:
adb remount
winch returned:
Operation not permitted.
This is ticking me off since I didn't have this problem until flashing the rom.
EDIT: Now if I try:
adb push bootanimation.zip /system/media,
I get:
Permission denied.
This is crazy.
I need help also. Rooting for first time and trying to get recovery.img on and keep getting read only errors. Tried remount to no avail. Help please
su
mount -o rw,remount /Dev/block/mtdblock3 /system
file system is case sensitive!
if anyone know what command to execute an install or push of "any.apk" via Android Terminal Emulator. It would help me greatly.
p.s.
make sure you have developer mode enabled "settings" and accept su permissions. Also have BusyBox
fKngFtd said:
su
mount -o rw,remount /Dev/block/mtdblock3 /system
file system is case sensitive!
if anyone know what command to execute an install or push of "any.apk" via Android Terminal Emulator. It would help me greatly.
p.s.
make sure you have developer mode enabled "settings" and accept su permissions. Also have BusyBox
Click to expand...
Click to collapse
...it's a lowercase d in dev.
mount -o rw,remount /dev/block/mtdblock3 /system
n2imagination said:
I need help also. Rooting for first time and trying to get recovery.img on and keep getting read only errors. Tried remount to no avail. Help please
Click to expand...
Click to collapse
I had the same problem. From what I could tell, I had the wrong ADB driver somehow. So I downloaded the drivers from the HTC website and went to device manager (Win7) and updated the driver software which fixed the problem. But I think i just lucked out when i stumbled onto that, I feel a blind retard with epilepsy trying to draw a circle on an etch-a-sketch when I'm doing things like rooting. But, it couldn't hurt to try it.
fKngFtd said:
su
if anyone know what command to execute an install or push of "any.apk" via Android Terminal Emulator. It would help me greatly.
Click to expand...
Click to collapse
adb install -l whatever.apk (from tools dir in sdk)
`mods said:
I am running custom rom Rooted 2.1 v0.3.
Ever since flashing to the custom rom, when i try to push a file, such as:
adb push bootanimation.zip /system/media
I get the error:
Failed to copy.... Read-only file system.
I didn't have this error before flashing to the rom. Does this have something to do with superuser whitelist?
I have tired:
mount -oremount,rw /dev/block/mtdblock3 /system
and it didn't work and I tired:
adb remount
winch returned:
Operation not permitted.
This is ticking me off since I didn't have this problem until flashing the rom.
EDIT: Now if I try:
adb push bootanimation.zip /system/media,
I get:
Permission denied.
This is crazy.
Click to expand...
Click to collapse
Did you ever get this fixed? I have the same problem!
I have the same problem also. I've been using SDK just fine for over a month or two, and now that I'm on V3, no worky. Somethings obviously going on. But what?!
LexusBrian400 said:
I have the same problem also. I've been using SDK just fine for over a month or two, and now that I'm on V3, no worky. Somethings obviously going on. But what?!
Click to expand...
Click to collapse
I think the proper permissions were not set for this ROM. Hopefully jcase can modify the file and re-upload the ROM =)
at least that's what I've gathered... someone PLEASE correct me if I'm wrong
edit: I looked at the script file and it seems like rw permissions are set properly???
jcase - any insight?
I personally get a bunch of "Out of memory" errors when trying to follow the recovery walk-through.
post baleeted

[Answered] File System read-only after permroot S-OFF

So I just rooted a Glacier out of the box using VISIONary and gfree. Did everything exactly as was supposed to: temprooted, ran gfree, permrooted with "Set system r/w after root" checked, flashed engineering bootloader. Still running stock ROM.
Whenever I try to use adb remount, it fails saying "Operation not permitted." I want to use adb push to write to the file system, but I can't do that without the remount command.
I've tried using terminal emulator to copy a file from the sd card and failed:
Code:
$ su
# cd /sdcard
# cp -f hosts /system/etc
cp: cannot create '/system/etc/hosts':File exists
I've also tried outright deleting a file and failed:
Code:
# cd /system/etc
# rm hosts
rm failed for hosts, Read-only file system
I'm stupefied.
jdkoren said:
So I just rooted a Glacier out of the box using VISIONary and gfree. Did everything exactly as was supposed to: temprooted, ran gfree, permrooted with "Set system r/w after root" checked, flashed engineering bootloader. Still running stock ROM.
Whenever I try to use adb remount, it fails saying "Operation not permitted." I want to use adb push to write to the file system, but I can't do that without the remount command.
I've tried using terminal emulator to copy a file from the sd card and failed:
Code:
$ su
# cd /sdcard
# cp -f hosts /system/etc
cp: cannot create '/system/etc/hosts':File exists
I've also tried outright deleting a file and failed:
Code:
# cd /system/etc
# rm hosts
rm failed for hosts, Read-only file system
I'm stupefied.
Click to expand...
Click to collapse
To be sure you could download a root explorer and see if you can mount R/W
Sent from my HTC Glacier using XDA Premium App
Is there a free application that does this?
Unfortunately, I won't have access to it for the next few days (someone else's phone, and he's going out of town).
the stock rom doesn't except the remount command.
I believe that astro has the remount ability in it. You might want to consider flashing a custom rom though, even if its one of the stock based ones.
option94 said:
the stock rom doesn't accept the remount command.
I believe that astro has the remount ability in it. You might want to consider flashing a custom rom though, even if its one of the stock based ones.
Click to expand...
Click to collapse
I see, thanks very much for the explanation. Is that also why the terminal commands didn't work? Does the stock ROM not allow r/w permissions even if you have superuser permission?
Since it's not my phone, I didn't flash a ROM, only ClockworkMod recovery 3.0.0.6. Next time I see him I'll ask whether he wants to do any firmware changes or not.
jdkoren said:
I see, thanks very much for the explanation. Is that also why the terminal commands didn't work? Does the stock ROM not allow r/w permissions even if you have superuser permission?
Since it's not my phone, I didn't flash a ROM, only ClockworkMod recovery 3.0.0.6. Next time I see him I'll ask whether he wants to do any firmware changes or not.
Click to expand...
Click to collapse
That's correct... I think. all I know is that the stock Rom doesn't usually play well with root lol so yes flash a custom rom
Sent from my HTC Glacier using XDA Premium App
You can make the stock rom rw, but its a pain and I dont really remember the command. Its something like
Code:
mount -o,rw remount /dev/block/mmcblk0p25 /system
That may br right, but if not it wont do any damage. just give you a syntax error.
option94 said:
You can make the stock rom rw, but its a pain and I dont really remember the command. Its something like
Code:
mount -o,rw remount /dev/block/mmcblk0p25 /system
That may b right, but if not it wont do any damage. just give you a syntax error.
Click to expand...
Click to collapse
Ah yes, I remember using that once before. I've since forgotten it since I never use it with my own phone. Alrighty, I'll mark this as answered.

System r/o

Hello fellow xda'ers,
A few weeks I am experiencing a problem with my moto x style. The problem is that i don't have access anymore to my system folder. I have full root access, I can use rooted apps, but i can't switch my file system to r/w. Also when I boot into recovery I can flash roms etc, they are fully working, but once again, no system access. Also when I try to mount the system folder in recovery it seems it won't stick. Also when I use root explorer it says it switched to r/w but in fact it is r/o..
Can someone please hint me out what I could do to fix this problem?
Thanks in advance,
Bump
Have you tried something like this in terminal as root, or via ADB root?
Code:
mount -o rw,remount,rw /system
Then for r/o...
Code:
mount -o ro,remount,ro /system
quakeaz said:
Have you tried something like this in terminal as root, or via ADB root?
Then for r/o...
Click to expand...
Click to collapse
Thanks for your reply. But i still can't get system access.
bartjeh1991 said:
Thanks for your reply. But i still can't get system access.
Click to expand...
Click to collapse
Did you receive an error running the command? You are root, correct? Possibly just use:
Code:
mount -o remount,rw /system
Then run...
Code:
mount | grep system
Mine is read-only, but this should tell you if yours is rw or not.
Code:
u0 a114 clark:/ mount | grep system
/dev/block/bootdevice/by-name/system /system ext4 [B]ro[/B],seclabel,relatime,data=ordered 0 0
quakeaz said:
Did you receive an error running the command? You are root, correct? Possibly just use:
Then run...
Mine is read-only, but this should tell you if yours is rw or not.
Click to expand...
Click to collapse
I get this message everytime i run the commands you give me.

Need help: ad-blocking via hosts file android 7 nougat

Hello dear community,
I'm now struggling for some days to enable ad-blocking on my Huawei Nova with Android 7 Nougat (CAN-L01C432B340). I simply only need root to edit the hosts file and then un-root my device (that can be easily done by flashing boot.img via fastboot again). Reason for un-root is to be able to play Pokemon Go which has a root-block.
Following steps have been tried with root enabled
First things first: The normal way of using AdAway to create a hosts file does not work anymore: It seems to be impossible to remount the /system partition with r/w (read more) with the app.
So I tried many things so far to gain r/w while Android is booted up
Reversed the order on how we give the options to mount as suggested in chainfires posts: mount -o rw,remount /system fails (same does mount -o remount,rw /system)
Installing busybox to have another (probably working) mount command: Installation fails because of no rw on /system (doh)
Flashing busybox installable zip: The binaries seem to be gone when Android is booted up (but are visible in TWRP)
Using another busybox installer seem to be able to at least temporary flash busybox to /system/bin. Yet, busybox mount -o rw,remount /system did not make /system rw.
Flashing systemless AdAway also fails (similar to flashing busybox, the files are written but mystically, all changes are gone after booting into android).
Now I unrooted my device
Then I thought, why not use TWRP and mount the partition with rw there and copy my own custom-made hosts-file to /system. And hey, mounting with rw works! Also even writing and all kind of stuff.
But now the bummer: No matter what I do, the hosts file, formerly written to e.g. the /system partition is reverted back to default after a reboot to android. The strange thing: My modification is still there and visible in TWRP
Investigating on how the hosts file is managed in a booted-up android, I found out, /system/etc/hosts is symlinked to /vendor/etc/hosts.
So I mounted the /vendor partition in TWRP and copied the hosts file there.
mount /dev/block/platform/soc/7824900.sdhci/by-name/vendor /system && cp /external_sd/hosts /system/etc
After a reboot, I noticed /vendor/etc/hosts (= /system/etc/hosts) just has the default entries :crying: Strangely, when I now root my device again, the hosts-file shows my entries (but I need to be un-rooted )
It seems like that all changes done to any partition are somehow reverted back by the kernels drive-mapper. Does anyone have an idea on how to write a hosts-file to my system, which persists when I boot up android and does not require to be permanently rooted?

Categories

Resources