A WSL alternative for users who prefer an MS-DOS environment. DOS Subsystem for Linux integrates a real Linux environment into MS-DOS systems, allowing users to make use of both DOS and Linux applications from the DOS command prompt.
What is this unholy union.
This is how the best science starts off, not with a why but with a why not!
Wow! It actually kinda makes sense (will not spoil it now).
First I thought it was a hoax, especially after seeing the relatively thin source tree. Checking around, there was a simple Makefile a few assembly and C sources and that would be pretty much the main part. There was a linux kernel config, along with a busybox one, but those could be easily faked.
But digging into the code, I saw this line:
https://github.com/haileys/doslinux/blob/1425efd502312ea6175123d7dc05c83295b890bf/doslinux.asm#L114
And everything clicked. It can actually happen.
(Hint: It is not actually Linux running under DOS, but keeping both around with a very clever trick).
Please, do spoil! How does it work? I do not understand the x86 architecture enough to understand what the asm code is doing.
So, this is from reading the code, since I could not get it running, yet.
There is an “Unreal” mode in Intel CPUs. Basically it runs in 16 bit 8086 mode, but with 32 bit segment registers. That allows sharing data between 16 bit and 32 bit programs. This is an important piece of the puzzle.
The kernel loader first makes sure the low memory (640K) is not touched:
https://github.com/haileys/doslinux/blob/1425efd502312ea6175123d7dc05c83295b890bf/doslinux.asm#L418
That means even after loading Linux, the DOS will stay in memory, just idle.
After the linux kernel loads, it runs a program called “init”. Here init runs an infinite loop which, just jumps back to the vm86, which has the real mode DOS:
https://github.com/haileys/doslinux/blob/1425efd502312ea6175123d7dc05c83295b890bf/init/vm86.c#L622
From the point of DOS, it ran a program that returned, but kept Linux kernel in memory inaccessible to it.
From the point of Linux, it is running a vm86 program, which happens to be the original DOS code, and receiving commands to run new programs.
The entire “subsystem” is a communication protocol between the two translating things like interrupts or console inputs.
Sadly, the linguistically confusing rationale for the WSL name doesn’t apply to DOS because “subsystem” is an official item of jargon for how the NT kernel modularizes platform APIs like Win32, but DOS doesn’t have that excuse for reversing the meaning of “X subsystem for Y”.
When I read “DOS Subsystem for Linux”, all I thought was “DOSEMU? Is that you?”
ssokolow,
+1, this is linguistically annoying, haha.
I remember loading linux from dos using loadlin and using a subdirectory of the dos filesystem as linux root with umsdos
This was around 1997
r0b0,
That’s the very first thing I thought of too, but this looks like it lets users interact with linux from DOS, which is quite something.
Shocking that anyone would bother doing this now though. it makes me very curious about the author. I’m guessing he is a former DOS user who decided to revisit DOS after a couple decades. I would imagine a young linux user who wanted to try something like this would have just created “DOS shell” for linux instead of invoking linux from an actual DOS shell.
It’s one of those “Just because you can” projects. Sure, it had very little use today, but it’s still cool that it exists
I think it will have some kind of use somewere. Most likely in some obscure place, were you would not even think it was useable. Like… I do not think that Linus ever thought that his OS would end up mostly in routers and servers. But it did.
brostenen,
One of my clients is a company that still deploys DOS systems for automation, it was built eons ago. More recently though they’ve had a very hard time sourcing hardware with DOS drivers, such as network cards and certain USB & rs-485 peripherals. When the last supplier dried up, they purchased extra stock to last several years but around 2019 their stock depleted and they were desperate to get things working on new supportable hardware. I migrated their DOS environment into a VM.running on a linux host, so at least compatible hardware could be emulated.
He may not have known his OS would become as popular as it would. But given that unix was predominantly used in servers, it wouldn’t have been difficult to foresee how linux would end up there as well. Linux was designed to be a unix clone, mimicking both the good parts and the bad.
Yes. It was the best way to test Linux back then before vms were a thing: no need to repartition the disk and no need to modify the master boot record.
jgfenix,
You could also run linux inside the “bochs” emulator (qemu’s precursor). I noticed a comment in the “doslinux” project suggests that the author himself is a bochs user. I didn’t realize it was still getting updates after all this time.
https://sourceforge.net/p/bochs/news/
Anyways, it would suggest he’s running a Windows or Linux host, using bochs to create a virtual environment for DOS, and using his DOS program to load & run Linux in the virtual host alongside of DOS. This whole thing is so funny to me. I don’t know if networking works, but he could telnet/SSH from the virtual Linux instance back to the host and work that way, haha.
I remember that command “loadlin” as well. But I only remember the command name. I know I have been doing it as well as you, I just have no memory of how I used it back then. Was it Slackware or some other distro? I do remember having slack from some sort of shareware CD back in 1995. There were two different distro’s on that CD. Some 28 Floppy disks had to be made from image files. Or something along that line.
But I really don’t remember much, as the years between 1995 and 2001, were years were I tried out an insane amount of various distributions, because I my interrest in Linux were more to learn how to use it as a user and not super user, and because of I was still not ready to go fully Linux. From 2001 I kind of dug deeper, and ran pure Linux a couple of weeks on and off to learn it more. And then I switched fully in 2016.
But yeah…. I too remember the command Loadlin.
I seem to recall playing with some linux releases back in the day that were started by loadlin but would preserve the DOS environment and let you exit Linux back to DOS.
By the looks of it, this is doing something similar, but keeping the DOS environment running in a v86 environment with an IPC mechanism.
Neat…
Since DOSBox is not 100% accurate and PCem needs a CPU with good single-core performance to run well, does this mean the best way to run DOS on modern Windows is by installing WSL and DOSEMU?
I think this is a great project, though I suspect I don’t have the knowhow to get it to work myself. I might give it a try.
If you want to see UMSDOS in action, you can still find Grey Cat Linux (a joke on Yellow Dog, an early distro). It is very easy to install under DOS (eg in a FreeDOS VM):
http://www.ipt.ntnu.no/~knutb/linux486/download/greycat/greycat.htm
It is built on Slackware 3.5, which gives to an idea of how old it is (and which means you can add Slack packages to it from an old mirror), and comes as a bunch of floppy archives. The download seems missing from that page, but maybe its out there. I might have the files somewhere…
I note a couple of the comments on this post try to guess what ‘he’ is doing. A pretty cursory look at the github profile suggests that might just be a rather sexist assumption. https://github.com/haileys
Seems to be here:
https://web.archive.org/web/20110710023201/http://www.angelfire.com/anime/db/gcl/
mz721,
Yes I did say that: “it makes me very curious about the author. I’m guessing he is a former DOS user”. But I wasn’t actually thinking male or female (that is an assumption on your part, haha). It’s just that languages can be asinine about gender specific pronouns, and in these cases “he” is usually used by default when a gender isn’t known. So while I agree it’s a problem, I would suggest that the language itself is at fault rather than sexist assumptions of the speaker.
https://en.wikipedia.org/wiki/Gender_neutrality_in_genderless_languages
In French every noun is assigned a gender, which you just have to memorize. You may not know the proper gender of a word, but once again the language forces us to assign a gender in order to speak about the noun unless it’s plural. You can switch to plural to make the gender correct (similar to “they” in English) but that isn’t necessarily what you wanted to say.
These kinds of gender semantic games have bugged me for ages, but I didn’t create the problem. I just live with it.
We’re lucky the word “you” doesn’t carry gender in english, otherwise just think of how difficult it would be to talk to people on the internet vs in person, haha.