[英]A terminal command for a rooted Android to remount /System as read/write
I'm writing an android app that needs to copy a file to the "/system" partition at runtime.我正在编写一个需要在运行时将文件复制到“/system”分区的 android 应用程序。 I've got the commands to run "su" and can successfully request SuperUser permissions and run commands as root.
我有运行“su”的命令,并且可以成功请求超级用户权限并以 root 身份运行命令。 But I don't know how to make this app universal across multiple devices, because the mount command can differ depending on where the /system is actually mounted.
但我不知道如何使这个应用程序在多个设备上通用,因为 mount 命令可能会因 /system 实际挂载的位置而异。 Here's the command that's used most offen:
这是最常用的命令:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
But I know that mtdblock3 could be different on some devices (and for that matter, i guess so could yaffs2).但我知道 mtdblock3 在某些设备上可能会有所不同(就此而言,我想 yaffs2 也可能如此)。 So, my question is: Is there a universal command that will work on all phones?
所以,我的问题是:是否有适用于所有手机的通用命令? Or is there a way to find out at runtime what the correct parameters are?
或者有没有办法在运行时找出正确的参数是什么?
我使用这个命令:
mount -o rw,remount /system
You can run the mount command without parameter in order to get partition information before constructing your mount command.您可以不带参数运行mount命令,以便在构建 mount 命令之前获取分区信息。 Here is an example of the mount command without parameter outputed from my HTC Hero.
这是我的 HTC Hero 输出的不带参数的 mount 命令示例。
$ mount
mount
rootfs / rootfs ro 0 0
tmpfs /dev tmpfs rw,mode=755 0 0
devpts /dev/pts devpts rw,mode=600 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /sqlite_stmt_journals tmpfs rw,size=4096k 0 0
none /dev/cpuctl cgroup rw,cpu 0 0
/dev/block/mtdblock3 /system yaffs2 rw 0 0
/dev/block/mtdblock5 /data yaffs2 rw,nosuid,nodev 0 0
/dev/block/mtdblock4 /cache yaffs2 rw,nosuid,nodev 0 0
/dev/block//vold/179:1 /sdcard vfat rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=
1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,s
hortname=mixed,utf8,errors=remount-ro 0 0
Try尝试
mount -o remount,rw /system
mount -o remount,rw /system
If no error message is printed, it works.如果没有打印错误消息,它就可以工作。
Or, you should do the following.或者,您应该执行以下操作。
First, make sure the fs type.首先,确定 fs 类型。
mount
山
Issue this command to find it out.发出此命令以找出它。
Then然后
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
Note that the fs(yaffs2) and device(/dev/block/mtdblock3) are depend on your system.请注意, fs(yaffs2) 和 device(/dev/block/mtdblock3) 取决于您的系统。
Instead of代替
mount -o rw,remount /system/
mount -o rw,重新挂载 /system/
use用
mount -o rw,remount /system
mount -o rw,重新挂载 /system
mind the '/' at the end of the command.注意命令末尾的“/”。 you ask why this matters?
你问为什么这很重要? /system/ is the directory under /system while /system is the volume name.
/system/ 是 /system 下的目录,而 /system 是卷名。
您也可以尝试 adb remount 命令将 /system 重新挂载为读写
adb remount
You don't need to pass both arguments when performing a remount.执行重新挂载时,您不需要传递这两个参数。 You can simply pass the mount point (here /system).
您可以简单地传递挂载点(此处为 /system)。 And /system is universal amongst Android devices.
并且 /system 在 Android 设备中是通用的。
I had the same problem.我有同样的问题。 So here is the real answer: Mount the system under
/proc
.所以这是真正的答案:在
/proc
下安装系统。 Here is my command:这是我的命令:
mount -o rw,remount /proc /system
It works, and in fact is the only way I can overcome the Read-only System problem.它有效,实际上是我克服只读系统问题的唯一方法。
This is what works on my first generation Droid X with Android version 2.3.4.这适用于我的第一代 Android 2.3.4 版 Droid X。 I suspect that this will be universal.
我怀疑这将是普遍的。 Steps:
脚步:
root system and install su.根系统并安装su。
Install busybox安装busybox
Install a terminal program.安装终端程序。
to mount system rw first su then先挂载系统 rw su 然后
busybox mount -o rw,remount system
To remount ro重新安装 ro
busybox mount -o ro,remount system
Note that there are no slashes on "system".请注意,“系统”上没有斜线。
If you have rooted your phone, but so not have busybox, only stock toybox, here a one-liner to run as root :如果你已经root了你的手机,但没有busybox,只有stock toybox,这里有一个单线以root身份运行:
mount -o rw,remount $( mount | sed '/ /system /!d' | cut -d " " -f 1 ) /system mount -o rw,remount $( mount | sed '//system /!d' | cut -d " " -f 1 ) /system
toybox do not support the "-o remount,rw" option toybox 不支持“-o remount,rw”选项
if you have busybox, you can use it :如果你有busybox,你可以使用它:
busybox mount -o remount,rw /system busybox mount -o remount,rw /system
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.