Read only file system on Android
Asked Answered
A

23

261

I recently rooted my Droid X and everything seems to be working perfectly. 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.

How can I fix this?

Aeriela answered 19/5, 2011 at 23:38 Comment(5)
have you tried adb remount, what do you get?Ran
Android is Google's software stack ... For non-developer questions, see android.stackexchange.comDong
Please note that this question should not be confused with the case where Android Application code fails with a read-only file system error. That is usually caused by trying to write a file without specifying a location, ie, trying to write to the root directory. This question is only about modifying the installation of Android itself on rooted/development/engineering devices.Nevus
Is there a way to do this with an android emulator?? None of these solutions work for my emulator.Truss
Just use adb shell mount -o rw,remount /sys (instead of /system). Works for me.Portsmouth
A
82

Got this off an Android forum where I asked the same question. 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

Aeriela answered 20/5, 2011 at 0:15 Comment(4)
adb shell <command> can be used from the computer (if you lack a terminal on your phone)Brighten
this comments results in mount: '/system' not in /proc/mountsOverawe
@임정섭 I am also facing the same issue, did you find any solution? nothing is working for me. if I am doing adb remount, I am getting remount of the / superblock failed: Permission denied remount failed and with this answer, I am getting '/system' not in /proc/mounts. Please help.Hisakohisbe
@Hisakohisbe I kind of gave up and found other proxy methods. Overall, what I wanted to was pushing some data to the phones and I did this by pushing to /data/local/ . Here didn't raise permission error.Overawe
P
439

Not all phones and versions of android have things mounted the same.
Limiting options when remounting would be best.

Simply remount as rw (Read/Write):

# mount -o rw,remount /system

Once you are done making changes, remount to ro (read-only):

# mount -o ro,remount /system
Presto answered 16/12, 2011 at 13:10 Comment(19)
You can do this on your PC too. adb shell mount -o rw,remount /systemClonus
Use in conjunction with adb root or you'll get a Permission Denied when pushing the file.Martyrize
mount: permission deniedQuintillion
@MikeHenke, it sounds like you were not root when you executed it.Presto
@MikeHenke or you need to remember to run "su" beforehand or prefix the command with "su", to give the shell root access.Mayberry
mount: Operation not permittedSlumgullion
If I use adb root I get adbd cannot run as root in production buildsLashandralashar
remember that don't run this command it directly on your Linux/Mac :-)Graces
@L'Esperanza This works fine, you don't have the privileges required to do it. You need to have super user permissions. Try doing it as rootAeriela
Yes. I detected problem with android. I can't root it.Arabic
if i tried the command above as a SU" mode... but still got permission denied, what should I do then? @curtlee2002Ultima
Doesn't work for me: Balazss-MBP:tools varh1i$ adb shell generic_x86_64:/ # mount -o rw,remount /system '/dev/block/vda' is read-onlyColyer
It is not worked for me.It showed "mount: Read-only file system"Tlingit
Since I had root anyway, I copied the file to /sdcard, then used (in my case) mv hosts /system/etc/hostsHooked
"mount: '/dev/block/bootdevice/by-name/system'->'/system': Device or resource busy"Cancellation
@Lashandralashar you've probably solved that, but i write for general knowledge. you should use the google api devices and not google playInterpellate
samsung tab a after that reboots and everything is back as it wasKali
@BalazsVarhegyi did you try remount /dev ? Otherwise you are only remounting the /system directoryGroot
If you get an error like mount: '/system' not in /proc/mounts, you can try remounting the / directory instead of /system directoryOhare
M
104
adb remount

works for me and seems to be the simplest solution.

