Sample Header Ad - 728x90

Make available a physical disk to existing Windows VM

5 votes
1 answer
2155 views
Problem: I have a new SATA drive I wish to sysprep with a Windows installation. I only have Windows virtualised on my PC. My Solution: Attach (passthrough) the entire drive to the Windows VM and sysprep as normal. This is my VGA/Passthrough script: #!/bin/bash #1st PART configfile=/etc/vfio-pci.cfg vfiobind() { dev="$1" vendor=$(cat /sys/bus/pci/devices/$dev/vendor) device=$(cat /sys/bus/pci/devices/$dev/device) if [ -e /sys/bus/pci/devices/$dev/driver ]; then echo $dev > /sys/bus/pci/devices/$dev/driver/unbind fi echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id } modprobe vfio-pci cat $configfile | while read line;do echo $line | grep ^# >/dev/null 2>&1 && continue vfiobind $line done #2nd PART xrandr --output DVI-D-0 --off /usr/bin/synergys --config /home/%username%/.synergy.conf export QEMU_ALSA_DAC_BUFFER_SIZE=512 QEMU_ALSA_DAC_PERIOD_SIZE=170 QEMU_AUDIO_DRV=alsa sudo qemu-system-x86_64 \ -enable-kvm \ -M q35 \ -m 8192 \ -cpu host,kvm=off,migratable=off,+invtsc,enforce \ -smp 4,sockets=1,cores=4,threads=1 \ -bios /usr/share/seabios/bios.bin -vga none \ -device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \ -device vfio-pci,host=06:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on \ -device vfio-pci,host=06:00.1,bus=root.1,addr=00.1 \ -soundhw all \ -drive if=none,file=/media/VM/windows1.img,id=disk,format=raw -device ide-hd,bus=ide.0,drive=disk \ -net tap,vlan=0 \ -boot menu=on sudo killall synergys xrandr --output DVI-D-0 --auto xrandr --output DVI-D-0 --right-of HDMI-0 exit 0 Question 1): I want to make /dev/sdc available to the VM. What -option format will achieve this. (To reiterate the new disk, sdc, has **no** content, partition or formatting at this point.) Question 2): Am I making life stupidly difficult for myself and is there is much simpler solution. Question 3) I do know that this can be achieved by using .xml script that virt-manager uses, but as you see I am not using virt-manager to launch the VM (because of the VGA Pasthrough), would it be possible to convert/import this startup script into the virt-manager .xml format and then add something like: ...to the `` section? Many thanks just for reading to end if you managed it.
Asked by themainliner (51 rep)
Nov 3, 2017, 04:51 PM
Last activity: Jun 30, 2025, 02:05 PM