How to create large bootable image of DOS for BIOS upgrades

Hello Fellows

Today I will show you quick and neat way to make your own bootable image of DOS 6.22 bigger than 2.88MB. With this you can easily upgrade your motherboards BIOS or some firmware for your hardware, that has a binary file bigger than 2MB, and can not fit in the commonly found images on the internet. Here is the list of things that will be needed before we can proceed:

# Requirements
– I’m doing this on top of Debian Wheezy.
– any kind of virualization software (in my case I will use: VirtualBOX)
– wget (we are using this ISO as a base, because it is a very clean, without any unnecessary software)
– aptitude install kpartx (will be used to set up device mappings for the partitions of our image)
– aptitude install genisoimage (will be used to generate the actual .iso file which can be burned to CD and boot from it)

In this brief how to I will not explain the details about the installation of pre-required software. Now lets begin with few screenshots that will guide you in actual creation of VM. The VM will be needed only for it’s image file, that will serve us later to generate our own iso with included firmwares.

1) Create new virtual machine with the following ‘name’, ‘type’ and ‘version’:

2) Set the memory for this VM, to 32MB. This will be more than enough, after all we are going to boot an OS that is approximately 20 years old :))

3) Choose to create new virtual disk image:

4) We need to use the VDI image type (this is important!):

5) It is important that the size of the image is fixed!:

6) Set the image size to desired value. For my usage patterns 64MB will be sufficient:

7) After the VM is set up, it is time to start it, and set it up to boot the ‘DOS6.22_bootdisk.iso’. In this screen shot you can see, how it must looks when the boot process is over:

8) Now we must “Create DOS Partition” for our 64MB image, using our good old friend ‘fdisk’:

9) Choose the “Create Primary DOS Partition”, we are going to need only one:

10) Use the hole disk space for this partition:

11) After the partition is ready, the system will reboot! This is important, so that we can see and format our newly created partition.

12) Now lets verify that everything is set up correctly. To do this we are starting the ‘fdisk’ tool again:

13) Choose the option ‘4’, and hit enter:

14) You must see the following info, from witch you can see that your partition is using 100% of the image size, but still has not have a filesystem:

15) Exit the tool, and create the file system with our other friend ‘format’:

16) After the procedure is done, you can see that we have a file system, which also make our image a “System Disk” (the old term for bootable DOS 6.22 disk).

17) Ensure that our partition is setup correctly:

18) Now you can “power down” the VM, disable the bootable iso image “DOS6.22_bootdisk.iso”, and test if our new 64MB image is booting correctly:

After we are having good 64MB VDI image, that boot DOS 6.22, you can “power down” the VM and stop the VirtualBox application. When that is done, you can start the ‘Terminal’ and continue the journey:

19) First we will need few directories, so that we can work with them:

root@browseman:~# mkdir -p /mnt/flash/
root@browseman:~# mkdir -p /mnt/ISOs/DOS/SOURCE/BOOTIMG/

20) Now lets lists all virtual hard drive images in VirtualBox with the following command:

root@browseman:~# VBoxManage list hdds

UUID:        00c97bc7-dd42-457f-bae2-b8317550fe58
Parent UUID: base
Format:      VDI
Location:    /mnt/virt.images/Work/GEN_DOS/GEN_DOS.vdi
State:       created
Type:        normal
Usage:       GEN_DOS (UUID: a86b610c-a0e1-4136-919e-19e45236aee1)

21) Now it is time to convert our image from ‘VDI’ to ‘RAW’ type. Here is the command the you can use to do this (please NOTE the we are using the value of ‘UUID:’ field from above command to instruct the application to use the correct image for conversion). The new image will be stored in “/mnt/ISOs/DOS/own_64MB_dos_hdd.raw”:

root@browseman:~# VBoxManage clonehd 00c97bc7-dd42-457f-bae2-b8317550fe58 /mnt/ISOs/DOS/own_64MB_dos_hdd.raw --format RAW
Clone hard disk created in format 'RAW'. UUID: 578a9f96-f1cc-4584-9dd1-c5022fc3028d

22) Lets mount our freshly created RAW image:

root@browseman:~# loopdev=$(losetup -s -f /mnt/ISOs/DOS/own_64MB_dos_hdd.raw)
root@browseman:~# kpartx -a $loopdev
root@browseman:~# ls /dev/mapper/loop*

