DOS Subsystem for Linux on a HP t5745
Interesting results
Last Modified: 20240209
Mission of the project
Figure out how hard it would be to build DOS Subsystem for Linux and run it on real hardware
It turns out, it's not that hard. Download precompiled bits here. Download the 2023 precompiled bits here.
Spun up a quick Ubuntu 20.04 VM on VirtualBox 6.1. YMMV on other OSes. Allocating more cores/threads to your VM can help make the builds go faster later.
I didn't keep great notes on setting up the VM, but I think you could get away with just the following packages:
# sudo apt install build-essential git gcc make nano flex bison libssl-dev mtools nasm zip unzip
Please correct me if I'm wrong.
Then clone a couple repos
# git clone --depth=1 https://github.com/haileys/doslinux.git
# git clone --depth=1 https://github.com/richfelker/musl-cross-make.git
Now you need to build the cross compiler for doslinux
# cd musl-cross-make
Configure the cross compiler builder files to match the original repo (I see some easy optimizations here. More experimentation to come later.)
# cp -v config.mak{.dist,}
Edit config.mak .
# nano config.mak
Minimally, uncomment line 10 (CTL-c to display current line) and change to i386 per doslinux repo
# TARGET = i486-linux-musl ---> TARGET = i386-linux-musl
and uncomment line 23
# OUTPUT = /usr/local ---> OUTPUT = /usr/local
CTL-o to Save the file then hit ENTER. CTL-x to Exit nano.
Build the cross compiler & then install it to /usr/local
# make && sudo make install
Test to make sure that cross compiler is in your $PATH and gives a version of 9.2.0
# i386-linux-musl-gcc -v
With the cross compiler out of the way, onto the doslinux prereqs, busybox 1.32.0 and Linux 5.8.9 kernel.
Build the preqreqs presuming you're still in ./musl-cross-make, (set J to match the number of threads/cores you have)
# cd ../doslinux/script
# J=1 sh build-prereq
If all goes well, after 15-30 minutes, you have no errors in either build, you should have a Linux kernel bzImage at ../linux-5.8.9/arch/x86/boot/bzImage and busybox binary at ../busybox-1.32.0/busybox_unstripped
From here, you need to build the actual doslinux code. This results in 2 binaries. A DOS COM binary doslinux.com which will boot the Linux kernel image bzImage and a Linux binary init which finishes the Linux boot process and handles the VMM/VM86 swapping back to DOS.
The current doslinux Makefile presumes you're using some sort of VM tooling like VirtualBox, QEMU, etc., so it intends to write the resulting binaries to a hard drive image. Not as useful for real hardware. So we'll do something different for us. Instead we'll put the necessary bits in a zip file for easier transport. If you wanted use a HDD image, I suggest this one from FreeDOS (http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/qemu/qemu-fd12-full-src.zip).
Jumping back into the doslinux folder from the script subfolder and build doslinux
# cd ../
# make doslinux.com init/init
Make the folder format that dislinux wants
# mkdir -pv DOSLINUX/ROOTFS
Copy the binaries in
# cp -v linux-5.8.9/arch/x86/boot/bzImage DOSLINUX/BZIMAGE
# cp -v init/init DOSLINUX/INIT
# cp -v busybox-1.32.0/busybox_unstripped DOSLINUX/BUSYBOX
# cp -v doslinux.com DOSLINUX/DSL.COM
Zip it up
# zip -9vvr DSL.ZIP DOSLINUX/
My HP t5745 Thin Client (Intel Atom N280, 2GB DDR3 RAM, 2GB IDE DOM Flash Drive) has great support for USB booting. I started with this USB image (http://www.freedos.org/download/download/FD12FULL.zip) from FreeDOS 1.2 and an old Axiom 4GB USB 2.0 drive. Unfortunately doslinux does not like booting from emulated hard drives on USB drives. It hardcodes it's kernel parameters to using sda1, which I think limits doslinux greatly to PATA and SATA (maybe only AHCI?) drives and BIOSes that support BIOS emulation. (Maybe. More testing is needed.) So, instead, I installed FreeDOS 1.2 using the USB Lite Image (http://www.freedos.org/download/download/FD12LITE.zip) to my HP t5745's 2GB DOM. The FreeDOS 1.2 Lite Image will only gives you a 32MB partition on the USB drive which makes cramming the 7MB doslinux bits a bit difficult without modifying the USB drive file system further. So after installation, reimaged the USB drive with FreeDOS 1.2 Full and now we have 86MB free. Unzip the dsl.zip file to C:\ and you're all set to play with booting Linux on DOS.
Below are various screenshots of my experimentations with doslinux so far. Right-click to View Images in full size.
One issue to note, USB keyboard got stuck for some reason upon return to FreeDOS from Linux. :( Guess you just need to be sure you're switching to Linux permanently. I used C:\> dsl sh to be able to get a shell and run Linux multiple commands.
I have a few plans to improve upon doslinux, too. Namely:
Optimize the Makefile so that pre-built binaries are downloaded instead. At least busybox 1.31.0-i686-uclibc (static?) is available. Maybe I could find a bzImage too.
Have Make build all the dependencies.
Upgrade the Makefile/dependencies to use i686 arch. Should get a little performance bump for some things.
First DSL boot failures
One does not simply boot DOS Subsystem for Linux from USB. Also didn't like the soundcard.
Woohoo /proc/cpuinfo!
Boo...stuck keyboard?
Yup, still stuck
I think this is coming from Linux.
Now we're talking
I have access!
Yay! /proc/meminfo
Working
# cat /proc/meminfo | less
with busybox
df -h
There's the hard drive.
Not enough drivers for networking
Only lo and sit0.
But ls works
And it's in color!
Land of no return
And we're stuck again. Exiting Linux locks up the keyboard and hitting the power button on t5745 registers as a keyboard scancode?
Questions?
Contact [lpsantil{at}gmail.com ] for comments or feedback.