在编译Android12 源码虚拟机进行调试时,需要remount 时有时会遇到下面错误:
$adb remount
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
Can not mount overlayfs for partitions: No such file or directory
skip unmounted partition dev:/dev/block/dm-0 mnt:/system: Success
failed to remount partition dev:/dev/block/dm-3 mnt:/vendor: Read-only file system
Consider providing all the dependencies to enable overlayfs
failed to remount partition dev:/dev/block/dm-2 mnt:/product: Read-only file system
Consider providing all the dependencies to enable overlayfs
failed to remount partition dev:/dev/block/dm-1 mnt:/system_ext: Read-only file system
Consider providing all the dependencies to enable overlayfs
remount failed
这时需要在使用下面命令启动虚拟机:
emulator -writable-system
-writable-system
使用此选项在模拟会话期间创建可写系统映像。为此,请执行以下操作:
1、使用 -writable-system 选项启动虚拟设备。
2、从命令终端输入 adb remount 命令,让模拟器以读/写方式重新装载 system/(默认情况下,它以只读方式装载)。
官方参数文档:https://developer.android.google.cn/studio/run/emulator-commandline?hl=zh-cn#startup-options
启动之后使用adb remount
, 如果失败,执行下面命令:
adb root
adb shell mount -o bind /system /system
adb shell mount -o rw,remount /