Creating customized FreeDOS images
Today I needed to update the firmware on a Supermicro server but the update package is only supplied as a DOS executable so I needed a FreeDOS live image to flash it. In the past I’ve used Rufus for this because it can automatically install FreeDOS on a flash drive. But I couldn’t use Rufus for 2 reasons:
- I didn’t have a computer with windows on hand.
- I have Ventoy on my flash drive and didn’t want to overwrite it.
FreeDOS has many installer images available on their Downloads page. I downloaded the “LiteUSB” image because it’s small and I don’t need any of the extra software that is included in the bigger images.
Then I needed to add the firmware update files to the image.
Adding space to the image
The FreeDOS 1.3 LiteUSB image is 32MiB in size and has ≈15MiB of free space in it. If the software you need to run fits in there you can skip straight to “Adding files to the image”. I needed 17MiB for the update so I had to add more space to the image. Here are the steps to do it.
Increase the size of the FreeDOS image to 64MiB.
$ truncate -s 64M FD13LITE.img
Resize the partition and filesystem to fill the added free space in the image.
fatresize
makes this very easy. -n 1
selects the first partition from the
image, -s max
makes it fill all available space.
$ fatresize -n 1 -s max FD13LITE.img
Adding files to the image
Mount the partition and copy necessary files onto it. udisksctl
is nice
because you don’t need root access. You can also use losetup
and mount
if
you have root access.
$ udisksctl loop-setup -f FD13LITE.img
Mapped file FD13LITE.img as /dev/loop0.
$ udisksctl mount -b /dev/loop0p1
Mounted /dev/loop0p1 at /run/media/user/FD13-LITE
$ cp /whatever/files/you/need /run/media/user/FD13-LITE/
Unmount the partition and detach the loop device.
$ udisksctl unmount -b /dev/loop0p1
Unmounted /dev/loop0p1.
$ udisksctl loop-delete -b /dev/loop0
Now the file can be copied to a Ventoy drive. You need to boot ventoy in BIOS mode because FreeDOS doesn’t support UEFI and you also need to start FreeDOS from Ventoy in Memdisk mode or it will fail to find it’s filesystem.
Once FreeDOS boots, after you’ve selected your language FreeDOS asks you if you want to install it on your system. Select “No - Return to DOS” and you’ll be dropped to a DOS shell where you can continue to run whatever software you added to your image.