[英]How can I remount my Android/system as read-write in a bash script using adb?
For info信息
adb remount
returns "remount failed: Operation not permitted"
返回
"remount failed: Operation not permitted"
adb shell 'su -c mount -o rw,remount /system'
returns unknown option -- o
返回
unknown option -- o
My device is rooted.我的设备已植根。
Probable cause that remount
fails is you are not running adb
as root
. remount
失败的可能原因是您没有以root
身份运行adb
。
Shell Script should be as follow. Shell脚本应该如下。
# Script to mount Android Device as read/write.
# List the Devices.
adb devices;
# Run adb as root (Needs root access).
adb root;
# Since you're running as root su is not required
adb shell mount -o rw,remount /;
If this fails, you could try the below:如果失败,您可以尝试以下方法:
# List the Devices.
adb devices;
# Run adb as root
adb root;
adb remount;
adb shell su -c "mount -o rw,remount /";
To find which user
you are:要查找您是哪个
user
:
$ adb shell whoami
I could not get the mount command to work without specifying the dev block to mount as /system如果不指定要挂载为 /system 的 dev 块,我就无法让 mount 命令工作
#cat /proc/mounts
returns ( only the system line here ) #cat /proc/mounts
返回(这里只有系统行)
/dev/stl12 /system rfs ro,relatime,vfat,log_off,check=no,gid/uid/rwx,iocharset=utf8 0 0
so my working command is所以我的工作命令是
mount -o rw,remount -t rfs /dev/stl12 /system
Otherwise... if否则……如果
getenforce
returns返回
Enforcing
Then maybe you should call那么也许你应该打电话
setenforce 0
mount -o rw,remount /system
setenforce 1
The following may help (study the impacts of disable-verity
first):以下内容可能会有所帮助(首先研究
disable-verity
的影响):
adb root
adb disable-verity
adb reboot
I had the same problem and could not mount system as read/write.我遇到了同样的问题,无法将系统挂载为读/写。 It would return
它会回来
Usage: mount [-r] [-w] [-o options] [-t type] device directory
用法:mount [-r] [-w] [-o options] [-t type] 设备目录
Or或者
operation not permitted.
不允许操作。 Access denied
拒绝访问
Now this works on all rooted devices.现在这适用于所有有根设备。
DO THE FOLLOWING IN TERMINAL EMULATOR
OR IN ADB SHELL
在
TERMINAL EMULATOR
或ADB SHELL
$ su
#mount - o rw,remount -t yaffs2 /system
Yaffs2
is the type of system partition. Yaffs2
是系统分区的类型。 Replace it by the type of your system partition as obtained from executing the following将其替换为通过执行以下操作获得的系统分区类型
#cat /proc/mounts
Then check where /system
is appearing from the lengthy result然后从冗长的结果中检查
/system
出现的位置
Extract of mine was like我的提取物就像
mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0/dev/block/platform/msm_sdcc.3/by-num/p10 /system ext4 ro,relatime,data=ordered 0 0
/dev/block/platform/msm_sdcc.3/by-num/p11 /cache ext4 rw,nosuid,nodev,relatime,data=ordered 0 0
So my system is ext4
.所以我的系统是
ext4
。 And my command was我的命令是
$ su
#mount -o rw,remount -t ext4 /system
Done.完毕。
从 Google Play 商店获取“adbd insecure”,它有助于提供对自定义 rom 的写访问权限,从而保护我的制造商。
In addition to all the other answers you received, I want to explain the unknown option -- o
error: Your command was除了您收到的所有其他答案之外,我想解释一下
unknown option -- o
错误:您的命令是
$ adb shell 'su -c mount -o rw,remount /system'
which calls su through adb.它通过 adb 调用 su。 You properly quoted the whole su command in order to pass it as one argument to
adb shell
.您正确引用了整个 su 命令,以便将其作为一个参数传递给
adb shell
。 However, su -c <cmd>
also needs you to quote the command with arguments it shall pass to the shell's -c
option.但是,
su -c <cmd>
还需要您用参数引用命令,它将传递给 shell 的-c
选项。 (YMMV depending on su
variants.) Therefore, you might want to try (YMMV 取决于
su
变体。)因此,您可能想尝试
$ adb shell 'su -c "mount -o rw,remount /system"'
(and potentially add the actual device listed in the output of mount | grep system
before the /system
arg – see the other answers.) (并可能在
/system
arg 之前添加mount | grep system
输出中列出的实际设备 - 请参阅其他答案。)
mount -o rw,remount $(mount | grep /dev/root | awk '{print $3}')
这对我有用,应该适用于任何 android 版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.