使用“adb remount”后,/data/gsi/remount 中将出现一个名为 scrap.img.0000 的大文件(11G)。 看来这个文件被用作overlay fs(/mnt/scratch),如何减小它的大小
/data/gsi/remount # ls -l
total 11138156
-rw-r----- 1 root root 17 2024-07-12 09:21 scratch.img
-rw------- 1 root root 11405463552 2024-07-12 09:21 scratch.img.0000
adb enable-verity
之后,文件被删除,但adb remount
之后的所有修改都恢复了。
看完aosp13的源码后, https://android.googlesource.com/platform/system/core/+/refs/heads/android13-release/fs_mgr/fs_mgr_overlayfs.cpp
它显示它将使用 /data 大小的一半作为覆盖磁盘,所以可以。
static inline uint64_t GetIdealDataScratchSize() {
BlockDeviceInfo super_info;
PartitionOpener opener;
if (!opener.GetInfo(fs_mgr_get_super_partition_name(), &super_info)) {
LERROR << "could not get block device info for super";
return 0;
}
struct statvfs s;
if (statvfs("/data", &s) < 0) {
PERROR << "could not statfs /data";
return 0;
}
return std::min(super_info.size, (uint64_t(s.f_frsize) * s.f_bfree) / 2);
}