Most active commenters
  • xienze(6)
  • kuschku(4)
  • JdeBP(4)

←back to thread

Ubuntu on Windows

(blog.dustinkirkland.com)
2049 points bpierre | 54 comments | | HN request time: 2.303s | source | bottom
1. zymhan ◴[] No.11390932[source]
"Linux geeks can think of it sort of the inverse of "wine" -- Ubuntu binaries running natively in Windows. Microsoft calls it their "Windows Subsystem for Linux"."

I find it amazing that you can have such a functional Ubuntu environment by translating system calls. Microsoft does have the advantage of Linux being open-source I suppose, while the Wine project had to reverse engineer DLLs. Or have you supply them on your own.

replies(9): >>11391001 #>>11391011 #>>11391074 #>>11391084 #>>11391105 #>>11391166 #>>11391290 #>>11391798 #>>11391866 #
2. grandalf ◴[] No.11391001[source]
Indeed. Perhaps it will increasingly make sense to design software for Linux and then run it on windows via this method. Over time the Windows system calls that are not needed by the linux overlay can be phased out.
3. UK-AL ◴[] No.11391011[source]
Windows NT had a POSIX subsystem awhile ago, not sure what happened to it. The NT Kernel was designed to have different personalities like Win32, OS/2, POSIX, etc

It could be an updated version.

replies(3): >>11391057 #>>11391465 #>>11391846 #
4. tonymillion ◴[] No.11391057[source]
I came here to make the same comment.

Its ironic (old)microsoft exerted so much effort to put the personalities in place (OS/2, posix etc), then (mid)microsoft systematically destroyed that work under Balmer, and now (new)microsoft are reimplementing the same thing under a (seemingly) completely different system.

replies(1): >>11391393 #
5. dec0dedab0de ◴[] No.11391074[source]
I would rather have the opposite. I would even pay for an official "Windows on Linux". There is a handful of games I would like to play, but other than that I have no interest in windows.
replies(4): >>11391181 #>>11391198 #>>11391351 #>>11392220 #
6. anonymfus ◴[] No.11391084[source]
>Microsoft does have the advantage of Linux being open-source

More correctly would be to say that Microsoft has advantage of user space libraries used in GNU/Linux distributions being open-source. Linux kernel itself being GPL2 is probably a problem for Microsoft's developers because of possibility to be accidentally exposed to it while researching documentation.

replies(1): >>11391115 #
7. drewg123 ◴[] No.11391105[source]
*BSD and Solaris have done have run linux binaries for years. Doing it on Windows is a bit more impressive, but given that there is a POSIX subsystem, its not all that surprising.

I didn't see any information about whether they do it using direct system call translation, or if they do it using shared library inter-positioning. In either case, its pretty cool!

8. digi_owl ◴[] No.11391115[source]
Thats why you do it clean room style.

One team to document, one team to implement based on that document.

replies(1): >>11391497 #
9. twic ◴[] No.11391166[source]
> I find it amazing that you can have such a functional Ubuntu environment by translating system calls

FreeBSD has been able to do this (with some limitations!) for years:

https://www.freebsd.org/doc/handbook/linuxemu.html

10. xienze ◴[] No.11391181[source]
Totally doable. Use KVM to virtualize Windows and (the important part) make sure your CPU and motherboard support VT-d. Then you can pass a graphics card (separate from the one you run Linux with, naturally) to the VM and get >95% of native performance. There's lots of videos of folks doing this.
replies(4): >>11391205 #>>11391210 #>>11391473 #>>11391500 #
11. wernercd ◴[] No.11391198[source]
The problem is that the user-base for Windows on Linux probably isn't worth Microsoft's time...

While it seems like it is worth Microsoft's time to keep people on Windows.

I for one look forward to having all my vulnerabilities in one place... Linux, windows, server, desktop...

12. plexicle ◴[] No.11391205{3}[source]
Hi. Do you mind linking one?

Thanks. :)

replies(1): >>11391275 #
13. wernercd ◴[] No.11391210{3}[source]
That's still "VM" not "Native".

You aren't running them "side by side"... you are running them "One inside the other".

