Friday, February 12, 2016

Running Windows Nano server on QNAP NAS device

How to run Windows Nano server on QNAP



Prerequisites:





Steps.


1.  Download and extract Windows 2016 ISO somewhere on HDD (I use 7-zip for this purposes)
2. Build WIM image by utilizing script below. At the end of the script you shall end up with c:\nanoserver folder with a bunch of subfolders beneath it

$Target_Drive = "C:"  
$cd_drive = "C:\win2016"  
###################  
$NanoTarget = join-path $Target_Drive "Nanoserver"  
$NanoServer = join-path $cd_drive "Nanoserver"  
$Nanosource = join-path $cd_drive "Sources"  
$DismPath = Join-Path $NanoTarget "DISM"  
New-Item -ItemType Directory $NanoTarget  
New-Item -ItemType Directory $DismPath  
foreach ($Filter in "*api*downlevel*.dll","*dism*","*provider*")  
    {  
    Get-ChildItem -Filter $Filter -Path $Nanosource | Copy-Item -Destination $DismPath -PassThru  
    }  
Copy-Item "$NanoServer\*" $NanoTarget -Recurse  

3. Convert VIM image into VHD file with powershell commad below

.\convert-windowsimage.ps1 -SourcePath .\NanoServer.wim -Edition CORESYSTEMSERVER_INSTALL -VHDPath .\nano.vhd -VHDFormat VHD -DiskLayout BIOS

4. You will end up with VHD file in your nano server directory
5. Update you VHD image with OEM drivers below. Make sure "mountdir" folder created first in your build folder.

dism\dism /Mount-Image /ImageFile:.\Nano.vhd /Index:1 /MountDir:.\mountdir
dism\dism /Add-Package /PackagePath:.\packages\Microsoft-NanoServer-OEM-Drivers-Package.cab /Image:.\mountdir  
dism\dism /Add-Package /PackagePath:.\packages\en-US\Microsoft-NanoServer-OEM-Drivers-Package.cab /Image:.\mountdir  
dism\dism /Unmount-Image /MountDir:.\MountDir /Commit  

6. You have fully working VHD now which you can import into Hyper-V if you want, but we need to convert it to qcow2 format used by QNAP by using qemu-img.exe tool

.\qemu\qemu-img.exe  convert -O qcow2 .\nano.vhd dest.img

7. Create new VM in QNAP with this image as HDD and you have yourself a working Nano server running on QNAP


Post a Comment