How can I mount the /system
directory rewritable or read-only on my Android phone?
3 Answers
There are a few methods how you can mount your /system
directory RW or RO. However, it will require root.
Method 1:
Connect your phone to the computer. (Make sure USB debugging is enabled on your phone)
Open
CMD
/Terminal
on your PC.Windows: CTRL + R, then type
cmd
.Ubuntu: CTRL + ALT + T.
Mac: Navigate to
/Applications/Utilities/
and double-click on Terminal.
Type this:
adb shell
su
Choose one: (for security mount
/system
back to RO when finished)- Mount system RW:
mount -o rw,remount /system
- Mount system RO:
mount -o ro,remount /system
- Mount system RW:
Method 2:
Open
terminal
on your android phone (download here):Type this in the
terminal
:su
Choose one: (for security mount
/system
back to RO when finished)- Mount system RW:
mount -o rw,remount /system
- Mount system RO:
mount -o ro,remount /system
- Mount system RW:
mount
responds '/system'
or '/system/'
not in /proc/mounts
You possibly have put a /
after ...remount /system
. This can not work, it isn't in the mounts file, /proc/mounts
. Remove this /
from the command you use.
You can use mount -o rw,remount /
(a comment from user:39571, Geremia).
Android 2.3
For people running "Android 2.3" and the command fails, specify the target (from this answer): mount -o remount,rw /system /system
.
-
5It seems this (method 1) does not work on newer Android any more. I am trying to do it on Android emulator running Android 6, but always get an error "mount: Read-only file system". I've run adb root, but it makes no difference. Any idea on what could be done?– diiduCommented Sep 12, 2016 at 12:07
-
1I got it, kind of. I have to use -writable-system command line option when starting the emulator. Then the first adb remount seems to succeed. Seems ... I have not seen it change to rw yet.– diiduCommented Sep 12, 2016 at 12:47
-
-
"For people running Android 2.3" -- that phrasing doesn't communicate very well. I am guessing you mean >=2.3 or <=2.3 (or, less likely, exactly 2.3 if there's a particular bug in 2.3 only) but we don't know which or why. Commented Dec 28, 2017 at 1:32
-
9For me,
mount -o rw,remount /system
givesmount: '/system' not in /proc/mounts
. However,mount -o rw,remount /
works.– GeremiaCommented Mar 6, 2021 at 1:58
-writable-system
for the emulator
When launching the emulator after a build with, you must use:
. build/envsetup.sh
lunch aosp_x86_64-eng
emulator -show-kernel -verbose -writable-system
Then, for future runs, you must keep the -writable-system
option, or else image changes will not be visible:
emulator -show-kernel -verbose -writable-system
-verbose
shows us that the emulator switches from the default -drive
:
if=none,index=0,id=system,file=/path/to/aosp/8.1.0_r60/out/target/product/generic_x86_64/system-qemu.img,read-only
to:
if=none,index=0,id=system,file=/path/to/aosp/8.1.0_r60/out/target/product/generic_x86_64/system-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576
Therefore it:
removes
,read-only
uses
system-qemu.img.qcow2
instead ofsystem-qemu.img
.This implies that changes will only be visible afterwards if you pass
-writable-sytem
on future boots after the change was made!We can see that the qcow2 image is just a small overlay on top of the base image since:
qemu-img info /path/to/aosp/8.1.0_r60/out/target/product/generic_x86_64/system-qemu.img.qcow2
contains:
backing file: /path/to/aosp/8.1.0_r60/out/target/product/generic_x86_64/system-qemu.img
The emulator -help
also confirms this:
emulator -help
contains:
-writable-system make system & vendor image writable after 'adb remount'
adb remount
+ adb root
I think this is just a shortcut for mount
as mentioned at https://android.stackexchange.com/a/110928/126934 , but it is very convenient:
adb root
adb remount
adb shell
adb help
contains:
root restart adbd with root permissions
remount
remount /system, /vendor, and /oem partitions read-write
Restore the original system image
Same as for userdata: remove the .qcow2
overlay, and re-generate it manually: https://stackoverflow.com/questions/54446680/how-to-reset-the-userdata-image-when-building-android-aosp-and-running-it-on-the
I really struggled with that until I used MT Manager (I tried a lot of root explorers and only MT Manager works for me). It isn't on Play Store, so you have to search for it online.
If it didn't work, try the Magisk module called OverlayFS. If you can't find it, here it is: OverlayFS (direct download from XDA).