Search code examples
androidadbmount

Android 8.1 can't remount /system,/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only


I found some similar issues on StackOverflow like Can't mount system android : read file only [duplicate],How can I remount my Android/system as read-write in a bash script using adb? and I tried those anwsers but all doesn't work for me,so please don't add duplicated tag for this issue. I do remount /system on AVD (Android 8.1 x86),what I'm trying as follow:

1|generic_x86:/ # cat /proc/mounts
rootfs / rootfs rw,seclabel,size=859768k,nr_inodes=214942 0 0
tmpfs /dev tmpfs rw,seclabel,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,seclabel,relatime,mode=600 0 0
proc /proc proc rw,relatime,gid=3009,hidepid=2 0 0
sysfs /sys sysfs rw,seclabel,relatime 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system /system ext4 ro,seclabel,relatime,data=ordered 0 0 
/dev/block/pci/pci0000:00/0000:00:07.0/by-name/vendor /vendor ext4 ro,seclabel,relatime,data=ordered 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,relatime,mode=755 0 0
tmpfs /mnt tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0
none /config configfs rw,relatime 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
pstore /sys/fs/pstore pstore rw,seclabel,relatime 0 0
/dev/block/vdb /cache ext4 rw,seclabel,nosuid,nodev,noatime,errors=panic,data=ordered 0 0
tmpfs /storage tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0
tracefs /sys/kernel/debug/tracing tracefs rw,seclabel,relatime 0 0
/dev/block/dm-0 /data ext4 rw,seclabel,nosuid,nodev,noatime,errors=panic,data=ordered 0 0
/dev/block/dm-0 /data/var/run/netns ext4 rw,seclabel,nosuid,nodev,noatime,errors=panic,data=ordered 0 0
proc /data/var/run/netns/router proc rw,relatime,gid=3009,hidepid=2 0 0
proc /data/var/run/netns/router proc rw,relatime,gid=3009,hidepid=2 0 0
/data/media /mnt/runtime/default/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid 0 0
/data/media /storage/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid 0 0
/data/media /mnt/runtime/read/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=23,derive_gid 0 0
/data/media /mnt/runtime/write/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0
generic_x86:/ # getenforce
Enforcing
generic_x86:/ # mount -o rw,remount /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # setenforce 0
generic_x86:/ # mount -o rw,remount /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # getenforce
Permissive
generic_x86:/ # setenforce 1
generic_x86:/ # getenforce
Enforcing
generic_x86:/ # setenforce 0
generic_x86:/ # mount -o rw,remount /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-n
by-name/  by-num/
generic_x86:/ # mount -o rw,remount /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # chmod 777 /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system
generic_x86:/ # mount -o rw,remount /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount -t rfs /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount -t rfs /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system  /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount -t ext4 /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount -t ext4 /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system  /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount -t ext4  /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # clear
[2J[Hgeneric_x86:/ # cd..
/system/bin/sh: cd..: not found
127|generic_x86:/ # su
generic_x86:/ # whoami
root
generic_x86:/ # cat /proc/mounts
rootfs / rootfs rw,seclabel,size=859768k,nr_inodes=214942 0 0
tmpfs /dev tmpfs rw,seclabel,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,seclabel,relatime,mode=600 0 0
proc /proc proc rw,relatime,gid=3009,hidepid=2 0 0
sysfs /sys sysfs rw,seclabel,relatime 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system /system ext4 ro,seclabel,relatime,data=ordered 0 0
/dev/block/pci/pci0000:00/0000:00:07.0/by-name/vendor /vendor ext4 ro,seclabel,relatime,data=ordered 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,relatime,mode=755 0 0
tmpfs /mnt tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0
none /config configfs rw,relatime 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
pstore /sys/fs/pstore pstore rw,seclabel,relatime 0 0
/dev/block/vdb /cache ext4 rw,seclabel,nosuid,nodev,noatime,errors=panic,data=ordered 0 0
tmpfs /storage tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0
tracefs /sys/kernel/debug/tracing tracefs rw,seclabel,relatime 0 0
/dev/block/dm-0 /data ext4 rw,seclabel,nosuid,nodev,noatime,errors=panic,data=ordered 0 0
/dev/block/dm-0 /data/var/run/netns ext4 rw,seclabel,nosuid,nodev,noatime,errors=panic,data=ordered 0 0
proc /data/var/run/netns/router proc rw,relatime,gid=3009,hidepid=2 0 0
proc /data/var/run/netns/router proc rw,relatime,gid=3009,hidepid=2 0 0
/data/media /mnt/runtime/default/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid 0 0
/data/media /storage/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid 0 0
/data/media /mnt/runtime/read/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=23,derive_gid 0 0
/data/media /mnt/runtime/write/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0
generic_x86:/ # mount -o rw,remount -t ext4 /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount -t ext4 /dev/b
binder  block/
generic_x86:/ # mount -o rw,remount -t ext4 /dev/block/pci/pci0000\:00/0000
0000:00:03.0/  0000:00:04.0/  0000:00:05.0/  0000:00:06.0/  0000:00:07.0/
generic_x86:/ # mount -o rw,remount -t ext4 /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system  /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ #
130|generic_x86:/ # exit
130|generic_x86:/ # exit

C:\Users\Administrator>adb -s emulator-5554 root

C:\Users\Administrator>adb -s emulator-5554 remount
remount of /system failed: Read-only file system
remount of /vendor failed: Read-only file system
remount failed

C:\Users\Administrator>adb -s emulator-5554 disable-verity

C:\Users\Administrator>adb -s emulator-5554 reboot

C:\Users\Administrator>adb -s emulator-5554 root

C:\Users\Administrator>adb -s emulator-5554 remount
error: closed

C:\Users\Administrator>adb -s emulator-5554 remount
Not running as root. Try "adb root" first.

C:\Users\Administrator>adb -s emulator-5554 root

C:\Users\Administrator>adb -s emulator-5554 remount
remount succeeded

C:\Users\Administrator>adb -s emulator-5554 shell
generic_x86:/ # mount -o rw,remount -t ext4 /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only
generic_x86:/ # mount -o rw,remount -t ext4 /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system /sys
sys/     system/
generic_x86:/ # mount -o rw,remount -t ext4 /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system /system/
mount: '/system/' not in /proc/mounts
1|generic_x86:/ # mount -o rw,remount -t ext4 /dev/block/pci/pci0000\:00/0000\:00\:03.0/by-name/system /system
'/dev/block/pci/pci0000:00/0000:00:03.0/by-name/system' is read-only

Solution

  • I fixed the exact same problem you were having with the following steps:

    1. Open the shell with .\adb.exe shell
    2. Open the mounts file with the command cat /proc/mounts inside the shell
    3. On the /system line, take a look on your mount type (in my case ext4) and the path (/dev/block....) enter image description here
    4. Exit the shell and then run .\adb.exe root followed by the command .\adb.exe shell 'mount -o rw,remount -t <type> <path> /system'
    5. If the problem still persists, run .\adb.exe reboot and try step 4 again

    I hope this fixes your problem!

    EDIT: You need to start up the emulator with Writable System image on powershell. Go to the emulator folder on your android-sdk directory and then run

    .\emulator.exe -avd $deviceName -writable-system
    

    This helped me keeping the changes persisted on the AVD