kvm vm deploy command memo
objectives
- personal memo
create disk image
VMNAME=''
qemu-img create -f qcow2 -o preallocation=metadata $VMNAME.qcow2 45G
deploy vm
RAM='' ### 8192 = 8GB
CPU='' ### 2 is multicpu
VNCPORT=''
ISOFILE=''
OSTYPE='' ###[linux, unix, windows, other]
echo $VMNAME $RAM $CPU $VNCPORT $ISOFILE $OSTYPE
- pattern 1
virt-install --connect qemu:///system \
-n $VMNAME \
-r $RAM \
--vcpus=$CPU \
--disk path=./$VMNAME.qcow2 \
-c ../osimages/$ISOFILE \
--os-type $OSTYPE \
--accelerate --network=bridge:br0,model=e1000 --hvm \
--graphics vnc,port=$VNCPORT,listen=0.0.0.0 \
-usbdevice tablet
- If you use vnc with mouse operation, add -usbdevice tablet or edit xml like following. (https://www.mail-archive.com/kvm@vger.kernel.org/msg25261.html)
<input type='tablet' bus='usb'/>
- pattern2
virt-install --connect qemu:///system \
-n $VMNAME \
-r $RAM \
--vcpus=sockets=1,cores=2,threads=2 \
--cpu Nehalem,match=exact,require=vmx \
--disk path=./$VMNAME.qcow2 \
-c ../osimages/$ISOFILE \
--os-type $OSTYPE \
--accelerate --network=bridge:br0,model=e1000 --hvm \
--graphics vnc,port=$VNCPORT,listen=0.0.0.0