Monday, July 3, 2017

Guest post: Updating BIOS with FreeDOS

Lars Noodén shared this note about using FreeDOS to update the BIOS on a computer. On the FreeDOS website, we like to say that most people install FreeDOS to play classic games, run legacy software, or do embedded development. And for installing FreeDOS, that probably covers almost everyone. But there are a lot of folks who use FreeDOS to do exactly what Lars describes: update the BIOS.

I use FreeDOS only occasionally—but when I have used FreeDOS, it has been a life saver. The most recent time was when I needed to update the BIOS on an old laptop. I was able to make a FreeDOS image containing the BIOS update and then modify GRUB2's configurations to allow me to boot it. The GRUB2 part, as opposed to GRUB1, was hard. The FreeDOS part was straightforward and easy. Here's how I did it:

This was all done on an ancient laptop using a Long Term Support (LTS) version of Ubuntu GNU/Linux for AMD64 computers, which to my consternation used GRUB2.

First, after downloading the FreeDOS boot floppy and unzipping it, I mounted the resulting disk image read-write using the "loopback" device so that I could edit it. I copied the vendor's ".EXE" style BIOS update there so it would be available while FreeDOS was running. I then removed AUTOEXEC.BAT so that I would get the normal command prompt when booting. Then I unmounted the disk image and it was ready to go, so I copied it to /boot/floppy.img and was all set with that. That was the easy part.

Next was the hard part with GRUB2. While it was fairly easy to figure out how to configure the old GRUB1, the new version is not. After much searching online, I ended up "cargo-culting" it. So if you follow this route, try to find and read current documentation. It turned out that I had to first to get memdisk into the /boot directory. The package syslinux at the time could do that—although now the package grub-imageboot seems to do that job, and installing it puts memdisk directly in /boot for you.

Then GRUB2 had to be configured to offer memdisk and the modified FreeDOS boot floppy as an option. That is done by creating a new file, /etc/grub.d/42_custom, and making it executable. In it, I put the following:
 #!/bin/sh
 cat <<EOT
   menuentry "FreeDOS" {
     linux16 /boot/memdisk
     initrd16 /boot/floppy.img
   }
 EOT
Then once update-grub was run, FreeDOS showed up in the boot menu starting with the next boot.

And with FreeDOS now in the boot menu, it was just to reboot the computer, select FreeDOS, and then run the BIOS update from the A: prompt. After the BIOS update ran to completion and I was back in Ubuntu, I removed the GRUB2 entry.

FreeDOS really saved the day in that way, since there was no other way to conjure the equivalent of a bootable floppy disk.

-Lars Noodén

No comments:

Post a Comment