Not exactly an apple-to-apple comparison.

replies(3): >>11391235 #>>11391363 #>>11391437 #
14. xienze ◴[] No.11391235{4}[source]
The performance hit is so negligible on modern hardware that the distinction doesn't really matter.
replies(3): >>11391346 #>>11391373 #>>11391476 #
15. xienze ◴[] No.11391275{4}[source]
Sure. Here's a guide: https://www.youtube.com/watch?v=w-hOr44oBAI

Here's the famous Linus Tech Tips 7-in-1 video: https://www.youtube.com/watch?v=LXOaCkbt4lI

16. jdub ◴[] No.11391290[source]
Windows NT was designed from the start to have modular subsystems. It was most infamously used to provide a POSIX subsystem which really only checked boxes on government acquisition forms. :-)

The reason WINE went with the library emulation route is because: (a) the Windows kernel doesn't have a stable system call layer, and (b) the Win32 API is massive anyway.

Windows has an easier time emulating Linux at the very lowest levels because Linux has an ABI stable system call layer. If you emulate those, you can run ANY Linux binary.

It also means Microsoft doesn't have to ship or support hundreds of Open Source projects. They ship the syscall layer, and distributions ship the user layer.

replies(4): >>11391432 #>>11391477 #>>11393730 #>>11480831 #
17. geofft ◴[] No.11391346{5}[source]
And the performance hit is almost certainly less than the relative performance of a "native" reimplementation of a foreign OS's syscalls that doesn't benefit from the decades of engineering work that went into making that foreign OS perform well.
18. zymhan ◴[] No.11391351[source]
I cannot possibly imagine a world where Microsoft cannibalizes their Windows Server sales by creating a Windows Emulation Layer for Linux.

Crossover is probably the best you'll get: https://www.codeweavers.com/products/crossover-linux

Otherwise, if you only need Windows to game, I'd highly suggested PCI Passthrough so that you can use your GPU in a Windows VM: https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVM...

replies(1): >>11391914 #
19. akiselev ◴[] No.11391363{4}[source]
That's a distinction without a difference if you're using a modern processor with special virtualization silicon like Intel VT-i/x/d or AMD-V. With these features, IO and memory management is completely isolated between different virtual machines at the hardware level so there is almost zero overhead. With VT-d, which allows you to dedicate DMA channels to a guest VM, you can completely bypass the the host for all types of hardware including PCI/e, USB, etc.
20. kuschku ◴[] No.11391373{5}[source]
Except, it does matter.

Not having a unified filesystem, not having a unified window manager, etc are quite some issues.

replies(2): >>11391395 #>>11391429 #
21. akiselev ◴[] No.11391393{3}[source]
To be fair, this new implementation is very completely different. If we had the same kind of experience with virtualization and hardware with VT-i/x/d or AMD-V when Microsoft was developing personalities, the chips would have landed very differently.
22. dllthomas ◴[] No.11391395{6}[source]
Those are not meaningful issues for the stated use case of playing some handful of games.
replies(1): >>11391949 #
23. xienze ◴[] No.11391429{6}[source]
As another posted pointed out, if you just want to bring up a VM for gaming, who cares?

Also, you can share directories between the native filesystem and the VM quite easily. And if you're using something like VirtualBox or VMWare there are "unity" windowing modes available.

replies(2): >>11391932 #>>11392670 #
24. cpach ◴[] No.11391432[source]
”It was most infamously used to provide a POSIX subsystem which really only checked boxes on government acquisition forms.”

Ah, so that was the rationale. I always found that subsystem curious.

25. Dylan16807 ◴[] No.11391437{4}[source]
The "Native" OS is also under the hypervisor. So effectively you have real CPU, real RAM, real GPU, and you can give it a real hard drive too. At that point does it really matter that the USB controller and network card are virtualized?
26. vram22 ◴[] No.11391465[source]
>Windows NT had a POSIX subsystem awhile ago, not sure what happened to it.

