implement FDD/HDD removal/attachment to VM script

Started by ggnfs000, January 08, 2017, 06:01:57 PM

Previous topic - Next topic

ggnfs000

implement FDD/HDD removal/attachment to VM script

Spent last few days on writing ps1 scripts for attaching the FDD/HDD from VMs to be used for development purpose. The Oracle's virtual box was favored choice however it turns out it can not attach any device while VMs is powered on (hotplug).

So far  effort include:
attach/de-attach FDD/HDD from/to Vbox VM that is turned off (OK).

attach/de-attach FDD/HDD from/to Vbox VM that is turned on a.k.a hotplug (fail).
It appears vbox does not have a good support on this.
From vbox GUI, it certainly possibly to attach the HDD onto SATA controller (not IDE, SAS). However with WIN7 is running, the attached drive still does not show up dynamically under control panel's disk management so this is of no use. Only after reboot, the hotplugged HDD appears.

On hyper-v VM, with WIN7 running, I was able to attach HDD while VM running and the HDD does appear dynamically in disk management if SCSI controller is used. Therefore this appears to be most promising option. I already know FDD removal/attachment is possible with no issue onto hyper-V.

What is troublesome is I had difficulty using cli option of SCSI HDD hotplug, I need to explore this path:

Set-VMHardDiskDrive --VMName minix.dev.winxp -Path $null

On hyper-v VM options, SCSI controller can hotplug HDDs while VM is running.
5/25/2016, finally made the scripts working flawlessly, target boot system is set to vbox vm: minix.boot and dev machine is on hyper-v win7 machine,following two scrips stop/start.minix.boot will make it easier to disconnect FDD/HDD from target boot machine and hot-plug into dev machine and vice versa.

stop minix.boot ps1 script:

write-host "powering off minix.boot..."

vboxmanage controlvm minix.boot poweroff

start-sleep 5

write-host "disconnecting HDD from vbox minix.boot machine..."
vboxmanage storageattach minix.boot --type hdd --medium none --storagectl  SATA --device 0 --port 1
write-host "disconnecting FDD from vbox minix.dev.boot machine..."
vboxmanage storageattach minix.boot --type fdd --medium none --storagectl Floppy --device 0 --port 0

write-host "connecting FDD to minix development machine..."
Set-VMFloppyDiskDrive -VMName minix.dev.win7 -Path J:\hyperv.fdds\fd0.vfd
write-host "connecting HDD to minix development machine..."
Add-VMHardDiskDrive -VMName minix.dev.win7 -Path J:\hyperv.hdds\fat32.1gb.vhd -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0


start minix.boot ps1 script:

write-host "disconnecting FDD from minix development machine..."
Set-VMFloppyDiskDrive -VMName minix.dev.win7 -Path $null
write-host "disconnecting HDD from minix development machine..."
Remove-VMHardDiskDrive -VMName minix.dev.win7 -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0

write-host "attaching HDD to vbox minix.boot machine..."
vboxmanage storageattach    minix.boot --type hdd --medium J:\hyperv.hdds\fat32.1gb.vhd --storagectl SATA --device 0 --port 1
write-host "attaching FDD to vbox minix.boot machine..."
vboxmanage storageattach    minix.boot --type fdd --medium j:\hyperv.fdds\fd0.vfd --storagectl Floppy --device 0 --port 0

start-sleep 10
vboxmanage startvm minix.boot












Source: implement FDD/HDD removal/attachment to VM script