# HOWTO: Update BIOS Using CD



## vermaden (Mar 11, 2010)

Previously I used MS-DOS 1.44 MB bootable floppy and added BIOS files to CD-ROM image, so an emulated floppy needed to load CD-ROM driver and then you was able to flash the BIOS. Now I use open/free 2.88 MB floppy with FreeDOS instead, and BIOS files are kept directly on the emulated floppy, so no need to load all these CD-ROM drivers, so it also boots a lot faster.

The script itself is here:


```
#! /bin/sh

trap __clean 1 2 3 4 5 6 7 8 9 10 11 12 14 15

# bootable 2.88 MB floppy image from: [url]http://fdos.org/bootdisks/[/url]
FLOPPY=FDSTD.288

__status() {
  [ ${?} -eq 0 ] || {
    echo "ER: ${@}"
    exit 1
    }
  }

__clean() {
  cd /
  umount mnt 1> /dev/null 2> /dev/null
  UNIT=$( echo ${UNIT} | tr -d 'a-z' 2> /dev/null )
  mdconfig -d -u ${UNIT} 1> /dev/null 2> /dev/null
  }

[ ${USER} = root ] || {
  echo "ER: only root may use that script"
  exit 1
  }

for I in fetch gzip mdconfig mkdir mount_msdosfs cp umount rm tr mkisofs
do
  which ${I} 1> /dev/null 2> /dev/null || {
    echo "ER: ${I} is not available in ${PATH}"
    exit 1
    }
done

fetch [url]http://www.fdos.org/bootdisks/autogen/${FLOPPY}.gz[/url] 1> /dev/null 2> /dev/null
__status "fetch(1) failed"

gzip -d -f ${FLOPPY}.gz 1> /dev/null 2> /dev/null
__status "gzip(1) failed"

UNIT=$( mdconfig -a -t vnode -f ${FLOPPY} 2> /dev/null )
__status "mdconfig(8) failed (create)"

mkdir -p mnt 1> /dev/null 2> /dev/null
__status "mkdir(1) failed"

mount_msdosfs /dev/${UNIT} mnt 1> /dev/null 2> /dev/null
__status "mount(8) failed"

cp bios/* mnt 1> /dev/null 2> /dev/null
__status "cp(1) failed"

umount mnt 1> /dev/null 2> /dev/null
__status "umount(8) failed"

rm -r mnt 1> /dev/null 2> /dev/null
__status "rm(1) failed"

UNIT=$( echo ${UNIT} | tr -d 'a-z' 2> /dev/null )
__status "tr(1) failed"

mdconfig -d -u ${UNIT} 1> /dev/null 2> /dev/null
__status "mdconfig(8) failed (destroy)"

mkisofs -J -R -b ${FLOPPY} -o bios.iso ${FLOPPY} 1> /dev/null 2> /dev/null
__status "mkisofs(1) failed"
```

Put all BIOS related stuff (flashing program/BIOS itself) into bios directory in the same place as this script is, lets call it create_bios_iso.sh, the listing will look like that:


```
# find .
./bios
./bios/flash.exe
./bios/bios.img
./create_bios_iso.sh
```

... and after usage:


```
# find .
./FDSTD.288
./bios.iso
./bios
./bios/flash.exe
./bios/bios.img
./create_bios_iso.sh
```


----------



## aepd (Sep 13, 2010)

Missing sysutils/cdrtools.

For those interested in making a USB stick image instead, look at /usr/src/release/scripts/make-memstick.sh and adapt it to FAT.


----------

