Command-Line
從 CLI 創建虛擬機?(KVM)
如何從 CLI創建虛擬機?
創建虛擬機
First, download an ISO cd image of some OS you want to run. For Ubuntu, you can find these at: http://www.ubuntu.com/getubuntu/download Double click on the name of the host. The Status column should read Active Right click on the name of the host, and select New This will start a wizard to guide you through the rest of your VM creation Enter your virtual machine details Name: foo Choose Local install media (ISO image or CDROM), or you can use another method if you know what you're doing Forward Locate your install media Use ISO image Browse to find the ISO you downloaded earlier Optional: Select the matching OS Type Optional: Select the matching Version Forward
主要是為了我自己的啟迪。
只需使用:
virt-install \ --name vm_name \ --ram=2048 \ --vcpus=2 \ --disk pool=guest_images,size=30,bus=virtio,format=qcow2 \ --cdrom /var/iso/debian.iso \ --network bridge=kvmbr0,model=virtio \ --graphics vnc,listen=0.0.0.0,password=Qwerty1234 \ --boot cdrom,hd,menu=on
where
/var/iso/debian.iso
- iso 映像的路徑
guest_images
- 磁碟池,需要在vm之前創建
我經常通過這種 qemu 命令以舊方式使用 qemu-kvm:
qemu-img create mydisk.img 10G
qemu-system-x86_64 -boot d -cdrom image.iso -m 512 -hda mydisk.img
virsh 將啟動 qemu-kvm。但它需要一些配置文件。有時繞過所有這些 xml 行並啟動 vm 會更容易。