[英]How to change zstd level for qcow2 image?
There is an option compression_type=zstd
to enable zstd compression for qcow2 according to wiki . 根据 wiki ,有一个选项compression_type=zstd
可以为 qcow2 启用 zstd 压缩。
But it always uses zstd level 3
, how could I do to compress it with level 19
?但它总是使用zstd level 3
,我怎么能用level 19
压缩它? This image is read-only and I just want the max compression level.此图像是只读的,我只想要最大压缩级别。
The command I use now is:我现在使用的命令是:
qemu-img convert -p -f qcow2 -O qcow2 -c -o compression_type=zstd,preallocation=off win10.qcow2 win10-zstd.qcow2
Other info:其他信息:
Linux fedora 5.17.5-300.fc36.x86_64
qemu-img.x86_64 2:6.2.0-9.fc36
There are not a command line option, so we need to modify the source code.没有命令行选项,所以我们需要修改源代码。 On ./block/qcow2-threads.c :在./block/qcow2-threads.c :
206 | return -EIO;
207 | }
+ 208 | ZSTD_CCtx_setParameter(cctx, ZSTD_c_strategy, ZSTD_btultra2);
209 | /*
Compiling it following offical tutorial .按照官方教程编译它。 Here some tips:这里有一些提示:
# (Fedora) Install dependencies
dnf install bzip2 ninja-build libzstd-devel pixman-devel
# Enable ZSTD, disable useless features for shorter compile time
./configure --enable-zstd --disable-tcg --disable-kvm
Now we found qemu-img
at ./build/softemu
.现在我们在./build/softemu
找到了qemu-img
。 Try to convert a file:尝试转换文件:
./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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.