繁体   English   中英

如何使用 adb 在 bash 脚本中以读写方式重新安装我的 Android/系统?

[英]How can I remount my Android/system as read-write in a bash script using adb?

信息

adb remount 

返回"remount failed: Operation not permitted"

adb shell 'su -c  mount -o rw,remount /system'

返回unknown option -- o

我的设备已植根。

remount失败的可能原因是您没有以root身份运行adb

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 /;

如果失败,您可以尝试以下方法:

# List the Devices.
adb devices;

# Run adb as root
adb root;

adb remount;
adb shell su -c "mount -o rw,remount /";

要查找您是哪个user

$ adb shell whoami

如果不指定要挂载为 /system 的 dev 块,我就无法让 mount 命令工作

#cat /proc/mounts返回(这里只有系统行)
/dev/stl12 /system rfs ro,relatime,vfat,log_off,check=no,gid/uid/rwx,iocharset=utf8 0 0

所以我的工作命令是
mount -o rw,remount -t rfs /dev/stl12 /system

否则……如果

getenforce

返回

Enforcing

那么也许你应该打电话

setenforce 0 
mount -o rw,remount /system 
setenforce 1

以下内容可能会有所帮助(首先研究disable-verity的影响):

adb root
adb disable-verity
adb reboot

我遇到了同样的问题,无法将系统挂载为读/写。 它会回来

用法:mount [-r] [-w] [-o options] [-t type] 设备目录

或者

不允许操作。 拒绝访问

现在这适用于所有有根设备。

TERMINAL EMULATORADB SHELL

$ su
#mount - o rw,remount -t yaffs2 /system

Yaffs2是系统分区的类型。 将其替换为通过执行以下操作获得的系统分区类型

#cat /proc/mounts

然后从冗长的结果中检查/system出现的位置

我的提取物就像

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

所以我的系统是ext4 我的命令是

$ su
#mount  -o  rw,remount  -t  ext4  /system 

完毕。

从 Google Play 商店获取“adbd insecure”,它有助于提供对自定义 rom 的写访问权限,从而保护我的制造商。

除了您收到的所有其他答案之外,我想解释一下unknown option -- o错误:您的命令是

$ adb shell 'su -c  mount -o rw,remount /system'

它通过 adb 调用 su。 您正确引用了整个 su 命令,以便将其作为一个参数传递给adb shell 但是, su -c <cmd>还需要您用参数引用命令,它将传递给 shell 的-c选项。 (YMMV 取决于su变体。)因此,您可能想尝试

$ adb shell 'su -c "mount -o rw,remount /system"'

(并可能在/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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM