DOS Subsystem for Linux: run Linux on DOS
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.
About The Author
Thom Holwerda
21 Comments
sukru 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).
r0b0 Please, do spoil! How does it work? I do not understand the x86 architecture enough to understand what the asm code is doing.
sukru 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.
ssokolow 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?”
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”.
r0b0 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
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
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.
The123king 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
brostenen 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.
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.
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.
Like… I do not think that Linus ever thought that his OS would end up mostly in routers and servers. But it did.
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.
jgfenix 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.
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.
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.
brostenen 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.
The1stImmortal 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.
kurkosdr 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?
mz721 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
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
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
Historically, “he” referred to a generic person whose gender is unspecified in formal language, but the gender-neutral singular they has long been common in informal language, and is becoming increasingly so in formal language. The use of the neuter pronoun ‘it’ in reference to a person is considered dehumanizing.
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.
I want to buy one apple: je veux acheté une pomme. (female, correct)
I want to buy one apple: je veux acheté un pomme (male, wrong)
I want to buy two apples: je veux acheté deux pommes (neutral, plural)
These kinds of gender semantic games have bugged me for ages, but I didn’t create the problem. I just live with it. 🙁
Alfman 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.
Разработчик опубликовал DOS Subsystem for Linux
Разработчик из Австралии Чарли Сомервилл (Charlie Somerville) опубликовал на GitHub альтернативу WSL (подсистема Windows для Linux) для тех компьютерных энтузиастов, кто предпочитает среду MS-DOS. Проект DOS Subsystem for Linux (DSL) доступен для всех пользователей под свободной лицензией GNU AGPL.
В DSL среда Linux интегрирована в систему MS-DOS. Пользователи могут запускать приложения DOS и Linux из командной строки DOS. В настоящее время DSL можно запустить в MS-DOS 6.22 или FreeDOS.
Когда DSL впервые вызывается из командной строки, то загружается ядро Linux, которое берет на себя управление компьютером из DOS. Фактически DSL запускает реальную копию MS-DOS на виртуальной машине QEMU и запускается с нее. Сомервилл использовал в проекте режим процессора под названием VM8086, который позволяет в 32-битной ОС запускать 16-битный legacy-код как нативный. Причем в этом случае Linux во время процесса загрузки не влияет на размер памяти DOS системы, оставляя нетронутым первый мегабайт памяти, где находится DOS. Так что для возврата к выполнению DOS команд Сомервиллю не нужно было придумывать что-то нового.
Сомервилл уточнил, что такой подход к запуску DOS под VM8086 на самом деле является тем, как работала ранняя Windows. Теперь разработчик заново открыл для себя эту технику много лет спустя.
В настоящее время Сомервилл дорабатывает DSL. Сейчас эта подсистема поддерживает эмуляцию только некоторых аппаратных средств. Например, поддерживается работа клавиатуры одновременно сразу в двух операционных систем на одном и том же оборудовании. Также разработчик сумел запустить DSL на реальном оборудовании помимо запуска с помощью виртуальной машины QEMU.
Предлагаемое в примере DSL ядро основано на выпуске ядра Linux 5.8.9.
Пример запуска DSL в системе.
Microsoft также занимается улучшением поддержки Linux в Windows 10 с помощью подсистемы Windows для Linux (WSL). Предлагаемое Microsoft для WSL2 ядро основано на выпуске ядра Linux 4.19. В WSL добавлена поддержка компьютерных вычислений на GPU. Разработчики могут полноценно использовать свои аппаратные ресурсы, например, для машинного обучения, используя NVIDIA CUDA и DirectML. В Linux-окружении можно запустить TensorFlow и PyTorch. В начале сентября этого года Microsoft добавила в подсистему Windows для Linux 2 (WSL2) возможность монтирования дисков. С помощью WSL2 можно запускать в Windows 10 не только консольные приложения, но и линуксовые GUI-программы.