How can I mount the /system directory rewritable or read-only on my Android phone?
- 4,000
- 5
- 35
- 46
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/Terminalon 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 shellsuChoose one: (for security mount
/systemback 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
terminalon your android phone (download here):Type this in the
terminal:suChoose one: (for security mount
/systemback to RO when finished)- Mount system RW:
mount -o rw,remount /system - Mount system RO:
mount -o ro,remount /system
- Mount system RW:
Android 2.3
For people running Android 2.3 and the command fails, look at this answer: https://android.stackexchange.com/a/125437/95577
- 4,000
- 5
- 35
- 46
-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-onlyuses
system-qemu.img.qcow2instead ofsystem-qemu.img.This implies that changes will only be visible afterwards if you pass
-writable-sytemon 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.qcow2contains:
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
- 905
- 1
- 10
- 13
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).
- 15,988
- 10
- 74
- 123
- 11
- 1
mount -o rw,remount /systemgivesmount: '/system' not in /proc/mounts. However,mount -o rw,remount /works. – Geremia Mar 06 '21 at 01:58