A developer from Melbourne got bored during the coronavirus lockdown so he ended up creating a DOS Subsystem for Linux (DSL). It is a tool that DOS users have never had so far: an integrated Linux environment similar to what Windows 10 users enjoy via Windows Subsystem for Linux (WSL).
The developer behind this DSL is Charlie Somerville, a software engineer who enjoys system programming and is interested in retro computing, especially when it comes to the 1990s Microsoft DOS and Windows.
Somerville told Itnews that he was inspired by Microsoft’s Windows Subsystem for Linux (WSL), so he wrote DSL for fun.
At first, he just wanted to see if he could get the Linux to boot from the DOS command line. Once that happened, he thought of taking it a notch higher to see if he can continue executing DOS once Linux was running.
“I’m mostly surprised by how smoothly the whole thing works given how *dodgy* it all is haha,” says Somerville.
How DOS Subsystem for Linux works?
DOS Subsystem for Linux is like a WSL alternative for users who prefer to work in an MS-DOS environment. DSL integrates a real Linux environment into MS-DOS systems, which lets users run DOS and Linux applications from the DOS command prompt.
Shedding further light on how DSL works, Somerville explained on a Hacker News thread:
“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 uses a processor feature called VM8086, which allows for a 32-bit OS to run legacy 16-bit code mostly natively. This approach of running DOS under VM8086 is actually how early Windows, DOS extenders, etc., worked. The Linux kernel also supports VM86, although it is mostly undocumented and not really used these days.
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 barely manages to emulate hardware like the keyboard to make things work and thereby allowing DOS raw hardware access for everything else. But it is to be noted that running two operating systems simultaneously on the same hardware is extremely fragile and unsafe, of course. Nevertheless, it seems to work surprisingly well.
To run DSL, you must:
- Have a cross toolchain targeting
PATH. This tool can build one for you without much hassle. Now set
- Build the prerequisites (Linux and Busybox) by running
J=xxx script/build-prereq, replacing
xxxwith the desired build parallelism
- Get a hard drive image
hdd.base.imgwith an installed copy of MS-DOS on the first partition
make(This will create a new hard drive image
hdd.imgwith DOS Subsystem for Linux installed)
C:\doslinux\dsl <command>to run Linux commands [you can also place
C:\doslinuxon your DOS
PATHfor more convenience]
You can check out DSL on Github which seems to be working on MS-DOS 6.22 and FreeDOS.