OpenBSD 5.1 on Hyper-V Server

Created Thursday 14 June 2012  

 

OpenBSD 5.1 on Hyper-V Server 2012 Release Candidate.  

 

OpenBSD 5.1 is the first guest operating system that I installed on my new virtualization server.  

 

What is OpenBSD?  

 

Why might I want to use OpenBSD?  

 

Why is OpenBSD a good choice for my virtual lab? 

Get the iso file. Size: 222 MB.

Place it in a folder on Hyper-V Server, e.g. C:\data for further use.  

 

Configure an external virtual switch if you need Internet connectivity.
Configuring the virtual machine.Use legacy network adapters. OpenBSD won't recognise Hyper-V's synthetic network adapter. The legacy adapter is recognized as 'de'.  

 

Everything you need to know about the installation process:
4 - OpenBSD 5.1 Installation Guide  

 

Installation was straigthforward. No problems occured.
10 minutes for answering the questions of the installer. 10 minutes for the installer to copy and untgz the sets. Be aware: no Integration Services for OpenBSD available.  

 

The old bug, is still present in Microsoft Hyper-V Server 2012 RC
The AltGr key does not work on a Linux virtual machine on a Windows Server 2008-based server that has the Hyper-V role enabled
is history now. It also affected OpenBSD. So no more registry hack necessary.  

 

In the future a powershell script will configure the virtual machine automatically.  

 

Adapted from Virtualization: Create Hyper-V Virtual Machines with Windows PowerShell , which is a Powershell Version 2 script based on the PowerShell Management Library for Hyper-V.


Hyper-V Server 8 ships with Powershell 3.0 and its own hyper-v module.
With a little help from a friend I wrote the following Powershell script.  

 

New-OpenBSDImage.ps1  

 

# Variables

$SRV1 = Read-Host "Enter the Virtual Machine name (Press [Enter] to choose Server01): "if ($SRV1 -eq ""){$SRV1="hypervsrv"} ; if ($SRV1 -eq $NULL){$SRV1="hypervsrv"}

 

$SRAM = Read-Host "Enter the size of the Virtual Machine Memory (Press [Enter] to choose 128MB): "if ($SRAM -eq ""){$SRAM=128MB} ; if ($SRAM -eq $NULL){$SRAM=128MB}

 

$SRV1VHD = Read-Host "Enter the size of the Virtual Machine Hard Drive (Press [Enter] to choose 8GB): "if ($SRV1VHD -eq ""){$SRV1VHD=8GB} ; if ($SRV1VHD -eq $NULL){$SRV1VHD=8GB}

 

$VMLOC = Read-Host "Enter the location of the Virtual Machine file (Press [Enter] to choose C:\HyperV): "if ($VMLOC -eq ""){$VMLOC="C:\HyperV"} ; if ($VMLOC -eq $NULL){$VMLOC="C:\HyperV"}

 

$Network1 = Read-Host "Enter the name of the Virtual Machine Network (Press [Enter] to choose Network1): "if ($Network1 -eq ""){$Network1="Network1"} ; if ($Network1 -eq $NULL){$Network1="Network1"}

 

$Network2 = Read-Host "Enter the name of the Virtual Machine Network (Press [Enter] to choose Network2): "if ($Network2 -eq ""){$Network2="Network2"} ; if ($Network2 -eq $NULL){$Network2="Network2"}

 

# Configure Hyper-V Virtual Network

# remove-vmswitch $Network1 -force -erroraction silentlycontinue

Remove-VMSwitch $Network1 -force -ErrorAction SilentlyContinue

Remove-VMSwitch $Network2 -force -ErrorAction SilentlyContinue

# new-vmprivateswitch $Network1

New-VMSwitch -Name $Network1 -SwitchType Internal

New-VMSwitch -Name $Network2 -SwitchType Private

 

$ISOPATH = "C:\data\install51.iso"

 

# Create Virtual Machines

MD $VMLoc -ErrorAction SilentlyContinue

new-vm $SRV1 -path $VMLoc -SwitchName $Network1 # use legacy network adapters

New-VHD -path $VMLoc\$SRV1 -size $SRV1VHD -VHDFormat vhd -Dynamic

 

# add-vmdisk -vm $SRV1 -controllerid 0 -lun 0 -path $VMLoc\$SRV1

Add-VMHardDiskDrive -vm $SRV1 -controllerid 0 -lun 0 -path $VMLoc\$SRV1# Get-VHD –Path $VMLoc\$SRV1 |  

 

# get-vm $SRV1 | add-vmdrive -controllerid 1 -lun 0 -dvd

get-vm $SRV1 | Add-VMDvdDrive –Path $ISOPATH

 

# get-vm $SRV1 | set-vmmemory -memory $SRAM

Set-VMMemory -VMMemory $SRAM

 

# get-vm $SRV1 | add-vmnic -virtualswitch $Network1

Add-VMNetworkAdapter -IsLegacy $true -Name "External" -SwitchName $Network1

Add-VMNetworkAdapter -IsLegacy $true -Name "Internal" -SwitchName $Network2