简体   繁体   English

Android 上的只读文件系统

[英]Read only file system on Android

I recently rooted my Droid X and everything seems to be working perfectly.我最近扎根了我的 Droid X,一切似乎都运行良好。 I made some changes to build.prop and when I do adb push build.prop /system/ I get the following error: failed to copy 'c:\\build.prop' to '/system//build.prop': Read-only file system .我对build.prop进行了一些更改,当我执行adb push build.prop /system/出现以下错误: failed to copy 'c:\\build.prop' to '/system//build.prop': Read-only file system

How can I fix this?我怎样才能解决这个问题?

Not all phones and versions of android have things mounted the same.并非所有手机和 android 版本都安装了相同的东西。
Limiting options when remounting would be best.最好在重新安装时限制选项。

Simply remount as rw (Read/Write):只需重新挂载为 rw(读/写):

# mount -o rw,remount /system

Once you are done making changes, remount to ro (read-only):完成更改后,重新挂载到 ro(只读):

# mount -o ro,remount /system
adb remount

对我有用,似乎是最简单的解决方案。

Got this off an Android forum where I asked the same question.从 Android 论坛上得到了这个,我在那里问了同样的问题。 Hope this helps somebody else.希望这对其他人有帮助。

On a terminal emulator on the phone:在手机上的终端模拟器上:

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system

Then on the cmd prompt, do the adb push然后在 cmd 提示符下,执行adb push

While I know the question is about the real device, in case someone got here with a similar issue in the emulator, with whatever tools are the latest as of Feb, 2017, the emulator needs to be launched from the command line with:虽然我知道问题是关于真实设备的,但如果有人在模拟器中遇到类似问题,使用截至 2017 年 2 月的最新工具,模拟器需要从命令行启动:

-writable-system

For anything to be writable to the /system .对于可写入/system任何内容。 Without this flag no combination of remount or mount will allow one to write to /system .如果没有此标志,则remountmount组合将不允许写入/system

After the emulator is launched with that flag, a single adb remount after adb root is sufficient to get permissions to push to /system .在使用该标志启动模拟器后,在adb root之后adb remount单个adb remount就足以获得推送到/system权限。

Here's an example of the command line I use to run my emulator:这是我用来运行模拟器的命令行示例:

./emulator -writable-system -avd Nexus_5_API_25 -no-snapshot-load -qemu

The value for the -avd flags comes from: -avd标志的值来自:

./emulator -list-avds

I think the safest way is remounting the /system as read-write, using:我认为最安全的方法是将 /system 重新挂载为读写,使用:

mount -o remount,rw /system

and when done, remount it as read-only:完成后,将其重新挂载为只读:

mount -o remount,ro /system

On my Samsung galaxy mini S5570 (after got root on cellphone):在我的三星galaxy mini S5570上(在手机上root后):

Fist, as root, I ran:拳头,作为根,我跑了:

systemctl start adb

as a normal user:作为普通用户:

adb shell 
su 

Grant root permissions on touch screen在触摸屏上授予 root 权限

mount 

list all mount points that we have and we can see, in my case, that /dev/stl12 was mounted on /system as ro (ready only), so we just need do:列出我们拥有的所有挂载点,我们可以看到,在我的情况下,/dev/stl12 作为 ro 挂载在 /system 上(仅就绪),所以我们只需要执行以下操作:

mount -o rw,remount /dev/stl12 /system
adb disable-verity
adb reboot
adb root
adb remount

This works for me, and is the simplest solution.这对我有用,并且是最简单的解决方案。

Try the following on the command prompt:在命令提示符下尝试以下操作:

>adb remount
>adb push framework-res_old.apk /system/framework-res.apk

Here is what worked for me.这对我有用。 I was running an emulated Android 7.1.1 (Nougat) device.我正在运行模拟的 Android 7.1.1 (Nougat) 设备。

On a terminal, I hit the following command.在终端上,我点击了以下命令。 One thing to be noticed is the -writable-system flag需要注意的一件事是 -writable-system 标志

./emulator -writable-system -avd Nexus_6_API_25  -partition-size 280

On another tab在另一个选项卡上

./adb shell
su
mount -o rw,remount -t ext4 /dev/block/vda /system

All the changes that you do on the /system contents will survive a restart.您对 /system 内容所做的所有更改都将在重新启动后继续存在。

