Android 6.0 adb remount后没有写权限,提示Read-only file system

在Android6.0 (Android M)userdebug版本上(eng版本不存在该问题),发现使用adb remount 系统之后,还是不能对system分区进行操作,提示没有写权限,为只读文件系统Read-only file system

解决方法如下
方法一:使用新的adb工具包
1.下载最新的adb工具包
查看是否为adb最新版本:
# adb version
Android Debug Bridge version 1.0.32
Revision 09a0d98bebce-android
(有该信息表明是最新的1.0.32版本,旧的1.0.32版本没有该信息)

最新版本的adb增加了一些adb命令,如 adb disable-verity等,可通过adb help查看安装的adb是否支持disable-verity命令

最新的adb工具包下载地址如下:
http://download.csdn.net/detail/linuxarm521/9572709

2.执行如下命令
1. adb root
2. adb disable-verity
(最新的adb 工具包才支持adb disable-verity命令,如果是Linux开发环境,则可使用工程编译结果目录out/host/linux-x86/bin下的adb执行文件)
3. adb reboot 重启设备
(只要不刷机,以上步骤执行一次就行)
4. adb root
5. adb remount
现在可以对system分区进行读写了

注意点:
1.新版本的adb工具 adb shell 进入命令行之后,Ctrl+c不能退出,可输入exit退出
2.可点击adb\run_adb.bat文件直接启动adb

方法二:修改系统源码
修改源码中的fstab文件,把system分区的verify标志去掉
如把
/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/system /system ext4 ro wait,verify
修改为
/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/system /system ext4 ro wait

其他:
adb disable-verity命令在系统源码中的控制
system\core\adb\set_verity_enable_state_service.cpp
void set_verity_enabled_state_service(int fd, void* cookie)
{
……
/* Loop through entries looking for ones that vold manages */
for (i = 0; i < fstab->num_entries; i++) {
if(fs_mgr_is_verified(&fstab->recs[i])) {
if (!set_verity_enabled_state(fd, fstab->recs[i].blk_device,
fstab->recs[i].mount_point,
enable)) {
any_changed = true;
}
}
}
……
}

static int set_verity_enabled_state(int fd, const char *block_device,
const char* mount_point, bool enable)
{
……
if (adb_write(device, &new_magic, sizeof(new_magic)) != sizeof(new_magic))
{
WriteFdFmt(fd, “Could not set verity %s flag on device %s with error %s\n”,
enable ? “enabled” : “disabled”,
block_device, strerror(errno));
goto errout;
}
……
}

参考资料
http://blog.csdn.net/wh_19910525/article/details/50263851

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章