root@browseman:~# mount /dev/mapper/loop0p1 /mnt/flash/

If everything is correct you must see the following content in the mounted image:

root@browseman:~# ls -la /mnt/flash/
total 218
drwxr-xr-x 2 root      root      16384 Jan  1  1970 .
drwxr-xr-x 7 browseman browseman  4096 Aug  6 15:17 ..
-rwxr-xr-x 1 root      root      54645 May 31  1994 COMMAND.COM
-r-xr-xr-x 1 root      root      66294 May 31  1994 DRVSPACE.BIN
-r-xr-xr-x 1 root      root      40774 May 31  1994 IO.SYS
-r-xr-xr-x 1 root      root      38138 May 31  1994 MSDOS.SYS

23) Now it’s time to copy our BIOS binaries and flash utilities (in my case three images for old MoBo’s):

root@browseman:~# cp -pr /mnt/ISOs/BIOS/* /mnt/flash/

root@browseman:~# ls -la /mnt/flash/
total 224
drwxr-xr-x 5 root      root      16384 Aug  6 19:07 .
drwxr-xr-x 7 browseman browseman  4096 Aug  6 15:17 ..
-rwxr-xr-x 1 root      root      54645 May 31  1994 COMMAND.COM
-r-xr-xr-x 1 root      root      66294 May 31  1994 DRVSPACE.BIN
-r-xr-xr-x 1 root      root      40774 May 31  1994 IO.SYS
-r-xr-xr-x 1 root      root      38138 May 31  1994 MSDOS.SYS
drwxr-xr-x 2 root      root       2048 May 23 13:27 x7dbe
drwxr-xr-x 2 root      root       2048 May 23 13:27 x7dbn
drwxr-xr-x 2 root      root       2048 Aug  5 16:26 x8dti-f

24) You can check that our image got bigger 🙂 :

root@browseman:~# df -H /dev/mapper/loop0p1
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/mapper/loop0p1                                      67M  9.7M   58M  15% /mnt/flash

25) Now after the image has our files it is time to generate the bootable .iso image, which we can burn to CD (for example) and boot from it, to upgrade the BIOS. To do this first we must copy all files from the freshly modified RAW image to our source directory:

root@browseman:~# cp -pr /mnt/flash/* /mnt/ISOs/DOS/SOURCE/

26) ‘Unmount’ the modified image and remove the configuration from dev-mapper:

root@browseman:~# umount /mnt/flash/
root@browseman:~# kpartx -d $loopdev
root@browseman:~# losetup -d $loopdev

27) It very important to copy the modified raw image in to specially created sub-directory of our source directory (the name of the sub-directory is not important, you can change it):

root@browseman:~# cp /mnt/ISOs/DOS/own_64MB_dos_hdd.raw /mnt/ISOs/DOS/SOURCE/BOOTIMG/own_64MB_dos_hdd.raw

28) Finally we are ready to create our .iso with this “simple” command:

root@browseman:~# genisoimage -hard-disk-boot -o /mnt/ISOs/DOS/own_boot_dos.iso -V DOSBIOS -b BOOTIMG/own_64MB_dos_hdd.raw /mnt/ISOs/DOS/SOURCE
I: -input-charset not specified, using utf-8 (detected in locale settings)
Size of boot image is 132096 sectors -> Emulating a hard disk
Warning: image size does not match geometry (131040)
 13.21% done, estimate finish Tue Aug  6 19:19:00 2013
 26.43% done, estimate finish Tue Aug  6 19:19:00 2013
 39.61% done, estimate finish Tue Aug  6 19:19:00 2013
 52.82% done, estimate finish Tue Aug  6 19:19:00 2013
 66.00% done, estimate finish Tue Aug  6 19:19:00 2013
 79.22% done, estimate finish Tue Aug  6 19:19:00 2013
 92.39% done, estimate finish Tue Aug  6 19:19:00 2013
Total translation table size: 2048
Total rockridge attributes bytes: 0
Total directory bytes: 8192
Path table size(bytes): 70
Max brk space used 1a000
37889 extents written (74 MB)

Now you can burn the ISO image to CD and flash BIOS-es and firmwares like a boss :))