I checked with emulator and following worked.我检查了模拟器并进行了以下工作。

  1. adb reboot亚行重启
  2. adb root && adb remount && adb push ~/Desktop/hosts /system/etc/hosts adb root && adb remount && adb push ~/Desktop/hosts /system/etc/hosts

As mentioned above as well, execute second step in single shot.同样如上所述,单次执行第二步。

Open terminal emulator on the phone: then在手机上打开终端模拟器:然后

adb shell

after that daemon is started守护进程启动后

su
mount -o rw,remount /mnt/sdcard

then the read only is converted into the read-Write.然后只读转换为读写。

mount -o rw,remount /dev/stl12 /system

为我工作

This worked for me

#Mount as ReadOnly

su -c "mount -o rw,remount /system"
# Change Permission for file
su -c "chmod 777 /system/build.prop" 
#Edit the file to add the property
su -c "busybox vi /system/build.prop"
# Add now
service.adb.tcp.port=5678

# Reset old permissions
su -c "chmod 644 /system/build.prop"

# Mount as readonly again once done
su -c "mount -o ro,remount /system"

I found this article from google, and thought I'd add the steps necessary on a Sony Xperia Z (4.2.2).我从谷歌上找到了这篇文章,并认为我会在 Sony Xperia Z (4.2.2) 上添加必要的步骤。

The Sony has a watchdog process which detects when you've changed ro to rw on / and /system (these are the only ones I was trying to modify) and possibly others.索尼有一个看门狗进程,它可以检测您何时在 / 和 / 系统上将 ro 更改为 rw(这些是我试图修改的唯一的)以及其他可能的。