I was interested in that too, since I write Unix utilities and it is sometimes useful to have them work on Windows as well. I've done that (checked that it worked on Windows) with a few utilities in the past (written in C), that did not use any very Unix specific features that were not present on Windows. And remember reading around that time that Windows (I think it was from NT onwards) had a POSIX subsystem.

Then more recently, as in, a few months ago, I wanted to check that out again, and did. IIRC I read (maybe on a Wikipedia page) that the POSIX subsystem is not present in Windows any more.

27. ◴[] No.11391473{3}[source]
28. ◴[] No.11391476{5}[source]
29. philjohn ◴[] No.11391477[source]
IIRC, this is how the Linux binary compat on BSD works.
30. vram22 ◴[] No.11391497{3}[source]
What does "clean room" style mean, exactly? I've heard the term, but only in connection with semiconductor factories, I think. You're talking about software here.
replies(3): >>11391647 #>>11391686 #>>11391715 #
31. khedoros ◴[] No.11391500{3}[source]
I've heard that this works wonderfully for graphics, but the sound emulation is pretty terrible. At least, I've heard about clicks and pops when the game puts much load on the system. This was on a friend's machine; maybe he had it configured badly.
replies(2): >>11391547 #>>11391687 #
32. xienze ◴[] No.11391547{4}[source]
Well if you're giving some hypervisor-managed sound interface to the VM then I wouldn't be surprised to hear that. The answer is to get a cheap dedicated soundcard and pass it through to the VM, just like you would with the graphics card.
33. TillE ◴[] No.11391647{4}[source]
To avoid any hint of copyright infringement, a team reimplementing an API (or similar) must never have looked at the original code.

https://en.wikipedia.org/wiki/Clean_room_design

34. alcari ◴[] No.11391686{4}[source]
The usual term is "Chinese Wall" [1].

[1] https://en.wikipedia.org/wiki/Chinese_wall

35. SXX ◴[] No.11391687{4}[source]
First of all there is option to emulate different sound cards and I have no issues with Intel HDA other than microphone delay.

And you can also buy $5 USB sound card and have no issues at all. Or spend few bucks more and connect PCI sound card.

36. soapdog ◴[] No.11391715{4}[source]
means a group check the source and documents. Another group never sees the code, only the documentation, and proceed to implement whatever they need being able to say that they have not used the original code.

This is common in reverse engineering stuff.

37. david-given ◴[] No.11391798[source]
So, uh. I did this! Crudely. In 2010.

http://cowlark.com/lbw/

It's a Linux syscall translator for Windows. It works well enough to run a Debian userland, although it's got so many holes and rough edges that I would never, ever, ever suggest using it for anything other than a stunt.

It uses Interix to do most of the heavy lifting, so all LBW does is to translate from Linux syscalls to Interix syscalls; so we get a Unix filesystem and user permissions and sockets and fork etc for free. (Interix was great. I'm glad they're bringing it back from the dead.) Unfortunately not all the system calls directly map onto each other; so Interix has a native fork(), but Linux emulates with clone(). I couldn't make threads work.

A few of the biggest problems were:

- the Windows page size is 64kB; the Linux page size is 4kB. The ld.so loader will try to map two bits of executable within the same 64kB boundary, and, of course, this doesn't work on Windows. I crudely hack around it by allocating pages of RAM and copying things. Write-back mapping only works at all if the application lets mmap() pick the address.

- very very very different register usage. glibc on Linux uses gs as a 'pointer' to the current thread's private data area, via a special syscall. Windows resets gs to 0 on every interrupt! I crudely hack around this by intercepting null pointer dereferences, looking at the instruction to see if it was gs, and then reloading it with the right value.

- even then, that syscall sets gs to point at a GTD segment with a size of 2^32; this wraps round the entire address space, which allows very large offsets in gs to be treated as negative numbers. Windows doesn't let you create GTD segments. It only allows LTD segments, and it caps the segment limit to the end of the user address space, so this trick won't work. I crudely hack around this by intercepting segmentation violations, looking at the instruction to see it it's a [gs+negative number] dereference, and then binary patching the executable to use a different instruction.

