(This is a guest post by Antoni Sawicki aka Tenox)
While everybody is busy buzzing about Windows 11, I wanted to commemorate the finest operating system ever made by Microsoft – Nano Server.
The OS was somewhat esoteric, distant and unapproachable. It had a rather high entry barrier, requiring you to build it on a Windows Server 2016 host using PowerShell magic spells. You couldn’t just download and run it. Even if you managed to get it running, there wasn’t anything you could do with it for fun. People didn’t bother to even check it out. My goal is to demystify this a bit, lower the entry bar and made it super easy for people to hack it.
Background info (you can skip it)
Nano Server was an interesting attempt at creating a datacenter grade OS that’s not managed via local GUI, keyboard and mouse, but rather full automation, code and remote tooling. It went one step further than Server Core or Windows PE by completely removing GUI components and local shell. Hence it’s not actually called “Windows” or “Windows Nano” but rather simply “Nano Server”. Rumor has it, it started as MinWin. The OS has a rudimentary text mode console loosely resembling this of VMware ESXi. However Nano was much more than a bare metal hypervisor. It was a fully fledged operating system.
Ever since I first saw a demo on Microsoft Ignite (previously known as TechEd) I wanted to run aclock on the text console. Much like the WinNT BSOD edition. This article started around my efforts to run (or port if needed) aclock to this platform. At the time of writing, the technology has been dead for several years now and rigor mortis has kicked in. However all the artifacts and documentation are still available on Microsoft’s website. Probably not for long, so a good moment to do it now, before everything gets deleted from existence.
How to quickly deploy Nano Server and run command line apps on the console
The hard way: you need to download Windows 2016 Server (eval) and run a PowerShell command to produce a bootable VHD file. While installing, you may want the Desktop Experience. However Nano creation is basically just a PowerShell command so you don’t actually need it.
Microsoft provides (soon to be deleted) Nano Server Quick Start. However the steps are trivial so you can totally skip that and stick just to this:
- Launch PowerShell terminal window on WS2016 host.
- Run:
Import-Module D:\NanoServer\NanoServerImageGenerator -Verbose
(D:\ drive being where Windows Server CDROM is mounted) - Run:
New-NanoServerImage -DeploymentType Guest -Edition Standard -MediaPath d:\ -BasePath c:\nano -TargetPath c:\nano.vhdx -ComputerName nano -Development
(c:\nano folder and c:\nano.vhdx image will be created for you)
Done! This will build a .vhdx image that can be run under Hyper-V as Gen-2 VM (for Gen-1 or to run it on any other hypervisor change .vhdx to .vhd in -TargetPath
while running the PowerShell command).
The easy way: you can just download a pre-built VM image from here. There are VHD for Hyper-v Gen-1 and VHDX for Hyper-v Gen-2 and OVA for everything else.
Once you boot it up you will be greeted with a PowerShell prompt. Just like that! You can type cmd
to launch the good old cmd.exe shell. MS-DOS anyone?
Keep in mind, this is a developer mode, normally you would be greeted with login/password prompt and a boring menu that allows to change some networking settings and not much beyond that. In production mode you need to resort to hacks (or this) to get stuff running, fortunately nothing like that needed here.
So what can you run on it?
Firstly in order to get some external utilities going, you can mount a SMB share using net use
in cmd or New-SMBMapping
in PS world. Nano being a server and all, you can also share out a folder via net share
or use C$
(you may need to create a user by using either net user /add
in cmd or New-LocalUser
in PS). Alternatively you can install Posh-SSH and use SCP to transfer files. If you don’t have working network you can just shut it down, mount the vhd image on the host and copy stuff in to the image then detach the VHD.
Aclock worked on the first run, no issues, using standard win64 exe:
Wow! So looks like Nano console does have basic terminal controls. That opens quite a lot of possibilities. But can you run more complex apps? Text editors? Web browsers? GAMES?
Well, yes…, but likely not, but it really depends – on dependencies (read: DLLs).
From all the editors I tried XVI is probably the best:
Everything else has a variety of issues:
- The console is not a real text mode as was promised in MinWin or even was in NT BSOD. Rather it’s a weird graphical mode that merely emulates text.
- The font is lacking line drawing characters. Some editors like YEdit allow to use ASCII drawing characters fortunately.
- There is no reverse video. This manifests mostly in menus, etc. however it also applies to the cursor.
- There is no cursor, or rather the cursor is an underscore and not transparent cell. Moving arrow left in the CLI doesn’t actually move the cursor it erases characters. There is no line editing.
- Also related to reverse video, it appears Nano console has some weird issues with colors.
- Missing DLLs. Nano Server not being a Windows OS is missing a lot of Windows DLLs and it has its own nano DLL hell. This has actually been acknowledged in MinWin. As such a lot of apps will not launch due to dependencies.
For example YEdit works remarkably well except for the menus, which use reverse video:
Perhaps Malcolm could make a Nano edition of YEdit? 😉
So what about games?
Initially nothing worked as expected. Either due to line drawing, colors or previously mentioned DLL hell. There was one game that actually worked – PowerShell adaptation of snake:
But I wanted something better. I had high hopes for ascii-patrol, which is pure text mode and they build it for win64. Unfortunately the game requires a bunch of multimedia / sound DLLs from Windows which are not present in Nano.
Thankfully Neozeed has stepped in, took the source code, amputated all the multimedia stuff, borrowed the Unix clock code and gettimeofday, and used an older Visual Studio to build it. But he managed to produce a fully working and playable version!!!! Truly amazing stuff!
The binary is available here. To play the game scroll down one screen to start a mission. If you enter profile customization simply press ESC to get out. Thanks again Neozeed!
I’m hoping readers can find more text mode/ascii apps and games that will work on the console. Please comment and send links!
In another dimension, having a semi working text editor, Yori shell, smb/scp, maybe with help of mingw64, sdk tools or borrowed compilers from Visual Studio, one could have a self hosted developer workstation with this.
For now please just download the pre-build image, or make one yourself and run it in your favorite hypervisor and have some fun with it!
With this, goodbye Nano Server! You will be always remembered. I know folks at Redmond tried really hard to make it such beautiful gem.
from Hacker News https://ift.tt/3jy3cmh
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.