如何快速创建 Xen 虚拟机镜像

2026年09月26日 19:16
有1个网友回答
网友(1):

qemu-img create -f raw filename.img

qemu-img create -f filename.img(这个和上面的指令是一个意思,下面有解释)
这个指令就是创建一个raw格式的磁盘,raw格式的优点如下:
Raw disk image format (default). This format has the advantage of being simple and easily exportable to all other emulators. If your file system supports holes (for example in ext2 or ext3 on Linux or NTFS on Windows), then only the written sectors will reserve space. Use qemu-img info to know the real size used by the image or ls -ls on Unix/Linux.
简单,能很容易的转换为其他虚拟机的格式;
根据实际使用量来占用空间,但是和qcow2不同,raw需要宿主机支持hole(比如ext2,ext3,ntfs等);
能够调节空间最大值;
能够直接被宿主机挂载,以传输数据;
由于采用直接写文件的方式,性能高于qcow2;
注:由于raw格式是qemu-img创建磁盘的默认格式,所以如果不指定文件类型的话,默认是raw。