Boosting the power of a DOS image

Multiple images: Right now we have a couple of potential issues with the DOS image setup. Currently we need two such images, one to initiate a Windows install and another to get a shell for troubleshooting. In case of linux the apparent multiplicity of images was solved by passing boot time arguments to the kernel. However, DOS does not have the concept of boot time arguments.

Size of Image: The current DOS image is very close to the 2MB limit, and if one needs to add more network drivers or utilities, we will be in trouble. One way out is to use the fact that MEMDISK can boot hard disk images as well. So we can have a 20MB hard disk image which boots into DOS and has all the goodies we want in it. However this leads to another nasty problem...

If one used a hard disk image, then DOS will assign C: to that image and the real hard disk, will get assigned the letter D:. When one installs windows on such a system, windows assigns the driver letter D: to the hard disk where it installs windows (I have actually not seen this, but seen something similar to this when one tries to install windows in the presence of additional external disks...). That by itself is not a problem, just an annoyance. One now has to live with the fact that everything is in D: as opposed to the standard expectation of C:. Even though this will not cause anything to go wrong, there are still software out there, which still install themselves in "C:\Program Files", without even checking if there is such a thing.

Luckily ISOLINUX/MEMDISK can be used to solve both the problems.

Large floppy images

The second problem is solved, by having a 10MB floppy image (or larger if you want). One creates a floppy image with non-standard geometry (number of heads and sectors) using unix utilities like mkdosfs, and instructs MEMDISK about the geometry of the image and that it is a floppy image and not a hard disk image.

Creating such a non-standard floppy image is not that difficult. One must ensure that the boot sector of this image is setup correctly. The boot sector created by mkdosfs, will not help. So we need to copy the boot sector from a bootable MSDOS disk (or diskimage). This does not solve the problem completely as well. Parts of the bootsector contain information about the geometry of the floppy. So, we need to copy all the parts of the boot sector which are unrelated to the geometry from the bootable MSDOS disk (or diskimage) and keep the rest of the information untouched.

Finally when booting off this image using MEMDISK, dont forget to tell MEMDISK about the non-standard geometry. See the downloads section for a script which creates the non-standard images for you.

Multiple images

Even though DOS does not have the concept of boot time arguments, one can simulate the same effect, with the help of MEMDISK. Recent versions of MEMDISK implement a mechanism by which one can retreive the entire command line which was passed to memdisk. Once we boot into DOS, as part of the autoexec.bat file we do the following:

  1. Retreive the command line passed to MEMDISK
  2. parse the command line and set appropriate environment variables
  3. Execute all the boot time scripts (init.d style)
  4. The scripts are expected to look at the environment variables and do the appropriate things

The first two steps are done by getargs.com whose source code is available in the downloads section. The third and the fourth are implemented as follows:

The autoexec.bat first calls getargs.com and uses it to setup all the environment variables. It then exectues all the boot time scripts (startnet, mountnfs, mountcd ...). Each of these scripts performs a check to see if it should do anything at all. For example the mountnfs script will be like:

@echo off
if not "%network%"=="yes" goto :quit
if not "%netmount%"=="yes" goto :quit
rem -- now mount the samba share
net use Z: \\SERVER\DIST 

:quit

Finally after all the boot scripts are executed, autoexec.bat looks for the boot time parameter "image", which tells it which script to execute. It then executes the "image" script. It is not necessary that we look for %image%.bat only in A:\. Instead we can check, if we have mounted a network share, and if so check for %image%.bat there as well. This way, every time we change the script (or add new scripts), we do not need to burn another CD.

if not exist %image%.BAT goto :shell
rem -- this call does not return
%image%.BAT

:quit
rem -- drop back to shell

Murali krishnan GANAPATHY
Last modified: Fri Feb 27 14:17:01 CST 2004