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 :))


Inteligante apache/nginx log analyzer.

Howdy m8s.

In next article i want to show you how to make an easy statistical view for an web page only by using one simple tool called goaccess.

As they say to their site, this tool can provide a various information for your web site just by scanning log files from apache / nginx logs.

 -General Statistics, Bandwidth etc.
 -Top Visitors
 -Requested files
 -Requested static files, images, swf, js, etc.
 -Referrers URLs
 -404 or Not Found
 -Operating Systems
 -Browsers and Spiders
 -Hosts, Reverse DNS, IP Location
 -HTTP Status Codes
 -Referring Sites
 -Unlimited log file size

For this review i’ll use VirtualBox image with Debian wheezey net-install with xfce.

Install methods:

1. debian package manager installer

If you install goaccess via debian wheezy installer it will put all packages needed for that tool and it will be ready for use.
But in that way you can’t use utf8 or geoip support.

sudo aptitude install goaccess

and you will have Version: 0.5-1

If you dont really need utf8/geoip the install part for you end with this simple command.

2. Manually compile

Here we shall install goaccess tool with fully support of utf8/geoip

Download it to your work my case this is /root/Downloads/

you need to install this libs

libglib2.0-dev libgeoip-dev  libncursesw5-dev libncurses5-dev

Than you have to follow the exact instructions from the site:

tar -xzvf goaccess-0.6.tar.gz
cd goaccess-0.6/
./configure --enable-geoip --enable-utf8 
make install

After compile is done you can use it on the fly by typing

goaccess -f /var/log/apache2/access.log -a -c

the “-c” options if for log/date configuration window.
In this window to show correctly apache log files you need to choose “NCSA Combined Log Format”

And this is all…now in console you can see in real time how log statistics is changing πŸ™‚

Goaccess main window

Customize external keyboard layout for Android

Hello Fellows πŸ™‚

Using an external keyboard with an Android device sometimes can be tricky because not all keyboards feature all of the basic Android buttons. For example I use a Bluetooth keyboard that lacks the context menu key which acts like a menu button for Android. Luckily if you have root access to your device you can customize the key mappings of your keyboard.

The first thing you need to do is to check the vendor and the product identification codes of your keyboard. You can find them if you do:

cat /proc/bus/input/devices

and explore the output in the terminal of your Android device (the keyboard has to be connected).

Check the names of the devices that are listed and you should easily identify your keyboard.

I: Bus=0005 Vendor=0a5c Product=8502 Version=011b

N: Name="Broadcom Bluetooth HID"

My Bluetooth keyboard is from vendor with id 0a5c and the product id is 8502. Now that you know the vendor and the product ids of your keyboard you can create a copy of the file /system/usr/keylayout/Generic.kl in the same location, give it a proper name and start customizing it. The name of the file should follow the pattern:


For example Vendor_0a5c_Product_8502.kl is the name of the file for my Bluetooth keyboard. The next time you connect your keyboard it should load it’s key mappings from this file instead of the generic one.

What I did to get the functionality of the menu button was to change these lines in my custom .kl file

key 126 META_RIGHT
key 127 MENU

Β to

key 126 MENU
key 127 META_RIGHT

This way I turned the right meta key (windows logo) into a menu button. The right meta key has a scan code of 126 and the context menu key has a scan code of 127 and swapping the actions that are mapped to them in the file did the job for me.

One thing that you have to be careful about is not to assign different actions to the same scan code which will cause you trouble. Each scan code must be present only once in the file.

If you want to find out the scan code of a key on your keyboard you can use the application “KeyEvent Display” which is free in the Play Store.

I hope this will be of some help.