This is still the header! Main site

Windows on Linux

2020/10/01

Just read this ESR article about Microsoft potentially swapping out the NT kernel for Linux... there was also a youtube video. Of course, the comments range from "yes they have no other choice, this will change everything" to "no way".

Actually, thinking about it: it'd make a whole lot of sense. And no, almost nothing would change.

Remember Windows 95 vs. NT, continuing throughout 98, ME vs. 2000, and finally converging on XP? Well, it might end up being something like that.

Obviously, you'd need an emulation layer. They have some of it for MS SQL Server for Linux. But... as the existence of Wine shows, it's doable. And, if you're Microsoft, it's drastically less effort.

If you look at Wine source code, a lot of it is various COM classes and libraries and entire little Control Panel dialog boxes. It's to draw things the right way and to implement shell extensions and to account for InstallShield using DCOM for a reason that didn't quite fit on the margin. These have nothing to do with the underlying OS kernel; there is a reasonable chance that MS could also share them between 95 and NT, two drastically different kernels. They still have the sources; all it takes to create a perfectly backwards compatible implementation would be to copy over a DLL from Windows 10. Wine had to go the hard way not because of Linux but because they're not Microsoft who is just allowed to do that.

Also remember that Windows syscalls, unlike Linux ones, go through DLLs (ntdll.dll if I remember well); again, they could make the 98-NT compatibility work without even agreeing on what the syscalls look like (... given how many NT syscall names start with "Nt", it's likely that 95 had a dissimilar set... but, apparently, not even NT kernels agree on syscall numbers themselves, so everyone has to go through the lib anyway). I presume this is how Wine can hook them without fancy kernel patches. (And it's not like MS couldn't get in fancy kernel patches; even Android did it.)

In a way, writing a Linux emulator for Windows is harder than the opposite, syscalls-wise. And yet, they've done that, too.

So... if they wanted to, they could make most games and desktop apps work well on their new, Linux-based OS; Wine is almost there, from a much harder starting point.

"But how about all the drivers and antivirus software and stuff that needs deep system integration?", you might ask. The way they had to give up the actually-elegant idea of WSL-the-NT-subsystem in favor of opting for what's essentially a well-integrated Linux VM. Well... let's return to when 95 vs. NT happened. When 95 came around, they did have a large MS-DOS user base; 95 could use DOS drivers somewhat:

https://devblogs.microsoft.com/oldnewthing/20071224-00/?p=24063

even though it was fairly suboptimal... it worked. (Just as you can use ndiswrapper to use Windows network drivers under Linux.) However, 95 had its VXD driver interface; NT was drastically different (being a different kernel). Not only did they drop support for MS-DOS drivers and chunks of code (... being finally 32-bit-only), NT also couldn't use VXDs.

If this sounds like a disaster drivers-wise... well, no one really cared. NT was "for business"; if you were going to shell out for a big, beefy machine with tons of RAM (16 MB for NT 3.1, vs. Win3.1 ran happily with 2 MB), it was probably more okay if you had a more limited selection. From 1991 (NT 3.1, with limited uptake) through NT 4.0 (1996), there was plenty of time to improve on that. So, by the time Windows 2000 eventually gave place to Windows XP, aimed at all the weird half-broken PC hardware consumers might end up having, the transition was gradual enough so that no one really complained anymore that their WinME drivers don't work on XP. Including driver vendors! Same with any kind of software that depended on kernel internals.

Linux-based Windows could follow a similar introduction strategy... except this time, it's, again, significantly easier. They could start with Azure instances running... something that's both Windows and Linux, in the WSL 2 way, just going farther and farther with the merge, until they can just swap the two VMs: instead of running Linux under Windows, you could run Windows under Linux. There are plenty of ways for doing this; the point is, it's all hosted by them, drivers are not a problem, and you're unlikely to run antivirus either. Server management works as with Server 2019.

Apart from them hosting this hybrid on Azure (thus taking care of any hardware issues), they have another advantage: Linux is definitely not a brand new operating system, so it has drivers for... most hardware, really. So whenever they think they're ready for a (business-oriented!) hybrid half-Linux system (that still quacks like Windows, but has a Linux kernel underneath, with things like e.g. the Registry implemented as a compatibility layer), they could release it to actual users, with some lead time given to vendors, to, well, write Linux drivers.

And by "Linux drivers", I mean "Android-style stubs called into by closed-source blobs". Which they might even _have_ for Linux already. If you have a custom weird device with no driver updates... well, you can just keep using Windows 10 the way you could with WinME vs. 2000. (Yes there are probably still a lot of machines running 98 for various kinds of lab equipment because those didn't get NT-style drivers. Ever.) Antivirus & custom hackery, that formerly needed the actual NT kernel to work, will catch up with Linux, too; at least their UI will still run without many changes.

NT went from being "the default OS at businesses & schools" (... with a 1996 release date) to "customer-oriented" (XP, 2001) in about 5 years. That's plenty of time for vendors to catch up.

So here is a timeline. WSL has been around since 2016; WSL 2 is 2019. By, say, 2022, it could be extensively fancified: imagine COM calls between Linux and Windows, so that native Linux executables could e.g. produce a Windows GUI. Meanwhile, available only on Azure, there could be a "hybrid Linux-Windows server", sold as a production version of WSL. And then, suddenly, there is a Windows Server for Linux 2023, familiar UI, familiar management tools, weird drivers, no promises that all stuff will keep working. Choose this if you're a Windows shop but you want to run some Linux stuff; it's probably all in containers. Ubuntu is a container. Windows DLLs have control. Just as usual. It's just the kernel is Linux underneath.

And then XBox switches over. (Known hardware.) Embedded stuff switches over. Around 2025, business workstations switch over; hey, it's the new way, it's more stable, it's faster, you can make use of... containerization or some other enticing features? And "WSL" gets easier: it's no longer a VM.

2028: an update switches Windows 10 to a Linux kernel. No one notices. No one cares. Yes you can get a Linux command line... which you already could with WSL; now it's a bit faster. Less weird. Developers who flock to whatever is most convenient do like it a lot.

The Hacker News crowd has a debate over whether this is the year of the Linux Desktop or not. A lot more people start using the name GNU/Linux, or "free" Linux, or... just Linux, which Windows doesn't qualify as, just like Android is really borderline. In 2020, we had the "Linux phones"; this is similar. Meanwhile, Wine is alive and well; although Visual Studio now also has an ELF target, reimplementing all the interop between native-Linux and win32 (that is provided by proprietrary MS code lately) has been a challenging part. There are also some efforts that allow using Linuxy-Windows drivers under Linux. (Yes, technically it's Linux kernel modules, but their HAL keeps calling into proprietary Windows code, which needs to be replicated. (Just like libhybris does the same for Android.)

Of course there is still a C drive. (Under the hood, we've had a single tree with mounts since the NT kernel anyway.) Of course there are still exe files. Microsoft has contributed an excellent open-source NTFS kernel driver; there is also a set of ACL extensions to ext4 that support Windows SIDs, which the kernel now also supports. On actual Linux systems, you can set them up but user mapping is still a mess, with about 3 different solutions. On Windows, you can set this up per container, and there is a slightly hacky dynamic mapping with users.

Games have gotten slightly better on Wine; if you install a binary L-Windows driver, you can now translate directly DirectX to DirectX. Adobe is planning on just jumping over to ELF, too; it's supposed to be slightly faster that way, but it doesn't make a whole lot of difference. Someone even got it working via Wine once.

---

Well, anyway.

Back in the early 2000s, we the starry-eyed high-schoolers thought that once we got everyone to use computers and if Linux just worked (or people finally learned how to use it), the Microsoft monopoly would just fall over (giving way to free software), everyone would have their home servers running sophisticated info-processing, the widespread knowledge of the fact that things are copiable by nature would make evil movie & music companies obsolete, you'd see people writing code a lot, and you'd become cool automatically if you wrote some. Everyone would have websites, and communicate about all the things.

What actually happened: we got everyone to use computers, and Linux just works, especially on phones. And thus, in a way, the Microsoft monopoly fell over... and there is a lot more open source. And yet... people on average are even stupider about computers than they were before, with their preference towards Idiocracy-style touchscreen phone interfaces and the ease with which they can be herded towards "platforms", walled gardens compared to which 90s Microsoft was actually open. Everything is proprietary "cloud services" under the guise of "open web", with users treated as property of the respective companies, including the right to decide whether they are allowed to install stuff to their own hardware; yet, no one has any problem with any of this. The rebellion of "torrents" gave place to calling long-term rentals "ownership". Even cars start looking like this: the moment you connect something to the internet (what awesome promise this once had), the company behind now has a way to take control over it.

There is the social network site. The internet video site. The search company. (... once upon a time you could search for videos on the internet; now you just go to the video site.)

Does this get even worse?

But, regardless: the part where Windows will have a Linux layer underneath will not change any of this. Yet, it's not that hard to do, and Microsoft might be interested in doing it in the medium term, as an excellent example of "commoditize your complement". OS kernels aren't hot anymore; if you own the platform, you rule. They'd still have the layer above. Even Google has an iron grip on Android, even though _that_ thing is actively open-source.

In the end, it's not technologies that count, it's people.