- glibc is horrible and undocumented. There's a big pile of key-value strings pushed onto the stack above the environment when the process is initialised, containing various magic numbers. ld.so will just crash if you get this wrong. I spent a lot of time reverse engineering the ld.so source code to figure out what these were and how to set them up.

It was all vile and horrible, but it worked surprisingly well (i.e., it worked, which was surprising).

Using the NT kernel's personality system to implement Linux syscalls natively is totally the right thing to do; that's obviously what they're doing here.

I would love to know about the internal Microsoft politics which made releasing this possible. I wonder how long it's been brewing? I did LBW in about a month of evenings; the core logic wasn't hard. I wouldn't be at all surprised if this hasn't been floating about inside Microsoft for years.

replies(4): >>11391919 #>>11391920 #>>11393130 #>>11416892 #
38. mpweiher ◴[] No.11391846[source]
From elsewhere in this thread:

"Windows NT was designed from the start to have modular subsystems. It was most infamously used to provide a POSIX subsystem which really only checked boxes on government acquisition forms. :-)"

https://news.ycombinator.com/item?id=11391290

replies(1): >>11480800 #
39. icefox ◴[] No.11391866[source]
Some long term thoughts:

1) Linux has won the server (web) market. Developers would like to use a Unix box to work on their server code so they typically move to OS X. This could prevent that switch because they can still use Windows to developer their Linux server software.

2) Many projects start out as Linux and stay Linux and are only ported after much time and effort to Windows. Enterprises when faced with a tool that they want to use will also look to switch off Windows. Now rather than the cost of switching they only have to pay to upgrade their windows boxes to use the tool.

3) There is now a major incentive for developers to only build Linux binaries because it will work more places. This might cause a faster drain of developers as they eventually remove all windows specific code and can more easily migrate elsewhere. This feels eerily similar to the OS2 story and no doubt in the next week I expect to see more than a few articles discussing this very thing.

4) It will be much easier for Microsoft to bring much loved Linux tools to Windows so you can expect to see a more rapid increase of tools announced that now work for Windows.

replies(1): >>11415786 #
40. dec0dedab0de ◴[] No.11391914{3}[source]
I cannot possibly imagine a world where Microsoft cannibalizes their Windows Server sales by creating a Windows Emulation Layer for Linux.

Are there any Windows only server applications that would be useful in a non windows shop? I'm not trying to be snarky, I really can't think of any.

I would expect the most likely users to convert would be those using job specific desktop software.

41. joshumax ◴[] No.11391919[source]
I used to use your program on my XP box a while back... I told an MS exec about it and he seemed really impressed. It would be funny if they got some of the core ideas for this from LBW.
42. kuschku ◴[] No.11391932{7}[source]
> Also, you can share directories between the native filesystem and the VM quite easily. And if you're using something like VirtualBox or VMWare there are "unity" windowing modes available.

I tried them – they don’t work at all in KDE.

Arch linux host, KDE as DE, Windows 10 Guest, just leads to a big black box in unified mode, and windows don’t properly occur in the KDE taskbar.

What I expect is integration equal to WINE – automatically putting stored data into the correct folders, easily accessible and mounted, integrating windows with the taskbar, etc.

And yes, this is "just for games" – but try gaming on a multiscreen setup when the game doesn’t show up in your taskbar and you can’t minimize it.

replies(1): >>11392434 #
43. kuschku ◴[] No.11391949{7}[source]
They are when you want to use the game on multiscreen setups, or if you want to backup the game’s save files manually.

Source: I use my VM only for gaming, and it’s a horrible experience.

44. TallGuyShort ◴[] No.11392220[source]
I also would've expected more demand for the opposite. I don't see myself ever switching back to Windows, but I'd pay $$$ to have Microsoft Project fully supported on Linux. I have more than a few colleagues who would be interested in the rest of the Office suite too, but who make do with LibreOffice because other things on Linux are more important.
45. xienze ◴[] No.11392434{8}[source]
Maybe it's a KDE problem? Other people certainly have been successful. But I guess that's par for the course in Linux -- lots of incompatibilities depending on how your environment is set up. Something like WINE is never gonna get there for running games as well as a VM can. So the options realistically are using a VM or reboot. The VM option is really pretty good all things considered.
replies(1): >>11392503 #
46. kuschku ◴[] No.11392503{9}[source]
That issue was with the VM in unified mode.