Muscovado answered 23/4, 2012 at 21:6 Comment(7)
"adb remount -- If you've gotten errors trying to push files to /system due to it being in read-only mode, adb remount will remount /system into read-write mode--- provided that the shell has the correct root permissions to do so. This replaces having to type a longer command by hand such as mount -o rw,remount /system (as root) or something." (source). If you have any issue with root permissions, try "adb root" before.Martyrize
I've got Not running as root. Try "adb root" first.. And then adbd cannot run as root in production builds.Cancellation
On newer devices it looks like we also need to $ adb disable-verity and then reboot the device before we can run $ adb remountNathan
$ adb disable-verity give : disable-verity only works for userdebug buildsDown
it doesn't work: Not running as root. Try "adb root" first.. I entered adb root and then again adb remount but still the same error: Not running as root. Try "adb root" first.Kali
Doing this on OnePlus Nord CE 5G seems to break mobile connection, I can no longer get texts or use dataMyatt
@Kali you need to enable root access from ADB on Developer Settings (if present)Groot
A
90

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:

-writable-system

For anything to be writable to the /system. Without this flag no combination of remount or mount will allow one to write to /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.

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:

./emulator -list-avds
Approbate answered 16/2, 2017 at 16:53 Comment(4)
my command prompt becomes extremely slow until cannot continue with adb root and adb remount after launch emulator with -writable-system, anyone can help ?Donatus
Note that in some old kernel versions there is a bug in the ext4 driver that causes the remount to immediately revert to read-only. Check dmesg for error messages like "Inode table for bg 0 marked as needing zeroing". This is fixed by commit 8844618Lacerated
What if I want to write to /product directory?Creekmore
In case you are on windows, Right-click the Bluestacks icon on Desktop > Properties > Target (And add flags there)Scutellation
A
82

Got this off an Android forum where I asked the same question. 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

Aeriela answered 20/5, 2011 at 0:15 Comment(4)
adb shell <command> can be used from the computer (if you lack a terminal on your phone)Brighten
this comments results in mount: '/system' not in /proc/mountsOverawe
@임정섭 I am also facing the same issue, did you find any solution? nothing is working for me. if I am doing adb remount, I am getting remount of the / superblock failed: Permission denied remount failed and with this answer, I am getting '/system' not in /proc/mounts. Please help.Hisakohisbe
@Hisakohisbe I kind of gave up and found other proxy methods. Overall, what I wanted to was pushing some data to the phones and I did this by pushing to /data/local/ . Here didn't raise permission error.Overawe
H
30
adb disable-verity
adb reboot
adb root
adb remount

This works for me, and is the simplest solution.

Heraclitean answered 25/7, 2018 at 0:12 Comment(3)
adb disable-verity -- this was the key solution in my case.Blob
verity cannot be disabled/enabled - USER buildMangrum
This is the right answer. I just had to push "adb root" as the very first command, otherwise I'm getting "Error getting verity state. Try adb root first? Overlayfs setup failed with error Permission denied Maybe run adb root?" on Android Emulator SDK 29.Insensible
G
28

I think the safest way is remounting the /system as read-write, using:

mount -o remount,rw /system

and when done, remount it as read-only:

mount -o remount,ro /system
Greenwich answered 21/12, 2011 at 19:50 Comment(3)
Welcome to SO! Your answer is technically useful, but essentially a duplicate of curtlee2002's prior answer. This might have been better as a comment on his answer saying "I agree it is safest to switch back to read-only after monkeying around in read-write mode." We have millions of questions, so there will always be another question where you are the first to come with a great solution or a fresh perspective!Arita
this only worked for me once I removed the "," from the statement. i.e. "" mount -o remount rw /system ""Partida
@TechnikEmpire, he does not refer to the accepted answer.Loxodrome
A
16

On my Samsung galaxy mini S5570 (after got root on cellphone):

Fist, as root, I ran:

systemctl start adb

as a normal user:

adb shell 
su 

Grant root permissions on touch screen

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:

mount -o rw,remount /dev/stl12 /system
Aerify answered 4/2, 2013 at 0:37 Comment(3)
Thank you for this answer. For some reason I never looked at the screen on my phone to grant root permissions and was getting access denied no matter what I tried.Adamsun
saying "You must specify a filesystem type with -t.", whats does this mean?Semiconductor
mount -o rw,remount -t ext4 /dev/block/vda /system , -t mean the type of file system in my example ext4Laurenelaurens
F
12

