Monday, March 07, 2022

Install FreeDOS 1.3 RC5 on Proxmox

FreeDOS 1.3 RC5 was released recently, and I thought I would give it a try to see if I can run some old DOS games. Since I don't really have old PC hardware, I thought I can try to make a FreeDOS virtual machine on one of my servers, the Poweredge R430.

FreeDOS does not use a lot of resources, so I created a basic VM with 2 cores, 256 MB of RAM, and a 20 GB harddisk (to store the games, mostly; FreeDOS can easily be installed in something less than 500 MB; use a raw disk image instead of qcow2). For display, use SPICE since it allows you to forward sound.
 
If your virtual disk is not partitioned, the FreeDOS installer will try to partition it... the problem is that it will slice them into partitions of 2 GB max. So with 20 GB, that means 10 virtual harddisks. Not what I want. The way to avoid this is to manually format the virtual disk before installation. 
 
This is done within the FreeDOS live environment. Use the CD image to boot. Then, run
fdisk
and create a new primary partition, with the option to use FAT32, and all available space on the virtual harddisk. Once that is done,
reboot
to reboot the VM and boot into the FreeDOS live installer again. This time, you can choose the option to install FreeDOS. It should see that the harddisk is already partitioned, and will as if you want to erase and format the drive. Choose yes and continue with the installation.
 
If you cannot boot from the system harddisk, this could be because FreeDOS is mounting your harddisk as A drive instead of C drive. The solution is to add a placeholder floppy drive. (Got the hint to the solution from this page.) This can be done by creating the virtual floppy drive as a raw disk image. You will need mtools to do the manual format, which can be installed by
apt install mtools
 
Then, through the server's console, go to the directory where VM disk images are stored. This is usually /var/lib/vz/images/XXX (where XXX is the VM ID). Next is to manually create and format the disk image being used as a floppy disk.
qemu-img create adrive.raw 1440K
mformat -i adrive.raw

Once that is done, the VM's config file found in /etc/pve/qemu-server/XXX.conf (XXX is VM ID) and add
args: -audiodev spice,id=spice -machine pcspk-audiodev=spice -device sb16 -device adlib -device gus -drive file=/zfspool/pve430zfs/images/203/adrive.raw,if=floppy,index=0
By the way, if you see the above, you will realise that I have quite some "device" stuff... those are supposedly needed for sound.
 
Networking may also be a problem, so the best thing is to edit the VM's config file to use pcnet as the network adapter. Open the VM's config file found in /etc/pve/qemu-server/XXX.conf (XXX is VM ID) and change the line
net0: e1000=......
to
net0: pcnet=......
(basically, e1000 to pcnet)
This will allow you to start networking inside FreeDOS with the command
\freedos\bin\fdnet.bat 
 
FreeDOS also has a bonus CD with extra stuff, which you can mount to the VM after FreeDOS has been installed. Then, run
fdimples
which will allow you to install additional packages from the CD (either the installer or bonus CD, whichever is mounted).
 
I have yet to actually test the VM yet, because installing it took a long time... will test out sound to see if it works. For now... time to sleep.
 
Additional notes:
Getting sound to work is a pain. Maybe I should try this on a Raspberry Pi 4 instead like this post. Or try the instructions here on my Linux machine. Or this script?

Update March 22, 2022: I just saw this video and realised that I probably installed the official release of FreeDOS 1.3 instead of RC5. 😅

Notes:
Examples for running from the commandline:
qemu-system-x86_64 -name FreeDOS -machine pc-i440fx-4.2,accel=kvm,usb=off,dump-guest-core=off -enable-kvm -cpu host -m 64 -overcommit mem-lock=off -no-user-config -nodefaults -rtc base=utc,driftfix=slew -no-hpet -boot menu=on,strict=on -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on -hda freedos.img -cdrom FD13LIVE.iso -device sb16 -device adlib -soundhw pcspk -vga cirrus -display sdl -usbdevice mouse

qemu-system-i386 -hda freedos.img -m 64 -soundhw sb16,adlib,pcspk -vga cirrus -net nic,model=pcnet -cdrom FreeDOS_installer.iso

qemu-system-i386 -hda msdos.img -m 64 -soundhw sb16,adlib,pcspk
 
The SoundBlaster configuration, which should be in AUTOEXEC.BAT:
BLASTER=A220 I5 D1 H5 P330 T5

For running as a VM within another VM that has a desktop, like Linux Mint.

No comments: