pack
它能做什么
说明如何把 smolvm 虚拟机或镜像打包成单个文件,并检查安装在其中的软件在迁移后是否仍然存在。它适合希望分享已准备好的环境的人。
适用场景
- ✓当你希望以单个文件的形式交付准备好的环境时。
- ✓当打包后的文件能运行,但你在其中安装的软件却不见了的时候。
- ✓当较旧的 smolvm 版本拒绝导出已分支的虚拟机时。
技能链接
https://github.com/smol-machines/smolvm/blob/main/docs/pack/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我准备好的 smolvm 虚拟机打包成一个文件,以便我的同事运行相同的环境。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能将镜像或已准备好的虚拟机打包成一个制品。打包前,它会在虚拟机中写入一个标记值,然后从制品中读回该值,以证明状态被保留下来。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Packing a machine into a portable artifact
For macOS first-import performance, storage seed behavior and a file-heavy reproduction, see macOS storage seeds.
Verified on smolvm v1.29.0 on macOS arm64, 2026-10-15, and on v1.14.6 on Linux aarch64, 2026-09-11; the Linux host could not run the packing steps on v1.18.2 or v1.22.2, for the reason in "Platform arms". Done means the artifact runs a command in a real VM and, for a machine pack, the state you installed is still inside it. The Linux runs used the scripts of their date; this version's preflight and cleanup scripts ran on Linux aarch64 on v1.22.2 on 2026-10-03.
The assertion that matters is a value, not a boot. A pack that lost its rootfs still boots,
still prints a guest kernel and still exits zero. The only thing that separates a good artifact
from an empty one is a marker written into the source machine before packing and read back out of
the artifact afterwards, which is what pack-machine.sh and verify-pack.sh do between them.
Procedure
1. Preflight. Read-only: starts no VM, packs nothing.
scripts/preflight.sh
The lines to read are exporter_memory_ok and image_vm_memory_ok: both pack paths boot a helper VM before they
write anything. pack create --image pulls in a VM fixed at 4 vCPUs and 8192 MiB on every release here.
pack create --from-vm boots an export helper fixed at 8192 MiB through v1.16.1, whose failure was a bare agent did not become ready within 30 seconds; from v1.16.2 it asks for 4096 MiB (on Linux half the available memory when that
is less, never under 1024), SMOLVM_EXPORT_HELPER_MEMORY_MIB=<MiB> sets it, and a failed start says The export helper asked for N MiB of memory and names the variable. exporter_memory_mib is the figure this binary will ask for, except
under a cgroup memory limit on Linux, where smolvm asks for less. From v1.16.1 the helper reuses the machine's cached
image layers (Reusing the machine's cached image layers...); on macOS arm64 on v1.16.1, 2026-09-15, that export took
1.2 s with exporter_memory_ok=no. Both lines warn and do not gate: see "What the memory lines do and do not promise".
2. Pack from an image, when you want a runnable artifact of a stock image.
scripts/pack-image.sh # alpine, ./from-image
scripts/pack-image.sh python:3.12-alpine ./mypack
This path boots the 8192 MiB pull VM, so image_vm_memory_ok is its line; --mem sets the
artifact's memory and does not reach that VM. If you pass a custom output, pass it to the
verify step too (verify-pack.sh --image ./mypack), or that step finds nothing at its defaults
and tells you so rather than passing.
3. Pack from a machine you provisioned, when the point is the state in it.
scripts/pack-machine.sh # smolskill-golden, ./from-vm
It creates the machine with a workload that stays up, waits for a value from it, writes a marker, asserts the marker on the source, stops the machine and exports it. The source assertion is not ceremony: packing a machine whose provisioning silently failed produces an artifact that runs perfectly and contains nothing, and nothing downstream will tell you.
Packing a machine that already exists, the user's own rather than one pack-machine.sh made:
the script refuses any name without the smolskill- prefix, so run its sequence by hand. Stop
the machine first: --from-vm packs a stopped machine's snapshot and refuses a running one. A
machine start afterwards is how the machine comes back. A machine provisioned by hand is verified
with a file of the user's own: --marker-path names it and --marker its expected last line.
smolvm machine exec --name myapp -- tail -1 /root/provisioned.txt # note the value on the source
smolvm machine stop --name myapp
smolvm pack create --from-vm myapp --output ./myapp-portable --single-file # one file, no sidecar
scripts/verify-pack.sh --machine ./myapp-portable --marker-path /root/provisioned.txt --marker <that value>
smolvm machine start --name myapp # the machine comes back
With no file of the user's to check, write the packet's marker before the stop,
smolvm machine exec --name myapp -- sh -c 'echo PACKED_STATE_PRESENT > /marker.txt', verify
without --marker-path, and remove /marker.txt after the start.
verify-pack.sh --machine reads the mark
常见问题
我怎么知道打包成功了?
该技能会从制品中读回标记值。仅仅启动成功并不能证明已安装的状态仍然存在。
任何电脑都能运行这个文件吗?
只有兼容的宿主机才可以。该技能是围绕特定的 smolvm 版本和平台编写的。
预检检查什么?
它是只读的,用来确认电脑有足够的内存供两种打包方式使用。
详情
作者的原始描述
Turns an image, or a machine already provisioned, into a single self-contained artifact that runs on another compatible host. Use when shipping a prepared environment as one file, when a packed artifact runs but the state installed into it is missing, when pack create fails because the VM it boots to pull or export could not start, when an older release refuses to export a branched machine, or when deciding whether to pack from an image or from a machine. Do not use it to keep a machine you re-enter, which is the dev-env packet, or to run untrusted code, which is the throwaway-machine packet.
repo: smol-machines/smolvm
热度
- GitHub 星标
- 6.9k
- 排名
- #13722
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
branch-and-checkpoint
6.9k帮你的智能体将正在运行的 smolvm 虚拟机保存为检查点,之后恢复,暂停并继续运行,或分支为多个副本。
coding-agent
6.9k帮你的智能体在安全的 smolvm 虚拟机中运行 Claude Code 等编程智能体,并挂载你的项目文件夹。
credentials
6.9k让你的智能体使用你的密钥调用 API,而密钥本身永远不会进入其虚拟机,因此不受信任的代码无法读取它。
dev-env
6.9k教你的智能体保持一个已安装工具的 smolvm 开发虚拟机,使其能快速重启,并在会话之间保留软件包。