"Reconnecting" to VMs...
-
When you said...
Quote:
however if you have a lot of VHDs
I thought 30-ish... but 159?!?! Humour me... WTH does one do with 159 VMs?
These are the Linux VMs I tinker with. How many Linux distributions do you know of? Variants of those distributions? Number of versions for each variant? It doesn't take long before it adds up. I'm not gonna claim I run many of them at the same time. And I only start deleting older versions when I start to run out of space. And unless you start collecting pictures/videos/music libraries (which belong on a NAS anyway), OS drives don't grow all that much. You can pack a lot of them on a 2TB SSD.
-
When you said...
Quote:
however if you have a lot of VHDs
I thought 30-ish... but 159?!?! Humour me... WTH does one do with 159 VMs?
fgs1963 wrote:
Humour me
No, you had it right first time :)
Paul Sanders. Not that the story need be long, but it will take a long while to make it short - Henry David Thoreau Some of my best work is in the undo buffer.
-
These are the Linux VMs I tinker with. How many Linux distributions do you know of? Variants of those distributions? Number of versions for each variant? It doesn't take long before it adds up. I'm not gonna claim I run many of them at the same time. And I only start deleting older versions when I start to run out of space. And unless you start collecting pictures/videos/music libraries (which belong on a NAS anyway), OS drives don't grow all that much. You can pack a lot of them on a 2TB SSD.
-
dandy72 wrote:
These are the Linux VMs I tinker with.
It's a wonder you're not 'cidal'* - after tinkering with 159 Linux VMs. :doh: I play with 2 or 3, pick one. Use it for a couple years then rinse and repeat. * either 'homo' or 'sui'
I typically don't spend all that much time with them individually - install them from newly-downloaded ISOs, make sure they can access the internet, download the latest updates, then leave them alone. *If* there's some distro I then decide I want to further tinker with, it's there and ready to go.
-
Hyper-V makes it trivial to create a new VM and point to an existing .VHD/.VHDX file to boot from it. This makes it rather easy to take a hard drive full of VMs, and move them to another machine and run those VMs from there. Even if all you have is VHD/VHDX files and not the associated config files. You may be asked to re-activate (in the case of Windows) in some instances, but it beats recreating a VM entirely from scratch. It gets tedious however if you have *a lot* of VHDs and have to manually recreate VMs one-by-one and point each instance to a different file. Hyper-V has lots of PowerShell cmdlets - has anyone ever tried to create a script that would (a) enumerate .VHD files starting from a given root folder and (b) create a new VM for each VHD it finds? I'm not looking for a full solution. Just some pointers as to what cmdlets might be useful to get the process going.
[Desired State Configuration](https://docs.microsoft.com/en-us/powershell/dsc/getting-started/winGettingStarted?view=dsc-1.1) may help
-
Sounds interesting, but overkill for the simple task I'm trying to do. And unless I'm misreading your response, PowerShell already has all the commands to do this nowadays. In the end, it turns out New-VM has all the params it needs to do a pretty decent job, so I banged together a smallish script after posting my previous question - by far the most complex part was deciding what to name the VMs being created based on the name of the subfolder a VHD/VHDX was found in. [Edit] My script recreated 159 VMs from 159 VHD/VHDX files it found in a bunch of folders on an external drive in well under 5 minutes. The script took less than 2 hours to write. If I ever re-use it a second time, its value will go up even more. Worth it.
-
This is a good example where you should post this as a question in a forum and then provide your answer. Google will help you find it later.
Well, I have my script now, and it's in a location where I won't have to search for long to find it. I considered posting it as a tip, but ultimately there's more code in the script trying to decide what folder name to use to name the VM (~40 lines) than actually creating it (one line)
-
[Desired State Configuration](https://docs.microsoft.com/en-us/powershell/dsc/getting-started/winGettingStarted?view=dsc-1.1) may help
I'm somewhat familiar with DSC. All I was trying to do here is "enumerate all existing VHD files, create a bog-standard VM mapping to each one of them". As I understand it, DSC serves a different purpose (defining templates, creating resources configured as dictated by said templates).
-
I'm somewhat familiar with DSC. All I was trying to do here is "enumerate all existing VHD files, create a bog-standard VM mapping to each one of them". As I understand it, DSC serves a different purpose (defining templates, creating resources configured as dictated by said templates).
DSC does not take a photo of the current setup and builds it again on the target system?
-
DSC does not take a photo of the current setup and builds it again on the target system?
Well, nothing really needs to be "rebuilt" in this case. I just have a bunch of fully functional VMs sitting on a disk. Their config files aren't that important; what matters is their disks (VHD files). It's really not all that different than taking an existing hard drive and putting it into another machine so it can boot from it. What I needed to do in my case is create new VMs, but at the step where you can either create a new VHD or use an existing file - point it to an existing file on disk. I really don't think DSC could have contributed much here. I could very well be wrong, but that's not my understanding of what DSC tries to do.