User Tools

Site Tools


tech:virt:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tech:virt:start [2019/06/12 17:52]
rk4n3 created
tech:virt:start [2022/11/13 23:24] (current)
rk4n3
Line 1: Line 1:
 <typo fs:​xx-large;​ fw:​bold>​Virtualization</​typo>​ <typo fs:​xx-large;​ fw:​bold>​Virtualization</​typo>​
 +
 +See [[:​tech:​linux:​ubuntu:​start#​virtualization_server|this section on Virtualization Server setup]] for more detailed pre-requisites
  
 <​code>​qemu-img create -f qcow2 -b baseimg vmname-vda 18G</​code>​ <​code>​qemu-img create -f qcow2 -b baseimg vmname-vda 18G</​code>​
  
-tech:virt \\+Sample start-up script: 
 +<code bash> 
 +#​!/​bin/​bash 
 +VMN=yourvmname 
 +VNC="​00"​ 
 +MAC0="​DE:​AD:​BE:​EF:​00:​00"​ 
 + 
 +VMH=/​var/​lib/​kvm 
 +VMC=qemu-system-x86_64 
 +CPUT=EPYC 
 +CPUS=8 
 +VMM=16G 
 +VGA="​-vga virtio -display gtk" 
 +# Headless ... 
 +#​VGA="​-vnc localhost:​${VNC} -daemonize"​ 
 + 
 +VGN="​yourlvmvolumegroupname"​ 
 +SIM= 
 +HD0= 
 +HD1= 
 +HD2= 
 +NIC0= 
 +NIC1= 
 +TPM= 
 +SND= 
 + 
 +# Boot device - d=cdrom, c=disk 
 +BOOT="​-boot c" 
 + 
 +function initTPM { 
 + local TPC="​swtpm"​ 
 + local TPD=$(ps -ef | grep swtpm | grep -v grep) 
 + if [ "​${TPM}"​ != ""​ -a "​${TPD}"​ == ""​ ]; then 
 + # echo "​NFO=>>>​ starting TPM ..." 
 + if [ "​${USER}"​ != "​root"​ ]; then TPC="​sudo -H ${TPC}"​ ; fi 
 + # echo "​DBG=>>>​ ${TPC} socket -d --tpmstate dir=/​var/​lib/​kvm/​${VMN}/​tpm --ctrl type=unixio,​path=/​var/​lib/​kvm/​${VMN}/​tpm/​sock --log file=tpm/​tpm.log,​level=20 --tpm2"​ 
 + ${TPC} socket -d --tpmstate dir=/​var/​lib/​kvm/​${VMN}/​tpm --ctrl type=unixio,​path=/​var/​lib/​kvm/​${VMN}/​tpm/​sock --log file=tpm/​tpm.log,​level=20 --tpm2 
 + else echo "​NFO=>>>​ software TPM daemon detected, skipping its startup"​ ; fi 
 +
 + 
 +function vmOptionsWin11 { 
 + CPUT=EPYC,​kvm_pv_eoi=on 
 +#​ SIM="​-cdrom ${VMH}/​iso/​Win11_English_x64v1.iso"​ 
 +#​ SIM="​-cdrom ${VMH}/​iso/​virtio-win-0.1.208.iso"​ 
 + HD0="​-hda vda" 
 + HD1="​-drive file=/​dev/​${VGN}/​dwin,​index=1,​media=disk,​format=raw"​ 
 +#​ NIC0="​-netdev bridge,​id=${VMN}eth0,​br=br0 -device e1000,​netdev=${VMN}eth0,​mac=${MAC0}"​ 
 + NIC0="​-netdev bridge,​id=${VMN}eth0,​br=br0 -device virtio-net-pci,​netdev=${VMN}eth0,​mac=${MAC0}"​ 
 + TPM="​-bios /​usr/​share/​ovmf/​OVMF.fd -chardev socket,​id=chrtpm,​path=/​var/​lib/​kvm/​${VMN}/​tpm/​sock -tpmdev emulator,​id=tpm0,​chardev=chrtpm -device tpm-tis,​tpmdev=tpm0"​ 
 + initTPM 
 +
 + 
 +function vmOptionsLinux { 
 + HD0="​-drive file=vda,​if=virtio"​ 
 +#​ HD1="​-drive file=/​dev/​${VGN}/​${VMN}home,​if=virtio,​index=1,​media=disk,​format=raw"​ 
 +#​ HD2="​-drive file=/​dev/​${VGN}/​${VMN}docker,​if=virtio,​index=2,​media=disk,​format=raw"​ 
 + NIC0="​-netdev bridge,​id=${VMN}eth0,​br=br0 -device virtio-net-pci,​netdev=${VMN}eth0,​mac=${MAC0}"​ 
 +#​ NIC0="​-netdev bridge,​id=${VMN}eth0,​br=br0,​helper=/​usr/​libexec/​qemu-bridge-helper -device virtio-net-pci,​netdev=${VMN}eth0,​mac=${MAC0}"​ 
 +#​ NIC1="​-netdev bridge,​id=${VMN}eth1,​br=br1,​helper=/​usr/​libexec/​qemu-bridge-helper -device virtio-net-pci,​netdev=${VMN}eth1,​mac=${MAC1}"​ 
 +
 + 
 +function vmOptions { 
 + if [ "​${USER}"​ != "​root"​ ]; then VMC="​sudo -H ${VMC}"​ ; fi 
 +#​ vmOptionsLinux 
 + vmOptionsWin11 
 +
 + 
 +cd ${VMH}/​${VMN} 
 +vmOptions 
 +${VMC} -machine pc,​accel=kvm -name "​${VMN}"​ -cpu ${CPUT} -smp ${CPUS} -m ${VMM} ${BOOT} ${VGA} ${NIC0} ${NIC1} ${HD0} ${HD1} ${HD2} ${SIM} ${TPM} ${SND} 
 +</​code>​
  
 //Links: [[tech:​start|tech]] ... [[:​start|main]]//​ \\ //Links: [[tech:​start|tech]] ... [[:​start|main]]//​ \\
  
  
tech/virt/start.1560379977.txt.gz · Last modified: 2019/06/12 17:52 by rk4n3