256

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?

Laurel
  • 5,965
  • 14
  • 31
  • 57
steveo225
  • 11,394
  • 16
  • 62
  • 114
  • 24
    have you tried `adb remount`, what do you get? – silverfox May 19 '11 at 23:48
  • 2
    _Android is Google's software stack ... For non-developer questions, see http://android.stackexchange.com_ – Selvin Dec 16 '11 at 14:42
  • 3
    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. – Chris Stratton Apr 23 '16 at 02:02
  • 1
    Is there a way to do this with an android emulator?? None of these solutions work for my emulator. – MikeSchem Dec 21 '16 at 17:38
  • 1
    Just use `adb shell mount -o rw,remount /sys` (instead of /system). Works for me. – SAMPro Oct 08 '20 at 07:48

24 Answers24

432

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
CurtisLeeBolin
  • 4,424
  • 2
  • 13
  • 11
103
adb remount

works for me and seems to be the simplest solution.

Chen Xing
  • 1,665
  • 2
  • 13
  • 13
  • 8
    "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](http://wiki.cyanogenmod.org/w/Doc:_Building_Basics#ADB)). If you have any issue with root permissions, try "adb root" before. – KrisWebDev Feb 01 '14 at 09:13
  • 11
    I've got `Not running as root. Try "adb root" first.`. And then `adbd cannot run as root in production builds`. – Vadzim Aug 31 '17 at 14:44
  • 3
    On newer devices it looks like we also need to `$ adb disable-verity` and then reboot the device before we can run `$ adb remount` – Nebel22 Dec 11 '18 at 18:43
  • 3
    $ adb disable-verity give : disable-verity only works for userdebug builds – William Jun 11 '19 at 18:29
  • 6
    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.` – user924 Aug 07 '19 at 11:20
  • Doing this on OnePlus Nord CE 5G seems to break mobile connection, I can no longer get texts or use data – murchu27 Nov 17 '21 at 09:58
  • @user924 you need to enable root access from ADB on Developer Settings (if present) – Ivan García Topete Feb 25 '22 at 16:08
86

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
Ishamael
  • 12,583
  • 4
  • 34
  • 52
  • my command prompt becomes extremely slow until cannot continue with adb root and adb remount after launch emulator with -writable-system, anyone can help ? – Beeing Jk May 17 '18 at 01:20
  • 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 8844618](https://github.com/torvalds/linux/commit/5012284700775a4e6e3fbe7eac4c543c4874b559) – Tyler Daniel Sep 02 '21 at 01:21
  • What if I want to write to `/product` directory? – Sevastyan Savanyuk May 21 '22 at 13:46
  • In case you are on windows, Right-click the Bluestacks icon on Desktop > Properties > Target (And add flags there) – testing_22 Jan 07 '23 at 01:13
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

steveo225
  • 11,394
  • 16
  • 62
  • 114
  • 4
    `adb shell ` can be used from the computer (if you lack a terminal on your phone) – Rescribet May 19 '14 at 08:38
  • 18
    this comments results in ```mount: '/system' not in /proc/mounts``` – 임정섭 Mar 05 '21 at 03:07
  • 1
    @임정섭 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. – HackRx Sep 18 '21 at 21:11
  • @HackRx 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. – 임정섭 Sep 22 '21 at 15:23
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
hgdeoro
  • 1,030
  • 10
  • 7
  • 7
    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! – Jonathan Van Matre Dec 21 '11 at 20:09
  • 1
    this only worked for me once I removed the "," from the statement. i.e. "" **mount -o remount rw /system** "" – propjk007 Apr 06 '13 at 18:51
  • @TechnikEmpire, he does not refer to the accepted answer. – Paschalis Oct 26 '15 at 13:20
25
adb disable-verity
adb reboot
adb root
adb remount

This works for me, and is the simplest solution.

byInduction
  • 405
  • 1
  • 6
  • 13
  • 3
    adb disable-verity -- this was the key solution in my case. – Abhiroop Nandi Ray Jul 15 '20 at 14:41
  • 1
    verity cannot be disabled/enabled - USER build – rmirabelle Apr 26 '22 at 22:10
  • 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. – pepan May 31 '23 at 13:17
15

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
Sérgio
  • 6,966
  • 1
  • 48
  • 53
  • 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. – Graham Mitchell May 10 '13 at 03:18
  • saying "You must specify a filesystem type with -t.", whats does this mean? – NehaK Mar 27 '18 at 10:17
  • mount -o rw,remount -t ext4 /dev/block/vda /system , -t mean the type of file system in my example ext4 – Sérgio Mar 27 '18 at 17:23
12

Try the following on the command prompt:

>adb remount
>adb push framework-res_old.apk /system/framework-res.apk
Jonas G. Drange
  • 8,749
  • 2
  • 27
  • 38
scue
  • 121
  • 1
  • 2
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.

George Garcés
  • 159
  • 1
  • 6
7

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.

CoDe
  • 11,056
  • 14
  • 90
  • 197
  • 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. – Günter Dec 05 '22 at 22:03
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.

ashwani
  • 33
  • 6
2
mount -o rw,remount /dev/stl12 /system

works for me

qinqie
  • 67
  • 6
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.

Geng Jiawen
  • 8,904
  • 3
  • 48
  • 37
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"
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.)

Paul
  • 1,502
  • 11
  • 19
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.

satyanx1
  • 111
  • 5
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.

vkkeeper
  • 277
  • 3
  • 4
1

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

xsilen T
  • 1,515
  • 14
  • 10
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

Jan Bergström
  • 736
  • 6
  • 15
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.

0

Try this in a Terminal Emulator as root:

restorecon -v -R /data/media
intrepidis
  • 2,870
  • 1
  • 34
  • 36
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.

rsanath
  • 1,154
  • 2
  • 15
  • 24
-1

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

Cillian Myles
  • 696
  • 8
  • 16
-2

I just only needed this:

su -c "mount -o rw,remount /system"
Dima Kozhevin
  • 3,602
  • 9
  • 39
  • 52