The following was what I ran to perform the changes I was trying to achieve.以下是我为执行我试图实现的更改而运行的内容。 I pasted these into a window, because removing the execute bit from /sbin/ric needs to be done quickly in order to stop it restarting itself.我将这些粘贴到一个窗口中,因为从 /sbin/ric 中删除执行位需要快速完成以阻止它重新启动。 (I tried stop ric ; this doesn't work - although it worked on a previous version of android on the phone). (我试过stop ric ;这不起作用 - 尽管它在手机上的先前版本的 android 上工作)。

pkill -9 ric; mount -o rw,remount -t rootfs /
chmod 640 /sbin/ric
mount -o rw,remount /system

I modified the hosts file here, so this is the place you make the changes you need to the filesystem.我在这里修改了 hosts 文件,因此这是您对文件系统进行所需更改的地方。 To leave things the way we found them, do this:要让事情保持我们发现它们的方式,请执行以下操作:

mount -o ro,remount /system
chmod 750 /sbin/ric
mount -o ro,remount -t rootfs /

At which point ric should automatically restart.此时 ric 应自动重新启动。 (It restarted for me automatically.) (它自动为我重新启动。)

Adding a little bit more to Jan Bergström's answer: Because Android is a Linux based system, and the path in Linux contains forward slashes(../), while using push command, use "/" to define destination path in the Android device.在 Jan Bergström 的回答中添加一点:因为 Android 是基于 Linux 的系统,并且 Linux 中的路径包含正斜杠 (../),在使用 push 命令时,使用“/”来定义 Android 设备中的目标路径。

For Example, the command goes: adb push C:\\Users\\admin\\Desktop\\1.JPG sdcard/pictures/例如,命令是: adb push C:\\Users\\admin\\Desktop\\1.JPG sdcard/pictures/

Notice that here, back slashes are used to define source path of the file to be pushed from windows PC and forward slashes are used to define destination path because Android is a Linux based system.请注意,这里的反斜杠用于定义要从 Windows PC 推送的文件的源路径,而正斜杠用于定义目标路径,因为 Android 是基于 Linux 的系统。 You don't have to act as a root to use this command and also, it works perfectly fine on production devices.您不必以 root 身份使用此命令,而且它在生产设备上运行良好。

Sometimes you get the error because the destination location in phone are not exist.有时您会收到错误消息,因为手机中的目标位置不存在。 For example, some android phone external storage location is /storage/emulated/legacy instead of /storage/emulated/0 .例如,一些安卓手机的外部存储位置是/storage/emulated/legacy而不是/storage/emulated/0

Thanks, Sérgio , for "mount" command without parameters idea.谢谢,塞尔吉奥,没有参数想法的“挂载”命令。 I'd need to made adb push into /data/data/com.my.app/lib for some test issue, and get "Read-only filesystem" message.对于某些测试问题,我需要将adb push送到/data/data/com.my.app/lib中,并获得“只读文件系统”消息。

ls command shows me: ls 命令显示我:

root@android:/ # ls -l /data/data/com.my.app/
drwxrwx--x u0_a98 u0_a98 2016-05-06 09:16 cache drwxrwx--x u0_a98 u0_a98 2016-05-06 09:04 files lrwxrwxrwx system system 2016-05-06 11:43 lib -> /mnt/asec/com.my.app-1/lib

So, it's understood, that "lib" directory is separated from other application directories.因此,可以理解,“lib”目录与其他应用程序目录是分开的。

Command mount -o rw,remount /mnt/asec didn't resolve "r/o fs" issue, it wants device parameter before directory parameter.命令mount -o rw,remount /mnt/asec没有解决“r/o fs”问题,它需要目录参数之前的设备参数。

"df" command didn't help also, but shows that my /mnt/asec/com.my.app-1 directory is at the separate mount point. “df”命令也没有帮助,但显示我的/mnt/asec/com.my.app-1目录位于单独的挂载点。

Then I looks by mount and voila!然后我看mount ,瞧!

root@android:/ # mount ......... /dev/block/dm-4 /mnt/asec/com.my.app-1 ext4 ro,dirsync,relatime 0 0

Next steps are already described upwards: remount to RW, push and remount back to RO.后续步骤已经在上面进行了描述:重新安装到 RW,推送并重新安装回 RO。

与必须解压并重新打包 initrc.img 并使用 mount /system 的代码编辑init文件相同

Copy files to the SD-card?将文件复制到 SD 卡?

Well, I assume you like to copy data to the Sd-card from the developers computer?好吧,我假设您喜欢将数据从开发人员计算机复制到 Sd 卡? You might have rooted the devise and made the area you address available?) I had about the same problem to upload data files for my application(Android Studio 1.3.2 in Win7), but.您可能已经根植了设备并使您解决的区域可用?)我在为我的应用程序(Win7 中的 Android Studio 1.3.2)上传数据文件时遇到了同样的问题,但是。

  • First the adb command-shell has to be found in th path: PATH=%PATH%;C:\\Users\\XXXXX\\AppData\\Local\\Android\\sdk\\platform-tools (the folder AppData is hidden, so you have to set the folder setup not hiding concealed files and folder to find it, Path works regardless)首先必须在路径中找到 adb command-shell:PATH=%PATH%;C:\\Users\\XXXXX\\AppData\\Local\\Android\\sdk\\platform-tools(文件夹 AppData 是隐藏的,所以你必须设置文件夹设置没有隐藏隐藏的文件和文件夹来找到它,不管路径如何工作)
  • You have to spell the folder path right or you get a read-only error message, most likely it must start with /sdcard or it is read only area.您必须正确拼写文件夹路径,否则您会收到只读错误消息,很可能它必须以 /sdcard 开头,或者它是只读区域。 As soon as I did no problem pushing the file to the emulator.只要我没有问题就将文件推送到模拟器。

So for instance the the adb command can look like this:因此,例如 adb 命令可以如下所示:

adb push C:\\testdata\\t.txt /sdcard/download/t.txt adb push C:\\testdata\\t.txt /sdcard/download/t.txt

如果复制只读文件失败,您可以尝试在根目录中找到原始文件并使用根文本编辑器(最好)RB文本编辑器对其进行修改,它带有ROM Toolbox应用程序。

以 root 身份在终端模拟器中尝试此操作:

restorecon -v -R /data/media

In my case I was using the command adb push ~/Desktop/file.txt ~/sdcard/在我的情况下,我使用命令 adb push ~/Desktop/file.txt ~/sdcard/

I changed it to ~/Desktop/file.txt /sdcard/ and then it worked.我将其更改为~/Desktop/file.txt /sdcard/然后它起作用了。

Make sure to disconnect and reconnect the phone.确保断开并重新连接手机。

As chen-xing mentioned the simplest way is:正如陈兴所说,最简单的方法是:

adb reboot

But for me I had to change my settings first:但对我来说,我必须先更改我的设置:

Settings → Developer options → Root access设置 → 开发者选项 → Root 权限

Make sure ADB has Root access:确保 ADB 具有 Root 访问权限:

在此处输入图片说明

我只需要这个:

su -c "mount -o rw,remount /system"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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