With WINE, everything works fine – but not with UPlay.

So I can run the game, via UPlay in the VM (but not unified mode), or I can pirate it and run it in WINE.

But unified mode, or paid in WINE, doesn’t work.

47. stcredzero ◴[] No.11392670{7}[source]
As another posted pointed out, if you just want to bring up a VM for gaming, who cares?

Apple needs to do a utility that supports this as smoothly as Bootcamp supports multiple boot.

48. tropo ◴[] No.11393130[source]
That "big pile of key-value strings pushed onto the stack above the environment" is auxv. You can see it in the binary /proc/*/auxv files. It's generated by the kernel's ELF loader.
replies(1): >>11393470 #
49. david-given ◴[] No.11393470{3}[source]
Arrgh! I wish I'd known that six years ago. It'd have made life so much easier. I was trying to figure them out from reading the source code...
50. makomk ◴[] No.11393730[source]
Also (c) Windows isn't open source so there are licensing issues with Wine shipping actual Windows DLLs. Some of them do work under Wine but the project aims to replace as many of them as possible with emulated versions.
51. JdeBP ◴[] No.11415786[source]
> This feels eerily similar to the OS2 story and no doubt in the next week I expect to see more than a few articles discussing this very thing.

Although, as others have already pointed out, it differs in some very significant ways.

OS/2 2.x providing Win16 binary compatibility was an after-market system providing binary compatibility with applications made for the operating system that shipped "out of the box". Whereas this is the operating system that ships "out of the box" providing binary compatibility with applications made for an after-market operating system.

(Yes, yes. One could buy OS/2 pre-installed, and one can buy Ubuntu Linux pre-installed. The scale of that, in both cases, is nowhere near significant enough to change the basic fact that overall the two situations are the reverse of each other.)

Also: There was not the extent of existing tools available natively on both platforms, in the OS/2 case. The examples being waved around in the news now are things like Apache, Ruby, Node, and so forth. There wasn't the OS/2-and-Win16 analogue of (say) the Ruby developers deciding in the months to come that a Win32 port is too hard to maintain, and dropping it in favour of just running the Linux Ruby on the Windows NT Linux subsystem. Today's analogue of the OS/2 case would be a universe where there was no Win32 Ruby at all, and the Ruby developers deciding not to start making a Win32 version because the Linux one "is good enough for the few Windows users".

I suspect that drawing parallels based upon what happened with OS/2 2.x and Win16 is a mistake, and those thinking that this will mean an outflux of Windows development "because it happened with OS/2 2.x" (which was more like an influx of development that failed to happen) are indulging in wishful thinking.

There's also the minor matter that, during the OS/2 2.x and Win16 time, there was this little thing called Windows NT lying around, promising a route for OS/2 1.x, where the existing tools were, with its OS/2 subsystem. (It is ironic that we are once again looking at a Windows NT subsystem.) That has no equivalent this time around at all; unless one mis-casts UbuntuBSD (https://news.ycombinator.com/item?id=11326457) in that rôle. It doesn't really fit, though. "Look, all you people with Ubuntu Linux application softwares. Forget that minority Windows thing that you ported to a couple of years ago. Come bring your applications to this new FreeBSD instead." (-:

52. JdeBP ◴[] No.11416892[source]
Given that Interix is not being brought back from the dead ...

* https://news.ycombinator.com/item?id=11391841

... would you agree with a call for it to be?

53. JdeBP ◴[] No.11480800{3}[source]
That makes it seem that the POSIX subsystem only ever did that, which is not true at all. A better explanation is at https://news.ycombinator.com/item?id=11392369 , which gives a version number and a time frame for context. The POSIX subsystem was different in later years.
54. JdeBP ◴[] No.11480831[source]
This makes it seem that the POSIX subsystem only ever did that, which is not true at all. A better statement is at https://news.ycombinator.com/item?id=11392369 .