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


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


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.

Folder encryption with EncFS

Sometimes we have private information, here I am using EncFS tool to protect my data.I am describing in a few minutes installation steps.

ibekyarov@machine:~$ sudo aptitude install encfs

We have to activate fuse module in the kernel, because EncFS use it.By adding “fuse” without quotes in /etc/modules,kernel will load this module on every boot.Here we are loading fuse`s module in the kernel.

ibekyarov@machine:~$ sudo modprobe fuse

Because of using fusermount we need add our user to fuse group.

ibekyarov@machine:~$ sudo adduser ibekyarov fuse
Adding user `ibekyarov' to group `fuse' ...
Adding user ibekyarov to group fuse

Here we create directory which will be encrypted.

ibekyarov@machine:~$ mkdir ~/encfs_encrypted

Here we create our mounting point of encrypted directory.

ibekyarov@machine:~$ mkdir ~/encfs_decrypted

Let`s encrypt our target.

ibekyarov@machine:~$ encfs ~/encfs_encrypted/ ~/encfs_decrypted/
Creating new encrypted volume.
Please choose from one of the following options:
enter "x" for expert configuration mode,
enter "p" for pre-configured paranoia mode,
anything else, or an empty line will select standard mode.
?&gt; p

Paranoia configuration selected.

Configuration finished. The filesystem to be created has
the following properties:
Filesystem cipher: "ssl/aes", version 3:0:2
Filename encoding: "nameio/block", version 3:0:1
Key Size: 256 bits
Block Size: 1024 bytes, including 8 byte MAC header
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File data IV is chained to filename IV.
File holes passed through to ciphertext.

-------------------------- WARNING --------------------------
The external initialization-vector chaining option has been
enabled. This option disables the use of hard links on the
filesystem. Without hard links, some programs may not work.
The programs 'mutt' and 'procmail' are known to fail. For
more information, please see the encfs mailing list.
If you would like to choose another configuration setting,
please press CTRL-C now to abort and start over.

Now you will need to enter a password for your filesystem.
You will need to remember this password, as there is absolutely
no recovery mechanism. However, the password can be changed
later using encfsctl.

New Encfs Password:
Verify Encfs Password:
fuse: failed to open /dev/fuse: Permission denied
fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message

We have the following errors:

fuse: failed to open /dev/fuse: Permission denied
fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message

The solution is:

ibekyarov@machine:~$ sudo /etc/init.d/udev restart
Stopping the hotplug events dispatcher: udevd.
Starting the hotplug events dispatcher: udevd.
ibekyarov@machine:~$ sudo /etc/init.d/fuse restart
Restarting filesystem in userspace: fuse.

Mount the encrypted directory.

ibekyarov@machine:~$ encfs ~/encfs_encrypted/ ~/encfs_decrypted/

EncFS Password:

ibekyarov@machine:~$ df -h | grep encfs
encfs 5.7G 4.3G 1.2G 79% /home/ibekyarov/encfs_decrypted
ibekyarov@machine:~$ cd /home/ibekyarov/encfs_decrypted/
ibekyarov@machine:~/encfs_decrypted$ touch test_encryption
ibekyarov@machine:~/encfs_decrypted$ cd ..

This unmount our encrypted directory from the mountpoint.

ibekyarov@machine:~$ fusermount -u /home/ibekyarov/encfs_decrypted/
ibekyarov@machine:~$ ls /home/ibekyarov/encfs_encrypted/

If we  want to  change our EncFS password.

ibekyarov@machine:~$ encfsctl passwd ~/encfs_encrypted/
Enter current Encfs password
EncFS Password:
Enter new Encfs password
New Encfs Password:
Verify Encfs Password:
Volume Key successfully updated.

Enjoy 🙂