Skip to content

Instantly share code, notes, and snippets.

@espoelstra
Created September 26, 2018 21:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espoelstra/2246a8ffdd40d362cefb1f6777e1e8b8 to your computer and use it in GitHub Desktop.
Save espoelstra/2246a8ffdd40d362cefb1f6777e1e8b8 to your computer and use it in GitHub Desktop.
Creating a FreeDOS image for PXE boot

FreeDOS easy to update USB or PXE boot (Legacy or EFI)

I've been wanting to do this for quite a while, ever since I had to make up dozens of USB drives with a system image for deployment to migrate from Windows XP to Windows 7 for a large enterprise. Any tweaks to the image required re-writing all the drives, and the quickest way to burn up a cheap drive is repeated reads and writes. Then I learned partway through the rollout from the support staff performing the hands-on reimaging that on some systems the boot took forever, and while investigating I discovered that there was a BIOS update that remedied the issue and the system boot dropped from 10-15 minutes to a minute or two. After that I added updating the BIOS to our reimage procedure checklist, but again I was making multiple copies of the USB so that each tech could have one to do the fairly quick BIOS update before switching over to the other USB for imaging the system. Luckily at the time I had opted for the USB "full" image of FreeDOS which had space for updates for a number of models, and didn't require any special tricks to add new ones, you just had to be mindful of the free space and delete outdated updates as the newer versions came out. In a few cases this was made tricky because there were "checkpoint" updates that had specific upgrades required by future updates, so you'd have to go from A01 to A04 to A09 to A14 to A21 in some cases, but luckily you could just grab the latest and work your way backwords through the list, though inevitably you'd come across a system that was even older than you'd ever seen and required another intermediate update that you had to go find and download.

Eventually I was able to improve the process by moving the imaging to pull from a PXE server which on a gigabit network actually performed the reimage faster than most of the USB devices, and also allowed imaging multiple machines at once in separate locations around the various offices instead of having to drag desktops and laptops to a single location. It always bothered me that I didn't have time to explore getting the BIOS update process more automated and available through USB. Even though I've worked at many companies since then I'm glad to finally get that checked off the list using some articles with helpful tips on things to watch out for and how to debug failures.

When using the FreeDOS full image you have to remember that it is primarily designed as an installer, so you need to edit the autoexec.bat or config.sys to REM out the lines that start the installation. This can easily be done with a text editor while you have the image/drive mounted to add the BIOS updates. If you are really automation enamored you can use something like dmidecode to detect the system's manufacturer and model number (as well as current BIOS version in case that matters), and then apply a specific update automatically without the user even having to select anything. There are usually options to force the update without any prompting, but I haven't fully explored this yet. Currently I assume that somebody is preparing to re-image a machine and wants to ensure that all the CPU/chipset level vulnerabilities are patched (Spectre/Meltdown/etc).

WIP: Continue detailing things like kpartx for detecting and loop mounting img embedded partitions easily to allow editing files in the img. Also the USB and PXE args to syslinux to allow mounting these harddisk images instead of the commonly cited floppy images which are really hard to maintain because they often require multiples of 720 or 1.44 or 2.88 to function with certain apps.

Resources (actually used)

https://github.com/rjocoleman/docker-netboot.xyz

References (referenced to build final solution)

https://www.cs.waikato.ac.nz/~dbaird/work/2013/11/05/pxe-boot-freedos-hard-disk-image/

https://wiki.inf.ed.ac.uk/DICE/FreeDOS

https://web.archive.org/web/20130613043812/http://www.falsyana.com/2011/linux/freedos-over-pxe/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment