惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
罗磊的独立博客
B
Blog
博客园_首页
A
About on SuperTechFans
有赞技术团队
有赞技术团队
V
V2EX
U
Unit 42
I
InfoQ
IT之家
IT之家
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
H
Help Net Security

kkocdko's blog

Tasker 永久试用修改思路 - kkocdko's blog 极限压缩文档扫描件 - kkocdko's blog Bypass the Blank Chars Detection crknob - Chrome portable patch 我如何将博客首页体积降至 3 KB - kkocdko's blog 如何极限优化压缩文件体积 - kkocdko's blog EmEditor 精简版 - kkocdko's blog Backup Data from VSCode Web 优雅地游玩 Minecraft - kkocdko's blog 让程序以管理员权限运行的 PE 清单 - kkocdko's blog 注销 ZEIT 账号之后遇到的坑 - kkocdko's blog 本博客的协议已更改为 CC0 - kkocdko's blog mobp - 使 MSOffice 后台常驻 在安装 VS 生成工具时规避 .NET 安装错误 各种格式的占位空文件 - kkocdko's blog 优雅地游玩 Flash 游戏 - kkocdko's blog WPS 2016 极限精简版 - kkocdko's blog Convert Const to Let by Terser 规避 Visual Studio 许可证过期的 Bug 方便地使用 iPod - kkocdko's blog 用 UserJS 注入 UserCSS - kkocdko's blog 注册表修改文件关联(默认程序) - kkocdko's blog 周期精准的太阳系模型 - kkocdko's blog 关闭屏幕的 WinAPI - kkocdko's blog 重置 Windows 图标缓存 - kkocdko's blog AIDA64 极限精简单文件版 - kkocdko's blog 几何画板单文件精简版 - kkocdko's blog 世界之窗浏览器单文件版 - kkocdko's blog 在 MBR + Legacy 下用 Bootmgr 引导 Ubuntu 简洁的 Markdown 预览工具 - kkocdko's blog
Change ZSTD Level in QCOW2
2026-04-11 · via kkocdko's blog

Currently it's QEMU 8.2.0

The zstd level of qcow2 created by qemu is always 3. For a read-only disk image, I just want the best compression ratio.

There are not a command line option, so we need to modify the source code(1). On ./block/qcow2-threads.c:

  224 |  */
+     | ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btultra2);
+     | ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, ZSTD_maxCLevel());
+     | ZSTD_CCtx_setParameter(cctx, ZSTD_c_enableLongDistanceMatching, 1);
  225 | zstd_ret = ZSTD_compressStream2(cctx, &output, &input, ZSTD_e_end);

Compiling by yourself or use my prebuilt binary (built on GitHub Actions).

Now we found qemu-img at ./build. Have a try?

./qemu-img convert -p -f qcow2 -O qcow2 -c -o compression_type=zstd win10.qcow2 win10-2.qcow2

We got it:

[kkocdko@fedora tmpfs]$ ls -l
total 3411264
-rw-r--r--. 1 kkocdko kkocdko 1651638272 Jun 12 01:57  win10-2.qcow2
-rw-r--r--. 1 kkocdko kkocdko 1841496064 May 25 18:21  win10.qcow2

(1) You can find more zstd parameters from docs.