kvm 虚拟机的详细说明(3)

发表于:2013-03-20来源:百度空间作者:cat650点击数: 标签:虚拟机
kvm-img info xxx.img 关于格式的优缺点,请参看高级篇 转换命令(先cd 到你要保存镜像的位置): kvm-img convert -f raw -O qcow2 xp.img xp.qco 注意:-O是字母o的大写。

  kvm-img info xxx.img

  关于格式的优缺点,请参看高级篇

  转换命令(先cd 到你要保存镜像的位置):

  kvm-img convert -f raw -O qcow2 xp.img xp.qco

  注意:-O是字母o的大写。

  这条命令举例的意思是:把名为xp.img格式为raw的镜像转换成新镜像xp.qco格式为qcow2

  其它格式"vmdk"是 VMware 3 / 4 兼容镜像格式。

  *******************************深入了解

  1.kvm-img 命令

  用法:kvm-img 后续命令 [命令选项]

  后续命令如下

  check [-f fmt] filename

  create [-F base_fmt] [-b base_image] [-f fmt] [-o options] filename [size]

  commit [-f fmt] filename

  convert [-c] [-f fmt] [-O output_fmt] [-o options] [-B output_base_image] filename [filename2 [...]] output_filename

  info [-f fmt] filename

  snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename

  部分内容详解:

  filename

  镜像的文件名(比如:xp.img cat.raw……后缀名随便取,或者不取)

  base_image

  只读的镜像——有点像“母镜像”。在“母镜像”基础上创建的镜像只储存对“母镜像”的修改。

  output_base_image

  forces the output image to be created as a copy on write image of

  the specified base image; "output_base_image" should have the same

  content as the input's base image, however the path, image format,

  etc may differ

  base_fmt

  base_image(母镜像) 的格式. 参考 fmt

  fmt

  指镜像格式。建议大多数情况让系统自动选择(不使用该选项)。

  主要格式如下:

  "raw"

  Raw disk image format (默认).该格式精简,易被多种虚拟机接受。

  如果你的系统支持 holes (如 linux 的 ext2 ext3 ext4? windows 的 NTFS),那么它将有效节约空间(比如你创建的磁盘是2G,虚拟系统只使用了800M,那么它实际也只占用800M的空间)。使用命令“kvm-img info 镜像文件名”,将显示实际使用的大小。linux用户还可以使用“ls -ls”命令直接查看。

  "qcow2"

  QEMU 镜像格式, 使用最多的格式. 创建的镜像比较小(用多少就占多少),对于系统文件不支持 holes 的(比如windows系统下使用qemu)很有帮助。可进行AES加密,zlib基本压缩,并支持多种VM的快照(snapshots)。

  "qcow"

  古老的 QEMU 镜像格式. Left for compatibility.

  "cow"

  User Mode Linux Copy On Write image format. Used to be the only

  growable image format in QEMU. It is supported only for

  compatibility with previous versions. It does not work on

  win32.不能运行win32.

  "vmdk"

  VMware 3 / 4 兼容镜像格式

  "cloop"

  Linux Compressed Loop image, useful only to reuse directly

  compressed CD-ROM images present for example in the Knoppix CD-

  ROMs.

  size

  镜像文件的大小比特. 一般单位使 "M" (megabyte, 1024k) 、 "G" (gigabyte, 1024M)、 T (terabyte, 1024G) 。 "b" is ignored.

  output_filename

  生成的镜像文件名

  output_fmt

  生成的镜像文件格式

原文转自:http://www.ltesting.net