Thursday, June 25, 2009

Debian Installation on Servers With Broadcom 5708/5709 NICs using the bnx2 driver

Installing Debian on a system with Broadcom network interfaces can be quite annoying because the firmware is no longer included. If you load the firmware onto a usb disk as suggested, you run into other problems when using scsi drives resulting in a system which requires hacking menu.lst after install to boot. This approach doesn't work if you're using iLO/DRAC/iDRAC to install as they only allow one remote media connection at a time.

An easy workaround is to modify your install iso to contain the drivers. Here's how:
  1. Download a newish Debian install iso.
  2. Mount the install iso:
    1. mkdir cdrom
    2. mount -o loop debian-testing-amd64-CD-1.iso cdrom
  3. Copy the files:
    1. mkdir isocopy
    2. cp -av cdrom isocopy
  4. Download the appropriate firmware package for your installation, such as
  5. Extract the drivers and copy into your new iso:
    1. dpkg-deb -x firmware-bnx2_0.16_all.deb firmware
    2. cp firmware/lib/firmware/* isocopy/cdrom
  6. Build a new iso:
    1. cd isocopy/cdrom
    2. mkisofs -o ../modified-debian.iso -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V disks .
  7. Done, let's look at our new iso:
    1. cd ..
    2. ls modified-debian.iso

You can now burn this iso to a CD or use it as virtual media.

There's one final step, which is getting the OS to see the firmware drivers.

Once booted to the new ISO, you need to immediately switch to another console and copy the files over before the installer looks for them:
  1. mkdir lib/firmware
  2. cp /cdrom/*.fw lib/firmware
After that's done, the Debian installer should be able to autoload the bnx2 driver without any problems.

Monday, June 15, 2009

php utf-8 chr() and ord() equivalents

As far as I can tell, PHP provides no built in methods of working with multi byte characters.

Here is a simple function for turning an integer value into a character:

function unichr($intval) {
return mb_convert_encoding(pack('n', $intval), 'UTF-8', 'UTF-16BE');

A uniord() function can be found in the comments of the PHP manual: