Linux/Flashing BIOS From Linux Using GRUB

Bizen | Linux | Recent Changes | Preferences

WARNING!! This currently is only known to work using the grub from RIP Rescue Linux version 13.4!!

Required Packages

Preparing the DOS Image

  1. Get the FreeDOS OEM Bootdisk FDOEM.144 from the FreeDOS site.
  2. Get the mkfloppyimg.sh script from [Here].
  3. Copy the file memdisk from the SysLinux distribution to /boot.
  4. Run mkfloppyimg.sh. It will create a file called DOS-4Mb-boot.img from FDOEM.144.
  5. Get the amiflash.zip distribution from [HERE]. Extract the files AFUDOS.exe and AFUDOS.txt. This is the latest version of the AMI BIOS flashing utility. If your nodes have a different BIOS, see the BIOS manufacturers website for a similar utility.
  6. Choose a node that will be the prototype for the BIOS change, make the required changes (possibly after flashing the BIOS using the boot disk from the next step) and reboot.
  7. Copy AFUDOS.exe to any DOS boot floppy or DOS boot USB stick, reboot the prototype node, and run the commands:
    1. AFUDOS BIOS.IMG /O to capture a copy of the BIOS into the file BIOS.IMG.
    2. SMCMOS -r BIOS.SIM to capture a copy of the current BIOS settings into the file BIOS.SIM.
  8. Reboot into Linux.
  9. Mount the floppy or USB stick and extract the BIOS.IMG and BIOS.SIM files.
  10. Add the AFUDOS.exe and SMCOMOS.exe programs and the BIOS images to your 4Mb DOS floppy image:

 mkdir DOS-image
 mount -o loop DOS-4Mb-floppy.img DOS-image
 cp AFUDOS.exe SMCMOS.exe MYBIOS.IMG MYBIOS.SIM DOS-image
 pushd DOS-image
 echo "rem  Sample DOS batch file to boot Linux." >autoexec.bet
 echo "rem afudos BIOS.IMG /P /REBOOT" >>autoexec.bet
 echo "smcmos -w BIOS.sim" >>autoexec.bat
 echo "re-boot 2" >>autoexec.bat
 popd
 umount DOS-image
 cp DOS-4Mb-floppy.img /boot

After running those commands, you should have the two files /boot/memdisk and /boot/DOS-4Mb-boot.img, which only need a proper entry in /boot/grub/grub.conf to make it possible to flash your BIOS or configure it with your settings.

GRUB Setup

Until further notice, this is the only grub that will work: http://inferno.slug.org/flash-BIOS-from-Linux/RIP-grub-0.97-X.tar.gz (No longer available!

To update BIOS settings on a node:

 yum -y remove grub
 tar xvzpf /ldcg_admin/Flash-BIOS/RIP-grub-0.97-X.tar.gz
 tar xvzpf /ldcg_admin/Flash-BIOS/bootkit-NN-NN-NNNN.tar.gz --directory /
 cp -r RIP-grub-0.97-X/usr /
 grub-install /dev/sda
 grub-set-default 7
 reboot

Your /boot/grub/grub.conf file needs to be modified to make this work:

 #
 # Note that you do not have to rerun grub after making changes to this file
 # NOTICE:  You have a /boot partition.  This means that
 #          all kernel and initrd paths are relative to /boot/, eg.
 #          root (hd0,0)
 #          kernel /vmlinuz-version ro root=/dev/sda2
 #          initrd /initrd-version.img
 #boot=/dev/sda
 default=saved
 timeout=5
 serial --unit=1 --speed=19200
 terminal --timeout=5 serial console
 title Fedora Core (2.6.20.20-CIT)
 	root (hd0,0)
 	kernel /vmlinuz-2.6.20.20-CIT ro root=/dev/sda2 elevator=deadline console=tty0 console=ttyS1,19200n8
 	initrd /initrd-2.6.20.20-CIT.img
         savedefault
 title Fedora Core (2.6.20.14-CIT)
 	root (hd0,0)
 	kernel /vmlinuz-2.6.20.14-CIT ro root=/dev/sda2 elevator=deadline console=tty0 console=ttyS1,19200n8 iommu=off
 	initrd /initrd-2.6.20.14-CIT.img
         savedefault 0
 title Memtest86+ (1.55.1)
 	root (hd0,0)
 	kernel /memtest86+-1.55.1 ro root=/dev/sda2
 	savedefault 0
 title DOS For BIOS Flashing
         root (hd0,0)
         kernel /memdisk bigraw floppy c=4 s=32 h=64
         initrd /DOS-4Mb-boot.img
         savedefault 0
         boot

All the lines highlighted in red are part of new functionality introduced in grub-0.96 to support the command grub-set-default (part of the grub distribution beginning with 0.96), which allows you to reboot to an alternate target ONCE, with a subsequent reboot returning to the default target.

In the example grub.conf above, the 0th target has the keyword savedefault with no added argument. All other targets have the added argument 0, which means that if they are run as alternate targets via the grub-set-default script, the default after they are selected will revert to the 0th target. The necessary state is preserved in the file /boot/grub/default, which is a plain text file consisting mostly of rubbish that gives it a known checksum for a given declared default target value.


Bizen | Linux | Recent Changes | Preferences

Last edited March 12, 2013 3:08 pm by Pokute
Search Bizen: