Thursday, August 28, 2008

BIOS Flashing a Lenovo X60s from FreeBSD

I used a 2GB USB Flash Stick in this process. Something smaller could work, something larger would make certain steps take longer.

The general idea is to grab the bootable cdrom and wedge the important pieces on to a flash drive (the laptop doesn't actually have cdrom).

The first challenge is making the Flash Stick bootable. The only Windows Machines I had access to through work are Vista, and I couldn't figure out how to make the little guy work with that. You can follow the general ideas from someplace like this which involves getting windows to make it bootable, or you can do the hack-around way.

This may not be the most efficient way, but it involved the least cognitive load:


  1. Install Qemu.

  2. Put freedos in a qemu image

  3. Insert USB Device, figure out name (/dev/da0 in my case)

  4. Make an empty image that is exactly the same size (dd if=/dev/da0 of=flashthing.hd)

  5. Boot the qemu image with -hdc flashthing.hd

  6. fdisk it (xfdisk, I don't remember, probably reboot, should give you d:)

  7. format \s d:

  8. Get the image onto the flash device (dd if=flashthing.hd of=/dev/da0 ... this took a long time since it wasn't usb2.0ing).

  9. Mount the iso and the flash drive then copy:
    mdconfig -a -f 7bu???.iso
    mount -tcd9660 /dev/md0 /mnt/cdrom
    mount -tmsdosfs /dev/da0s1 /mnt/flash
    cp -r /mnt/cdrom /mnt/flash

  10. It's important to get the memory setup correct (I got various invalid opcodes, first one, then after I installed HIMEM, a whole lot of them). I copied some pieces from those in the el-torito boot image (you can rip it out with this nice tool). /mnt/flash/FDCONFIG.SYS ended up as:
    SET lang=EN
    LASTDRIVE=Z
    BUFFERS=20
    FILES=40
    DOS=HIGH,UMB
    DOSDATA=UMB
    set dircmd=/ogn /4
    RED HIMEM is important
    DEVICE=C:\FDOS\BIN\HIMEM.EXE
    SHELLHIGH=C:\FDOS\bin\command.com C:\FDOS\bin /E:1024 /P=C:\autoexec.bat
    REM STACKS is important
    STACKS=9,256

  11. After that, reboot onto the flash drive (set it as the first boot device in the bios -- just setting it as the temporary boot device won't work)

  12. cd cdrom and command.com should get you to the point of actually flashing the thing.

Monday, August 11, 2008

Making and viewing pdfs from windows gvim.

pdfLaTeX is within cygwin, adobe reader is off in windows land, the solution:

map = :!c:\cygwin\bin\bash --login -c "pushd %:p:h:gs?\\?\\\\\\? && pdflatex %" && "C:\Program Files (x86)\Adobe\Reader 8.0\Reader\AcroRd32.exe" %:p:r.pdf


(Windows should stop using the escape character for the directory separator).

Edit
A smarter person would have installed miktex for windows and discovered that "start" launches the program associated with the filetype which reduces this to:

map = :!pdflatex % && start %:p:r.pdf