Live data from Hacker News

DOS Subsystem for Linux

github.com

31–40 of 182 posts

Re: DOS Subsystem for Linux

#31
This used to be the best way to try Linux before live CDs became a thing. The first Linux distro I ever used (DragonLinux) was 'installed' by unzipping an 8mb zip file and running a BAT file. You could 'uninstall' it by deleting the directory it created next time you booted into DOS.

Re: DOS Subsystem for Linux

#32

Just wondering. Since "Windows subsystem for Linux" is running Linux on Windows, shouldn't it be named "Linux subsystem for DOS"?

EDIT: I stand corrected. A closer look at TFA confirmed that it is indeed DSL. I was confused by the screenshot which at first glance just shows DOS running in QEMU on Linux. But it goes deeper! Yes, that is correct. Windows Subsystem for Linux means it's one of Windows' subsystems which provides linux. This should be called Linux Subsystem for DOS.

This is a thing you execute under DOS to run linux commands. it provides Linux. (or at least pretends to do it that way around)

Re: DOS Subsystem for Linux

#33

So does this run DOS on Windows? Or DOS on Linux? Or Linux on DOS? Or DOS on Linux on Windows? Would be nice if there were an explanation in the README.

The GIF's prety much crystal clear: it runs QEMU on Linux. And QEMU runs whatever you want, because it's a machine emulator/virtualiser, in this case it's running as x86 with MS DOS on top.

No.... QEMU is being used to run DOS, since a) who runs DOS on metal these days, and b) how would you record the screen if you were running DOS on metal (I suppose you could use a capture card). Linux is running in a WSL-like environment on the DOS host.

Re: DOS Subsystem for Linux

#34
post #23

Just wondering. Since "Windows subsystem for Linux" is running Linux on Windows, shouldn't it be named "Linux subsystem for DOS"?

No, because this is running Linux on DOS.

Thanks, I thought it is running DOS under Linux before I saw you comments.

Re: DOS Subsystem for Linux

#35
post #12

Earlier quoted context omitted.

This runs Linux "inside" of DOS, allowing you to exec Linux i686 binaries "inside" of a DOS terminal I put inside in quotes because how this actually works is quite amusing (and apparently is actually how Windows 95 also works)

Is this explained somewhere? I'd love to read how it works (without trying to understand the source code).

Author here. I am planning to do an in depth write up of how this works, but it seems Hacker News found it sooner :)

When DSL is first invoked at the command line it boots up the Linux kernel which takes over control of the computer from DOS.

Now here’s the trick: DSL makes use of a processor feature called VM8086 which allows for a 32 bit operating system to run legacy 16 bit code mostly natively. This feature is how early Windows, DOS extenders, etc worked. The Linux kernel also supports VM86, although it is largely undocumented and not really used these days. I think dosemu is the only major user of VM86 on Linux.

DSL then returns to DOS, which has essentially been flipped inside out and is now unknowingly running inside a VM8086 task. Helpfully Linux does not appear to clobber DOS’s memory during its own boot process.

DSL does just enough emulation of hardware like the keyboard to make things work, allowing DOS raw hardware access for everything else. This situation of running two operating systems at the same time on the same hardware is extremely fragile and unsafe of course, but it does seem to work surprisingly well anyway!

Re: DOS Subsystem for Linux

#36
post #32

Earlier quoted context omitted.

EDIT: I stand corrected. A closer look at TFA confirmed that it is indeed DSL. I was confused by the screenshot which at first glance just shows DOS running in QEMU on Linux. But it goes deeper! Yes, that is correct. Windows Subsystem for Linux means it's one of Windows' subsystems which provides linux. This should be called Linux Subsystem for DOS.

This is a thing you execute under DOS to run linux commands. it provides Linux. (or at least pretends to do it that way around)

Windows subsystem for Linux is a thing you execute under Windows to run linux commands. It provides Linux.

So what's different?

Re: DOS Subsystem for Linux

#37
post #12

Earlier quoted context omitted.

This runs Linux "inside" of DOS, allowing you to exec Linux i686 binaries "inside" of a DOS terminal I put inside in quotes because how this actually works is quite amusing (and apparently is actually how Windows 95 also works)

Is this explained somewhere? I'd love to read how it works (without trying to understand the source code).

From a quick skim through the code:

- it first, if not yet present, starts Linux, via normal Linux kernel load. It passes over some pointers from DOS into /init arguments so that /init can know about DOS' context when Linux was first loaded

- Linux's /init then uses VM86 [1] to call back into DOS, back to the function that was run in DOS before Linux was loaded (vm86_return). This is a bit of a 'draw the rest of the fucking owl' deal, as it has to actually emulate a lot of DOS/PC behaviour (emulate INB/OUTB, etc). It's basically a small VM, like with KVM, but for 16-bit DOS.

- when DOS wants to run a Linux command, it now uses a special new interrupt (DOSLINUX_INT) to call into the kernel. This in turn triggers a VM86 exit, jumps into the VM86 monitor in /init, executes the command, and pokes the result back into DOS, resuming VM86 emulation.

[1] - https://en.wikipedia.org/wiki/Virtual_8086_mode

Re: DOS Subsystem for Linux

#38
post #36
post #32

Earlier quoted context omitted.

This is a thing you execute under DOS to run linux commands. it provides Linux. (or at least pretends to do it that way around)

Windows subsystem for Linux is a thing you execute under Windows to run linux commands. It provides Linux. So what's different?

This one runs on DOS.
Post reply on HN