QEMU-KVM Command Line学习笔记1

来源:互联网 发布:网络使人更亲近的例子 编辑:程序博客网 时间:2024/06/18 17:20

Basic Installation with qemu-kvm

创建虚拟磁盘

qemu-img create -f raw/images/hda 8G

  • create命令创建一个新的镜像
  • -f 指定镜像格式
  • /images/hda 镜像的路径
  • 8G 镜像大小

创建虚拟机

 qemu-kvm -name "ubuntu" -M pc-0.12 -m 768\

-smp 2 -boot d\

-drive file=/images/hda,if=virtio,index=0,media=disk,format=raw\

-drivefile=/isos/ubuntu.iso,index=1,media=cdrom\

-net nic,model=virtio,macaddr=52:54:00:05:11:11\

-vga cirrus -balloon virtio

  1.  VM的名字,显示在window的标题,VNC server使用,名字必须唯一。

  2.  指定机器类型(Standard PC, ISA-only PC, orIntel-Mac)。pc-0.12是Standard PC。

  3.  该虚拟机最大内存

  4.  指定一个2个处理器的SMP系统

  5.  指定启动顺序,可用值a, b (floppy 1 and 2), c(first harddisk), d (first CDROM), or n to p (Ether-boot from network adpter1-3). 默认为c。

  6.  定义第一块(index=0)硬盘,半虚拟化驱动(if=virtio)加速,raw格式。

  7.  定义第二块(index=1)镜像驱动作为CD-ROW。

  8.  定义半虚拟化网卡适配器(model=virtio),并设置MAC地址。

  9.  指定显卡,如果为指定,显卡不会被使用。

  10.  定义半虚拟化balloon device,允许内存动态变化

在客户操作系统安装完成后,启动虚拟机不在需要指定CD-ROM device:

qemu-kvm -name "ubuntu"-M pc-0.12 -m 768 \

-smp 2 -boot c \

-drivefile=/images/hda,if=virtio,index=0,media=disk,format=raw \

-netnic,model=virtio,macaddr=52:54:00:05:11:11 \

-vga cirrus -balloon virtio
 

 

 

原创粉丝点击