Repository navigation
数据盘快满时下次开机前自动扩容 - #130
Merged
Merged
数据盘快满时下次开机前自动扩容#130
Conversation
数据盘剩余不够时没人提醒,装不下游戏新版本才发现,要靠用户自己知道 set --data-gb。数据盘镜像是稀疏的(16 GB 扩到 32 GB 宿主只多约 0.3 GB), 所以默认自动扩、留一个按实例关掉的开关。 - 开机后读一次客体 /data 的 statfs,记进 mas-avd.json 的 instances.<i>.dataSpace。剩余不到 5 GB 或不到 10% 算快满。 - 快满时下次开机前(prepareLaunch)经 avd.Update 扩大 16 GB,和 set --data-gb 同一套:模拟器开机时扩镜像,growData 在线扩文件系统。 到 256 GB 为止;宿主盘剩余要不少于步长 + 20 GB,读不到或不够就不扩。 读数要属于当前配置的大小(设备已到这个大小),手动改大后、或旧版盘 文件系统跟不上时不扩。结果记在 dataGrow。 - info / status 和管理器卡片按新的 data_space 提示快满、扩了、没扩成、 到上限,带上手动扩容的命令。 - set <i> --auto-grow on|off(dataAutoGrow,没写就是开)。 - README、API.md 中英两份跟着改;mock 加了两张示例卡片。 Refs ModAVD/ModAVD#153
# Conflicts: # README.en.md # README.md # internal/cli/cli.go
This was referenced Nov 11, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为什么
客体数据盘快满时管理器和
modavd都不提醒,装不下游戏新版本才发现,要靠用户自己知道modavd set <i> --data-gb N(ModAVD/ModAVD#153)。这次定的做法是自动扩容,默认开、按实例可以关。先核了一件事:数据盘镜像扩大以后宿主侧占用会不会马上涨。16 GB 的新实例
set --data-gb 32后开机(在线扩到 32 GB),userdata-qemu.img.qcow2在宿主上从 1.40 GB 到 1.73 GB(含这次开机本身的写入)。镜像按客体实际写入增长,扩大本身几乎不占宿主盘。改了什么
growData之后)读一次客体/data的 statfs,记进mas-avd.json的instances.<i>.dataSpace(剩余、总量、属于哪个配置大小、文件系统有没有跟上磁盘)。剩余不到 5 GB 或不到 10% 算快满。prepareLaunch里,上次读数快满时经avd.Update把disk.dataPartition.size加 16 GB,和set --data-gb同一套:模拟器开机时扩镜像,开机后growData在线扩文件系统。结果记在instances.<i>.dataGrow。InstanceInfo加data_space(status --json也带)。info、status和管理器卡片提示快满(下次开机会扩)、已扩、宿主盘不够、到上限、文件系统跟不上、扩容失败、快满但自动扩容关了,都带手动扩容的命令。set <i> --auto-grow on|off,存instances.<i>.dataAutoGrow,没写就是开,立即生效。internal/ui/API.md中英两份跟着改;dev/mock.js加了数据和两张示例卡片。测试
mas-avd.json里别的键、info/status文字、--auto-grow参数。被测代码读的根目录是测试临时目录,宿主盘剩余由注入的函数给出,不碰生产。<=、取反;上限>=改>、删掉上限判断、目标不截上限;宿主盘护栏删掉、去掉 20 GB 预留、改成<=、读不到时照扩;忽略关掉开关、忽略读数大小、忽略文件系统跟不上。go test ./...、go vet(Windows、GOOS=darwin、GOOS=linux)、gofmt、隐私扫描通过。fallocate27.5 GiB 把剩余压到 2.9 GB;再跑一次开机后步骤,status提示「下次开机前自动扩到 48 GB」。正常关机后开机:开机前日志「自动从 32 GB 扩到 48 GB」,开机后在线扩到 48.0 GB(0.3 秒),df剩 18.8 GiB,随机文件 md5 不变、填充文件还在;关机后宿主占用从 1.75 GB 到 2.05 GB(含这次开机的写入)。管理器卡片用 mock 看过:「下次开机会扩」显示为普通提示,「宿主盘不够」显示为警告。发版回归要测的场景:
fallocate一个大文件即可),开机后status提示「下次开机前自动扩到 N GB」,卡片显示同一条提示。status/ 卡片提示「已自动扩」;宿主侧占用只涨实际写入的量。modavd set <i> --auto-grow off后重复 1、2:不扩,status/ 卡片提示快满并给出set --data-gb命令;--auto-grow on后下次开机照常扩。mas-avd.json后dataAutoGrow、dataSpace、dataGrow还在。Refs ModAVD/ModAVD#153