Getting a DietPi image running on Hyper-V

Why? Because it is faster to test installs and adding items to the DietPi installer with snapshots! Also it makes a great small Linux installation to run other items off in Hyper-V.

  1. Go get the VirtualBox VMWare x64 image from the DietPi site. http://dietpi.com/#five
  2. Download the QEMU disk image utility from https://cloudbase.it/qemu-img-windows/
  3. Extract the VirtualBox VMWare image, it is a ova file. At this point we need to take the actual disk image out of this file. I use 7zip for this purpose. Right click on the ova file and open archive. Then extract the VMDK file out.
  4. Extract the QEMU disk image utility to the same folder as the VMDK file and then run the following command changing the file names as needed:

.\qemu-img.exe convert ‘.\DietPi_v120_VirtualBox-x86_64-(Jessie)-disk1.vmdk’ -O vhdx -o subformat=dynamic ‘.\DietPi_v120_VirtualBox-x86_64-(Jessie)-disk1.vhdx’

.\qemu-img.exe convert “dietpi_vm.vmdk” -O vhdx -o subformat=dynamic ‘.\DietPi_VMWare-x86_64-Stretch.vhdx’

Now you need to open up Hyper-V and make a new VM using the image you just extracted. You may want to keep a copy around to make more images in the future. Related Posts: HA on Pine64 with DietPi

2018/01/30 - Update

Updated to use the VMWare image.

$zipexe = ‘C:\Program Files\7-Zip\7z.exe’
$qemuZip = “qemu-img-win-x64-2_3_0.zip”

Push-Location $env:TEMP
if(-not (Test-Path “dietpiimage”)) {
New-Item “dietpiimage” -Type Directory
}

Push-Location “dietpiimage”

Remove-Item * -Exclude @(‘.7z’,’.zip’)

if(-not (Test-Path $qemuZip)) {
Invoke-WebRequest -Uri “https://cloudbase.it/downloads/$qemuZip" -OutFile $qemuZip
}
& $zipexe x $qemuZip

### Image download and conversion

$imageName = “DietPi_VMWare-x86_64-Stretch”

if(-not (Test-Path “$imageName.7z”)) {
Invoke-WebRequest -Uri “http://dietpi.com/downloads/images/$imageName.7z" -OutFile “$imageName.7z”
}
& $zipexe x “$imageName.7z”

$disk = (Get-ChildItem *.vmdk)[0]
.\qemu-img.exe convert “$disk” -O vhdx -o subformat=dynamic “.\$imageName.vhdx”

Write-Host “$imageName.vhdx is ready!”

2018/07/01 - Stretch Update

Here is a PowerShell script to make it faster.

Push-Location $env:TEMP
if(-not (Test-Path “dietpiimage”)) {
New-Item “dietpiimage” -Type Directory
}

Push-Location “dietpiimage”

Remove-Item * -Exclude @(‘.7z’,’.zip’)

if(-not (Test-Path “DietPi_VirtualBox-x86_64-(Stretch).7z”)) {
Invoke-WebRequest -Uri “http://dietpi.com/downloads/images/DietPi\_VirtualBox-x86\_64-(Stretch).7z" -OutFile “DietPi_VirtualBox-x86_64-(Stretch).7z”
}

if(-not (Test-Path “qemu-img-win-x64-2_3_0.zip”)) {
Invoke-WebRequest -Uri “https://cloudbase.it/downloads/qemu-img-win-x64-2\_3\_0.zip" -OutFile “qemu-img-win-x64-2_3_0.zip”
}

$zipexe = ‘C:\Program Files\7-Zip\7z.exe’
& $zipexe x “DietPi_VirtualBox-x86_64-(Stretch).7z”
& $zipexe x “qemu-img-win-x64-2_3_0.zip”

Rename-Item (Get-ChildItem *.ova)[0] “DietPi_VirtualBox-x86_64-(Stretch)_OVA.tar”
& $zipexe x “DietPi_VirtualBox-x86_64-(Stretch)_OVA.tar”

$disk = (Get-ChildItem *.vmdk)[0]
.\qemu-img.exe convert “$disk” -O vhdx -o subformat=dynamic ‘.\DietPi_VirtualBox-x86_64-(Stretch)-disk1.vhdx’

Write-Host “DietPi_VirtualBox-x86_64-(Stretch)-disk1.vhdx is ready!”

2017/09/20 - Update

Here is a PowerShell script to make it faster.

Push-Location $env:TEMP
if(-not (Test-Path “dietpiimage”)) {
New-Item “dietpiimage” -Type Directory
}

Push-Location “dietpiimage”

Remove-Item * -Exclude @(‘.7z’,’.zip’)

if(-not (Test-Path “DietPi_VirtualBox-x86_64-(Jessie).7z”)) {
Invoke-WebRequest -Uri “http://dietpi.com/downloads/images/DietPi\_VirtualBox-x86\_64-(Jessie).7z" -OutFile “DietPi_VirtualBox-x86_64-(Jessie).7z”
}

if(-not (Test-Path “qemu-img-win-x64-2_3_0.zip”)) {
Invoke-WebRequest -Uri “https://cloudbase.it/downloads/qemu-img-win-x64-2\_3\_0.zip" -OutFile “qemu-img-win-x64-2_3_0.zip”
}

$zipexe = ‘C:\Program Files\7-Zip\7z.exe’
& $zipexe x “DietPi_VirtualBox-x86_64-(Jessie).7z”
& $zipexe x “qemu-img-win-x64-2_3_0.zip”

Rename-Item (Get-ChildItem *.ova)[0] “DietPi_VirtualBox-x86_64-(Jessie)_OVA.tar”
& $zipexe x “DietPi_VirtualBox-x86_64-(Jessie)_OVA.tar”

$disk = (Get-ChildItem *.vmdk)[0]
.\qemu-img.exe convert “$disk” -O vhdx -o subformat=dynamic ‘.\DietPi_VirtualBox-x86_64-(Jessie)-disk1.vhdx’

Write-Host “DietPi_VirtualBox-x86_64-(Jessie)-disk1.vhdx is ready!”

Loading message from the API: ...