TSCM Hyper-v Gen 1 to Gen 2 conversion

ThreatSTOP provides a Hyper-V generation 1 (Gen 1) Virtual Machine (VM) image for maximum compatibility. For those looking to implement advanced features required by Hyper-V Generation 2 (Gen 2) this guide will help you through the conversion process.

The following guide was modeled using a Windows 10 Hyper-V installation, but will closely resemble Windows Server implementations as well. You may need to adjust for your particular environment. This guide involves heavy manipulation of the VM disk with destructive commands so having prepared VM backups crucial before proceeding. For those upgrading a TSCM that has configured devices please see this guide for instructions on backing up your Hyper-V VM before beginning.

The general process involes converting the VM Virtual Harddrive (vhd) disk image we provide with a Virtual Hard Disk v2 (vhdx) format, booting into Ubuntu installer ISO to add UEFI booting capability required by Gen 2 VMs.

Step 1 - Convert VHD disk image to Gen2 compatible VHDX

Hyper-V Gen 2 VMs require vhdx disk images. We’ll need to convert the .vhd disk image ThreatSTOP provides to a .vhdx disk image.

Open Powershell on the <ul>server running Hyper-V</ul>. You’ll be able to use the built-in “Convert-VHD” cmdlet to upgrade the disk image format.

Convert-VHD –Path “Source vhd file” –DestinationPath “Destination vhdx file”

Please replace the example paths above with the location of your .vhd file or follow along below by copying/pasting the code snippet. The code snippet will download a fresh TSCM image from our servers and extract it to the Windows default Virtual Hard Disk directory for Hyper-V.

cd "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\"

Invoke-WebRequest https://downloads.threatstop.com/TSCM-HyperV.vhd.gz -OutFile "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\TSCM-HyperV.vhd.gz"
gzip -d "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\TSCM-HyperV.vhd.gz"

The next command will need to be executed in a powershell with admin privileges.

Start-Process powershell -Verb runAs # to open a powershell with Admin privileges

In the Admin Powershell instance run (updated the file paths as needed):

Convert-VHD –Path "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\TSCM-HyperV.vhd" –DestinationPath "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\TSCM-HyperV.vhdx"

Step 2 - Download Ubuntu ISO

Download Ubuntu Server ISO image from https://releases.ubuntu.com/noble/. This will be required to use it to boot your Gen 2 Hyper-V image and reconfigure it for Unified Extensible Firmware Interface (UEFI) booting. You will be able to eject the ISO image after we’re done. Again we’ll provide a powershell snippet below for those comfortable with command line interfaces.

cd "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\"

Invoke-WebRequest https://releases.ubuntu.com/noble/ubuntu-24.04.2-live-server-amd64.iso -OutFile "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\ubuntu24_amd64.iso"

Step 3 - Create Hyper-V Gen2 VM

Next we’ll create a VM by following the ThreatSTOP Hyper-V instructions making the following changes.

Hyper-V

To create a TSCM virtual machine:

  1. Download and uncompress the VHD file (compressed with gzip).
  2. Start the Hyper-V Manager.
  3. Select New > Virtual Machine to start with wizard.
  4. Enter a name and location of your choosing.
  5. Specify Generation 2 (required).
  6. Set the memory size. Use 2GB for all devices except A10 vThunder, which requires 10 GB.
  7. Select a network (e.g. Default Switch). The TSCM requires a single network interface with connectivity to the Internet.
  8. On the Connect Virtual Hard Disk screen, select Use an existing virtual hard disk v2 (vhdx) and browse to the uncompressed VHDX image file.
  9. Click Finish.
  10. Edit the settings of the new VM to set the number of Virtual Processors to 2.
  11. Edit the VM settings > SCSI controller > Add a DVD drive and mount the Ubuntu ISO image.
  12. Turn off secure boot in the Security subsection.
  13. The Virtual machine is ready to be started.

Please note you must turn off secure boot. It may be possible to get secure boot to work but this is outside of the scope of this guide.

Step 4 - TSCM to Gen 2 compatibility conversion

You can start the VM at this point. It may take some time for it to boot and take you to an Ubuntu “Try or Install” menu screen. Once there select “Try or Install”.

  • After ISO installer is loaded asking you to start setting it up. Press CTRL+ALT+F2 or CTRP+Option+F2 (Mac). If you are using Ubuntu Desktop ISO you can simply open up a terminal. This will take you to a linux shell command prompt.
  • Next run through the following commands. Please note the # indicates the following is a comment and should not be copied.
sudo apt install -y grub-efi-amd64
sudo gdisk /dev/sda
n # (new partition)
[enter] # (enter to take the default partition number 3)
[enter] # (enter to take the default first sector)
+100M # +100M sets partition size to 100MB
ef00 # enter ef00 GUID hex code to set to EFI partition type
c # to set a label for the new partition
3 # to select the partition ID set earlier
EFI-system # set partition label to EFI-system
w # write partition
y # accept changes
sudo partprobe /dev/sda # rescan partition map
sudo mkfs -t vfat -v /dev/disk/by-partlabel/EFI-system

sudo mount /dev/sda2 /mnt
sudo mkdir /mnt/boot/efi
sudo mount /dev/sda3 /mnt/boot/efi
sudo grub-install --target=x86_64-efi --boot-directory=/mnt/boot /dev/sda
# will see "Installation finished. No error reported" if all goes well.

Once this is complete you can either just type reboot to reboot the VM or shutdown now to halt it if you would like to take a snapshot before first boot.