This box will be fixed on your screen using Firefox, Opera9 or IE7.

Grub 引导虚拟 FreeDOS 刷 BIOS

最近机器有个小毛病怀疑可能是 BIOS 问题,到主板官方看了看,已经出了好几版新的 BIOS 了,遂决定刷一下新的看看。我们知道在 Windows 中刷 BIOS 很方便,很多主板商甚至提供直接在 Win 中刷的程序,但这台机是纯 Linux 机器,没有 windows 和 DOS 环境,而且我更不希望用什么软驱和光盘。那只有先 Google 一下看看,找到两篇文章,一是 How to flash motherboard BIOS from Linux (no DOS/Windows, no floppy drive)? 但最后还要烧成引导光盘;另一篇是 Gentoo 官方 wiki (gentoo 的文档的确全)上的 Boot Floppydisk Image without Floppy using GRUB,其实两篇结合一下就是一个刷 BIOS 的完美方案了──不需要软驱,也不需要烧盘。

先把原理说一下:Grub 是现在 GNU/Linux 系统的标准引导器,只要此时加载一个虚拟的 DOS 启动盘即可──就这么简单。当然,还得事先把 DOS 中刷新 BIOS 的工具和 BIOS 更新文件也集成到该 DOS 盘中,比如我的主板是使用 Award BIOS,它的 DOS 刷新工具是一个很小的 awordflash.exe 文件,BIOS 更新文件则需在主板官方下载诸如 newbios.bin 文件。

感谢 FDOS.org 提供了和 DOS 兼容的 FreeDOS 系统,它还提供可引导的 1.44 M软盘镜像下载:
wget http://www.fdos.org/bootdisks/autogen/FDOEM.144.gz
gunzip FDOEM.144.gz

下面我们要将刷 BIOS 的两个文件添加到上面这个镜像中,需要先挂载这个镜像,挂载前要确认内核打开 Vfat 支持(要 root 的地方不再提示):
modprobe vfat
#查看 /proc/filesystem 以确认

#准备挂载:
mkdir ~/Desktop/vfd
mount -t vfat -o loop FDOEM.144 ~/Desktop/vfd

#挂载成功后就可以将刷 BIOS 的两个文件复制其中了,确认无误后解除挂载:
cp awdflash.exe newbios.bin ~/Desktop/vfd
umount ~/Desktop/vfd

#改一下名,因为其本身就是一个镜像文件
mv ~/Desktop/FDOEM.144 ~/Desktop/bios.img

安装 syslinux,安装命令取决于你是什么发行版了,一般软件库中都有。Syslinux 是一个可以脱离 DOS/win FAT 格式的 Linux 系统的启动调入程序。在这儿,我们主要是利用其组件 memdisk──可以生成虚拟内存盘。然后开机由 Grub 引导装载。
mkdir /boot/dos
cp /usr/lib/syslinux/memdisk /boot/dos/

#把咱们的 DOS 镜像也复制过来
cp ~/Desktop/bios.img /boot/dos

#修改 grub 配置文件,
vim /boot/grub/menu.lst

#添加类似如此的启动选项(注意路径,我的 /boot 是单独分区 sda1):
title freedos
root (hd0,0)
kernel /dos/memdisk
initrd /dos/bios.img

大功告成。重启后,选择 freedos 启动后就可以直接进入 FreeDOS 刷 BIOS 了。最重要一点:只要是 Linux,这个方法就适用。

4 Comments

  1. ppip Comments @ 10:31:52 on 2008-02-13

    很有意思:)

    这样也可以用来装windows系统了。

  2. tomosak Comments @ 10:22:09 on 2008-03-19

    不错,应当可以引导PE的启动镜像

  3. HK Comments @ 21:35:53 on 2008-12-09

    没用过Linux,但是从这里学到了些东西

  4. lebron 15 Comments @ 03:23:21 on 2018-12-23

    I wish to show appreciation to this writer for rescuing me from this dilemma. Because of looking throughout the online world and getting ways that were not productive, I assumed my life was done. Existing without the presence of strategies to the problems you’ve solved by way of your entire article is a serious case, as well as ones that might have in a negative way affected my career if I hadn’t come across your blog post. Your actual mastery and kindness in touching all the things was invaluable. I’m not sure what I would have done if I hadn’t come upon such a point like this. I’m able to at this time look ahead to my future. Thanks very much for the skilled and sensible help. I will not hesitate to recommend the sites to any individual who would like tips about this area.