How can I remount my Android/system as read-write in a bash script using adb?

后端 未结 8 1228
半阙折子戏
半阙折子戏 2020-12-23 17:27

For info

adb remount 

returns \"remount failed: Operation not permitted\"

adb shell \'su -c  mount -o rw,remo         


        
相关标签:
8条回答
  • 2020-12-23 17:38

    Probable cause that remount fails is you are not running adb as root.

    Shell Script should be as follow.

    # Script to mount Android Device as read/write.
    # List the Devices.
    adb devices;
    
    # Run adb as root (Needs root access).
    adb root;
    
    # Since you're running as root su is not required
    adb shell mount -o rw,remount /;
    

    If this fails, you could try the below:

    # List the Devices.
    adb devices;
    
    # Run adb as root
    adb root;
    
    adb remount;
    adb shell su -c "mount -o rw,remount /";
    

    To find which user you are:

    $ adb shell whoami
    
    0 讨论(0)
  • 2020-12-23 17:46
    mount -o rw,remount $(mount | grep /dev/root | awk '{print $3}')
    

    this does the job for me, and should work for any android version.

    0 讨论(0)
  • 2020-12-23 17:48

    The following may help (study the impacts of disable-verity first):

    adb root
    adb disable-verity
    adb reboot
    
    0 讨论(0)
  • 2020-12-23 17:48

    Get "adbd insecure" from google play store, it helps give write access to custom roms that have it secured my the manufacturers.

    0 讨论(0)
  • 2020-12-23 17:56

    In addition to all the other answers you received, I want to explain the unknown option -- o error: Your command was

    $ adb shell 'su -c  mount -o rw,remount /system'
    

    which calls su through adb. You properly quoted the whole su command in order to pass it as one argument to adb shell. However, su -c <cmd> also needs you to quote the command with arguments it shall pass to the shell's -c option. (YMMV depending on su variants.) Therefore, you might want to try

    $ adb shell 'su -c "mount -o rw,remount /system"'
    

    (and potentially add the actual device listed in the output of mount | grep system before the /system arg – see the other answers.)

    0 讨论(0)
  • 2020-12-23 18:03

    I could not get the mount command to work without specifying the dev block to mount as /system

    #cat /proc/mounts returns ( only the system line here )
    /dev/stl12 /system rfs ro,relatime,vfat,log_off,check=no,gid/uid/rwx,iocharset=utf8 0 0

    so my working command is
    mount -o rw,remount -t rfs /dev/stl12 /system

    0 讨论(0)
提交回复
热议问题