Advertisement
Guest User

kvm-install

a guest
Oct 1st, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. INSTALLFILE=win7-uefi-x64_system.qcow2
  4. FILESIZE=50G
  5.  
  6. INSTALLCD=/data/operatingsystems/windows7/win7sp1x64noeicfg.iso
  7. # if you use a hardware CD-ROM drive, check for the device. In most cases it's /dev/sr0
  8. #INSTALLCD=/dev/sr0
  9.  
  10. DRIVERCD=/home/mobi/Downloads/virtio-win-0.1.110.iso
  11.  
  12. # PCI address of the passtrough devices
  13. DEVICE1="01:00.0"
  14. DEVICE2="01:00.1"
  15.  
  16. # load vfio-pci module
  17. modprobe vfio-pci
  18.  
  19. for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
  20. vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
  21. device=$(cat /sys/bus/pci/devices/$dev/device)
  22. if [ -e /sys/bus/pci/devices/$dev/driver ]; then
  23. echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
  24. fi
  25. echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
  26. done
  27.  
  28. # create installation file if not exist
  29. if [ ! -e $INSTALLFILE ]; then
  30. qemu-img create -f qcow2 $INSTALLFILE $FILESIZE
  31. fi
  32.  
  33. QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
  34. qemu-system-x86_64 \
  35. -enable-kvm \
  36. -m 4096 \
  37. -cpu host,kvm=off \
  38. -smp 2,sockets=1,cores=2,threads=1 \
  39. -machine pc-i440fx-2.1,accel=kvm \
  40. -soundhw hda \
  41. -bios /usr/share/ovmf/x64/OVMF.fd `# SID version of OVMF` \
  42. -device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on \
  43. -device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
  44. -vga qxl \
  45. -device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
  46. -netdev user,id=user.0 \
  47. -drive file=$INSTALLCD,if=none,id=drive-ide0-0-0,readonly=on,format=raw \
  48. -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
  49. -drive file=$INSTALLFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=unsafe \
  50. -device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 \
  51. -drive file=$DRIVERCD,if=none,id=drive-ide0-1-0,readonly=on,format=raw \
  52. -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=3 \
  53. -rtc base=localtime,driftfix=slew \
  54. -smb /home/mobi/Downloads/toinstall \
  55. -usb \
  56. -device usb-tablet \
  57. -device usb-kbd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement