Snapshotting single disk of running Hyper-V VM
- by modelnine
I'm currently somewhat at a loss of how to create a snapshot of a single virtual hard-disk of a running Hyper-V VM. Generally, creating a differential disk while a server is shut down is no problem (i.e., call the new-vhd cmdlet and pass a ParentPath, then update the VHD-binding of the respective VM-device), but while the host is running, all I can find is checkpointing the VM as a whole (which creates snapshots of all attached disks), and leaves the VM-state in a form which isn't easily processable by external tools (i.e., it requires reading additional meta-data from the VM).
Generally, what'd I'd like to happen for a single-disk snapshot (in my understanding) is:
Pause the VM
Rename current disk to some other name which specifies it as a base-snapshot
Create a new VHD which has the renamed VHD as parent path and is marked as "current"
Swap the VHD for the VM for the snapshotted hard-disk to the newly created differential VHD
Resume the VM
Is there any means to do this programatically?
Update: I've seen that this is actually possible with SCSI-disks, i.e. pause the VM, remove the SCSI disk, make the snapshot, reattach the SCSI disk at the same position, resume the VM. And, the VM resumes properly. But: is something similar also possible with G1 machines for the boot disk which is always IDE?