Sun, 03 Aug 2008
Real DOS on a virtual disk
Sometimes you need to run DOS programs, like to flash BIOSs on your laptop. Sometimes, if you're Kragen, that lets you fix ACPI on your BIOS, giving you a hope that X will boot up more often than 1 in 3, sound will skip less, and the first PC card you insert will be assigned a valid IRQ. (The last one is particularly interesting: to get a working PC card before the promised joy of the BIOS update, you have to plug in one card, watch it get assigned the mostly broken IRQ 3, plug in a second card, watch it get assigned the useful IRQ 4, and then you can remove the first one. This is a good way to get a wifi card working.)
Here's a simple HOWTO for getting that going on a Linux machine without repartitioning or booting off external media.
I'll refer to aptitude; I'm assuming you're using a Debian/Ubuntu machine so that makes sense.
Step 1: Install syslinux
$ sudo aptitude install syslinux
Now memdisk is in /usr/lib/syslinux/memdisk .
You should copy it to /boot/ in case your root filesystem is encrypted:
$ sudo cp /usr/lib/syslinux/memdisk /boot/
Step 2: Get your DOS floppy in /boot
Debian packages FreeDOS in dosemu-freedos. Unfortunately that doesn't include a floppy image. Instead:
$ cd /boot $ sudo wget http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.0/fdboot.img
Step 3: Configure GRUB
Put this in your /boot/grub/menu.list and smoke it:
title FreeDOS kernel /memdisk initrd /fdboot.img boot
Step 4: Reboot, and choose FreeDOS!
Ta-da, you're done.
More options
For bonus points, you can customize the floppy disk image. The easiest way to modify is to mount it loopback:
$ sudo mount -o loop,mode=777 /boot/fdboot.img /mnt/
Then you can copy files into /mnt/, and then when you're done:
$ sudo umount /mnt/
Ta-da, the image has been changed! (Thanks to Kragen for confirming that this actually works.)
The lame old way to customize the image is to use "mtools."
P.S. Thanks to Albert Lee for explaining this trick to me in the first place!