Sunday, August 9, 2009

Trying to Use a FreeDOS USB Drive to Flash the BIOS via Ubuntu

I wanted to flash the BIOS on my Gigabyte motherboard. I downloaded the updated BIOS from Gigabyte's website. Now, how to flash the BIOS? In the past, I had always used floppy drives for BIOS updates. At this point, though, my last floppy disks were really old and I was not eager to risk BIOS corruption. This post describes the gyrations I went through before winding up with the floppy approach after all. To test my old floppy disk, I went to Ubuntu's Terminal utility and typed "gfloppy" and chose the Thorough formatting mode. This gave me "Error formatting track #0." Somebody suggested that this was because I already had the floppy inserted in the drive, so I ejected it and tried "gfloppy" again. This gave me "Unable to access the floppy disk." Now I inserted the floppy and clicked OK. But no, still the same error. Following a somewhat related discussion, I went to Synaptic and installed the pmount package. In Terminal, I typed "sudo pmount -h." That brought up some help information which told me that pmount was useful for mounting devices. Not quite what I needed. It seemed that there used to be a Floppy Formatter menu option in Ubuntu, but I wasn't finding that anymore; but then it seemed that this was just the fancy way of invoking gfloppy. Somebody else said that Linux can't handle a completely blank floppy, and suggested using these two command lines in that case: setfdprm -p /dev/fd0 1440/1440 fdformat /dev/fd0 The first line gave me an error indication, "The program 'setfdprm' is currently not installed. You can install it by typing sudo apt-get install fdutils." So I did that, and then tried these two lines again. This time, the first line went OK, but the second line said, "Device or resource busy." I ejected the floppy and tried again, but this time I got, "No such device or address." David Haas suggested that automount might be the problem so, following his advice, I typed "gedit /etc/fstab" and looked for the line for /dev/fd0 (i.e., for the floppy drive). But its default was already "noauto" (he thought maybe automount was the problem, and advised setting it to noauto to prevent that), so that wasn't the solution. But I tried what the other person said in response to his advice, which was to enter "sudo umount /dev/fd0" and then I tried again with the fdformat command (above) and, you know, it worked! Ah, but it had occurred to me that making my BIOS update depend upon something as flaky as a floppy drive might not be the ideal approach. Surely Gigabyte offered a way to flash the BIOS from some other kind of drive? Yes, as it turned out, they did - but only if you were running Windows. Since I had a double-boot system, that could be arranged. But what about booting from a USB drive? Andrew provided instructions on how to create a bootable Windows or Linux USB drive using UNetbootin. I decided to do that once I could find where I had put my larger USB drive (1GB minimum required). Aside from Andrew's approach, the UNetbootin instructions looked kind of complicated. For now, though, as Linerd said, sometimes you just need a DOS boot disk. Following his instructions, I dedicated my smallest USB drive - a 256MB unit that had been gathering dust - to this very purpose. Following his instructions, I plugged that USB drive into the system that was running Linux and opened System > Administration > Partition Editor (i.e., GParted). In GParted, I wrote down the address of the USB drive (in my case, it was /dev/sdd1); unmounted the USB drive and formatted it to FAT16; and then I right-clicked on it (still in GParted) and, under Manage Flags, made sure the "boot" flag was checked. Then I mounted it by double-clicking on it in Nautilus (i.e., Ubuntu's File Browser). (Like most or all drives, it was located in File System > media.) In my case, I couldn't actually mount it until I went back into GParted, right-clicked on it, and ran a Check; then it showed up in Nautilus as "259.5 MB Media." Now double-clicking on it in Nautilus revealed that it contained nothing. So, back to Linerd's instructions: I closed GParted and, from the website for the ultra-mini FreeDOS distribution known as Odin, I downloaded the odin1440.img image file and copied it to the USB drive. In Nautilus, I also copied the file called "memdisk" from File System > usr/lib/syslinux to the USB drive. Then I created a folder called "grub" on the USB drive. I went to File System > usr/lib/grub. There, I saw that I had only one folder, called x86_64-pc. (This was different from Linerd's example because I was running 64-bit Ubuntu.) He told me to copy all of the files from that folder into the grub folder on the USB drive. Next, using Ubuntu's Applications > Accessories > Text Editor, I created a file containing these lines: default=0 timeout=10 root=(hd0,0) title FreeDOS kernel /memdisk initrd /odin1440.img I called that file "menu.lst" and saved it in the grub folder on the USB drive. Then I installed grub (the program) on the USB drive. This required, first, getting to the grub prompt by entering these two commands: cd /media/disk sudo grub At the grub prompt, I then entered these commands: grub> device (hd5) /dev/sdc grub> root (hd5,0) grub> setup (hd5) grub> quit My impression was that the first grub command would create a virtual device called hard disk no. 5, and would then install the necessary runtime programs in it. The Gentoo webpage that Linerd drew upon had some additional information. Anyway, with the USB drive still plugged into the computer, I rebooted, hit Del to go into my BIOS Setup, and (in the Advanced BIOS Features section) chose USB-FDD as my first boot device. I saved the BIOS changes and rebooted. Apparently the USB thing didn't work, because I found myself back at the usual GRUB menu. I hit Ctrl-Alt-Del and then, on reboot, hit F12 to call up my boot menu. (Not an option for everyone, I'm sure.) I tried USB-FDD from here too, but still no luck. I realized that I had copied down Linerd's instructions verbatim, and had therefore probably entered sdc (the location of his USB drive) rather than sdd1 (the location of mine, according to GParted) in the grub command (above). So I tried again with sdd1. That part went OK, but then, when I typed the "root (hd5,0)" line, grub said, "Error 22: No such partition." I took another look in GParted. I thought maybe grub wanted "sdd" rather than "sdd1," so I tried again with that. It accepted that, so I finished and rebooted. It still didn't boot from the USB drive. I rebooted and hit F12 again. This time, instead of USB-FDD, I chose USB-CDROM. Still not right. I tried again with USB-ZIP. Bingo! This gave me a GRUB menu with FreeDOS listed as the only item. (Later, it looked like I could also have selected USB-HDD.) Now I had another menu, with options to load FreeDOS for 8086, 186, 286, or 386-based computers. There were four 386 options: with HIMEM, EMM386, XDMA, and CDROM. I chose option 6, the last one (i.e., with all four of those programs loaded). I got a floppy (A:\) prompt. I typed C: and it gave me what looked like a corrupt drive directory. I tried D: and it gave me three options in some Eastern European language. I hit Ctrl-Alt-Del, changed the BIOS so it would always try USB-ZIP first, and let it go through its boot process. This time, I went with option 3 rather than 6; and at the A: prompt, I typed DIR /W. It showed me a list of DOS programs and files (e.g., XCOPY.EXE). I typed B:. There was no B drive. I tried C: again. DIR still gave me no joy. E: gave me "Invalid drive E:." This was different from what Linerd said: he said his system booted with C: as the default (and working) prompt. I rebooted again and, this time, from the FreeDOS menu, I chose the F5 ("Bypass startup files") option. This yielded the same results as above. Trying another reboot, I chose the F8 option and walked through each line of AUTOEXEC.BAT. There weren't any error messages; it seemed to be booting and loading as intended. On another try, booting the USB-HDD option didn't fix the problem. Basically, this setup was not working for me. Possibly the problem lay in the note that said, "ATAPICDD should be replaced by your own driver"; possibly my 64-bit system messed things up. Either way, I had no idea what the solution would be. At this point, I gave up on the USB drive approach. Moreover, for some reason (probably related to the router), Windows on this machine was not able to go online. So I went back to the floppy-based approach for flashing the BIOS. In about two minutes, it was done. But I would rather have had a working USB solution and avoid the risk of floppy-based flashing.

1 comments:

Linerd

Ray – I should have perhaps stated things more clearly in my post. In your grub commands you should have used
grub> device (hd5) /dev/sdd1
based on the device you had in GParted.

I’ve edited my post to make it more clear. Hopefully this gets things working for you.