Try the following on the command prompt:

>adb remount
>adb push framework-res_old.apk /system/framework-res.apk
Fragmentation answered 4/8, 2012 at 15:0 Comment(1)
It should be adb root remountCalefacient
I
9

Here is what worked for me. I was running an emulated Android 7.1.1 (Nougat) device.

On a terminal, I hit the following command. One thing to be noticed is the -writable-system flag

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

Imbue answered 31/1, 2018 at 16:4 Comment(1)
mount: '/system' not in /proc/mountsFlorida
P
8

I checked with emulator and following worked.

  1. adb reboot
  2. adb root && adb remount && adb push ~/Desktop/hosts /system/etc/hosts

As mentioned above as well, execute second step in single shot.

Prinz answered 29/3, 2019 at 10:27 Comment(1)
I had one console open for pushing and one for remounting. Remount, switch to the other terminal where you have the push line ready to submit, and submit it. That's it.Closehauled
F
3

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.

Furrier answered 10/5, 2015 at 16:18 Comment(0)
H
2
mount -o rw,remount /dev/stl12 /system

works for me

Herschel answered 5/9, 2013 at 2:37 Comment(0)
U
2

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.

Unaffected answered 19/1, 2016 at 11:54 Comment(0)
O
2
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"
Othello answered 19/4, 2018 at 20:30 Comment(0)
S
1

I found this article from google, and thought I'd add the steps necessary on a 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.

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. (I tried stop ric; this doesn't work - although it worked on a previous version of android on the phone).

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. 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. (It restarted for me automatically.)

Stephenstephenie answered 19/9, 2013 at 2:24 Comment(0)
C
1

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.

For Example, the command goes: 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. You don't have to act as a root to use this command and also, it works perfectly fine on production devices.

Christianity answered 19/12, 2015 at 0:12 Comment(0)
G
1

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.

ls command shows me:

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.

Command mount -o rw,remount /mnt/asec didn't resolve "r/o fs" issue, it wants device parameter before directory parameter.

"df" command didn't help also, but shows that my /mnt/asec/com.my.app-1 directory is at the separate mount point.

Then I looks by mount and voila!

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.

Genitor answered 6/5, 2016 at 10:3 Comment(0)
B
1

it sames that must extract and repack initrc.img and edit init file with the code of mount /system

Bivalent answered 1/2, 2017 at 2:54 Comment(1)
btw. you must start avd with -writeable-system optionsBivalent
D
0

Copy files to the SD-card?

Well, I assume you like to copy data to the Sd-card from the developers computer? 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.

  • 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)
  • 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. 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 push C:\testdata\t.txt /sdcard/download/t.txt

Diagnostician answered 5/9, 2015 at 15:20 Comment(0)
K
0

If there's a failure in copying the read-only file you can try locating the original file in the root directory and modify it with a root text editor (preferably) RB text editor, it comes with ROM Toolbox app.

Keniakenilworth answered 31/7, 2016 at 10:15 Comment(0)
V
0

Try this in a Terminal Emulator as root:

restorecon -v -R /data/media
Vassili answered 6/11, 2016 at 12:23 Comment(0)
F
0

In my case I was using the command adb push ~/Desktop/file.txt ~/sdcard/

I changed it to ~/Desktop/file.txt /sdcard/ and then it worked.

Make sure to disconnect and reconnect the phone.

Fenestration answered 3/9, 2018 at 1:35 Comment(1)
The author of this question asks about remounting the /system as read-write, your answer is kinda off topicLopes
A
-2

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

Make sure ADB has Root access:

enter image description here

Ardie answered 8/11, 2019 at 16:39 Comment(1)
I've seen this alot, but I don't have this option on ANY of my devices. Emulator or otherwise.Bogtrotter

© 2022 - 2024 — McMap. All rights reserved.