Thursday, October 22, 2009

pxe booting system rescue cd with a bnx2

The system rescue cd project has made progress on becoming more pxe bootable in 1.3.1 than it was in 1.1.2 or so. It worked like a charm on a machine of mine with an intel NIC. However, many of our machines have the Broadcom NetXtreme II cards (bnx2) which require firmware to load. Currently, the sysrcd firmware lives in the sysrcd.dat squashfs that should be loaded over tftp/http.

To fix this, I wedged the firmware in question onto the initram.igz filesystem and tweaked the /sbin/init script to fire up mdev (the udev replacement for busybox that is not told to load until after module probing and hotplug isn't initialized until much later in the boot process) so that the firmware can be loaded.

To unpack the initrd

mkdir initrd
cd initrd
gzip -dc path/to/initram.igz | cpio -id


Move the firmware over

mkdir lib/firmware
cp path/to/mounted/sysrcd.dat/from/cd/or/otherwise/lib/firmware/bnx2 lib/firmware
cd ..


in sbin/init, I added

mount_sysfs
setup_hotplug
start_dev_mgr


just above the line

good_msg "Loading the disk and network drivers required to boot..."


Repack:

find ./ | cpio -H newc -o > /tmp/new-initrd.cpio
gzip /tmp/new-initrd.cpio
mv new-initrd.cpio.gz initram-bnx2.igz


My pxelinux.cfg entry looks like this:

label netboot64
kernel sysrcd/isolinux/rescue64
append initrd=sysrcd/isolinux/initram-bnx2.igz netboot=tftp://192.168.1.10/pxelinux/sysrcd/sysrcd.dat console=tty0 console=ttyS0,9600n1 udev


Fetching sysrcd.dat over tftp isn't very fast, and it may be worth looking into the http method.

Wednesday, May 20, 2009

vimoutliner on debian

After looking for a clever way to keep notes in a marginally platform independent way, I found vimoutliner which adds some interesting features for folding and making todo lists and so on. I noticed that there was a debian package and I thought "cool I can easily check it out". It turned out to be a bit more complicated than I expected and I replicate my steps here for posterity:

apt-get install vim-vimoutliner vim-addon-manager
vim-addons install vimoutliner

If it doesn't seem to work correctly when you open a *.otl file, ensure than your vimrc has

filetype plugin on

The other note, which is in the /usr/share/doc/vim-vimoutliner/README.Debian is that the ,, commands are in fact \ commands.

See :help vo for instructions.

Happy outlining.

Tuesday, March 17, 2009

Debian on 730i Nvidia Board w/HDMI

Put together a machine to run my TV at 1080p. The board is a evga 113-yw-e115-tr. Installed Debian 5.0 (amd64) from a usb key. The biggest hiccup was getting sound output via the HDMI port.
The major steps were:

  • Install alsa-sources from unstable (to version 1.0.19) (apt-get ...; m-a a-i alsa)

  • Install libasound2 from unstable

  • Install nvidia-kernel-source from unstable (m-a a-i nvidia)



Edit: When trying to repeat this process, I discovered that hdmi output would not load without an up-to-date nvidia module that had been not only loaded, but initialized by the X driver.

This gets the HDMI device into Alsa's view:

proost:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: ALC888 Analog [ALC888 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 1: ALC888 Digital [ALC888 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0


It took a while to discover that, and then I found that I could playback wav files via aplay -Dplughw:0,3 .... After setting up a basic asound.conf I discovered that not all players output 48kHz. I found some hints that alsa can ensure a specific output rate and that worked well. Then I discovered that dmix (multiple streams) wasn't working. The net result (/etc/asound.conf) is:

pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dsp0 {
type plug
slave.pcm "dmixer"
}
pcm.dmixer
{
type dmix
ipc_key 1234
slave {
pcm "digital-hw"
rate 48000
}
}
pcm.digital-hw {
type hw
card 0
device 3
}
ctl.digital-hw {
type hw
card 0
}
ctl.mixer0 {
type hw
card 0
}

With the slave line alsa ensures that output is at 48kHz.

The other hiccup was getting the picture to fill the screen. Standard TV signals crop the edges a fair bit. This didn't show up on the vga cable, but it did for HDMI. After searching the Internet far and wide, it turned out that I can set the picture size to "Just Scan" and it works beautifully. The only other issue was setting the default font size to be less huge (Option "DPI" "120 x 120") in xorg.conf.

Monday, November 17, 2008

Gnuplot Umlauts when input isn't in iso_8859_1


# Blah
set output 'thingie'
set encoding iso_8859_1
plot 'datafile' title 'Na\357ve' # gets i umlaut, a is 345 or so.

Thursday, November 13, 2008

Port bouncing with iptables.

This just turned out to be useful to someone other than me, and I forget how I did it periodically, so:

The situation is that I am on a network where there are machines with globally routable addresses and some with private addresses. Suppose I want to get traffic from outside on the internet, but I don't want to add port-forwards to the NAT machine (Don't want to make the sysadmin manage it and I don't want to do mysterious things to those machines). Since I have a machine with a globally routable address, I can bounce the packets to the internal machine via:

DPORT=XXX
PRIVADDR=XXX.YYY....
# To
iptables -t nat -A PREROUTING -i eth0 -p tcp -d $EXTIP --dport $DPORT -j DNAT --to-destination $PRIVADDR
#from
iptables -t nat -A POSTROUTING -p tcp -d $PRIVADDR -s ! $EXTIP --dport $DPORT -j SNAT --to-source $EXTIP


If you need to target different ports, I think you can do something like

iptables -t nat -A PREROUTING -i eth0 -p tcp -d $EXTIP --dport $DPORT -j DNAT --to-destination $PRIVADDR:$OTHERPORT
iptables -t nat -A POSTROUTING -p tcp -d $PRIVADDR -s ! $EXTIP --dport $OTHERPORT -j SNAT --to-source $EXTIP

But I haven't tested it (dig around in the iptables man page under DNAT).

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

Wednesday, June 25, 2008

Vista Caps-Lock to Control Re-Mapping

Abbreviated from here: Windows Scancode Mapping.

This is the caps/ctrl swap without the ctrl->caps side.

caps2ctl.reg:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,20,00,00,00,1d,00,3a,00,00,00,00,00

Sunday, June 15, 2008

IPV6 OpenWrt Kamikaze.

This is mostly an adaptation of various ipv6 install bits around.
Kamikaze is a little different, and the documentation isn't entirely
complete -- so I thought I would reproduce what I did in here. It isn't
perfect, but it is working for my /64 delegations of the /48 I have
routed to my fat-pipe machine.

Names changed to protect the innocent.


ipkg install kmod-ipv6
ipkg install radvd
ipkg install ip
ipkg install kmod-ip6tables
ipkg install ip6tables


/etc/hotplug.d/iface/10-ipv6:

. /etc/functions.sh
NAME=ipv6
COMMAND=/usr/sbin/ip
IPV6PREFIX="the:/48:subnet:here:2"
REMOTE="fat.pip.es.heh"

[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
[ -x $COMMAND ] && {
VLAN=$(nvram get ${INTERFACE}_ifname)
IFNAME=eth0.${VLAN#vlan}
IPV4=$(ip -4 addr show $IFNAME | grep inet | cut -f6 -d' ' | cut
-f1 -d'/')
ip tunnel add fatty-ipv6 mode sit ttl 255 remote $REMOTE local $I
PV4
ip link set dev fatty-ipv6 up
ip -6 addr add ${IPV6PREFIX}::2/48 dev fatty-ipv6
ip -6 route add ::/0 dev fatty-ipv6 metric 1
}
}
[ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ] && {
[ -x $COMMAND ] && {
VLAN=$(nvram get ${INTERFACE}_ifname)
IFNAME=eth0.${VLAN#vlan}
IPV4=$(ip -4 addr show $IFNAME | grep inet | cut -f6 -d' ' | cut
-f1 -d'/')
ip -6 route flush dev fatty-ipv6
ip tunnel del fatty-ipv6
}
}


/etc/config/network:

config interface lan
option type bridge
option ifname "eth0.0"
option proto static
option ipaddr 192.168.1.1
option ip6addr the:/48:subnet:here:2::2/64


/etc/config/firewall:

accept:proto=41


/etc/firewall.user:

iptables -t nat -D POSTROUTING -o wan -j MASQUERADE
iptables -t nat -A POSTROUTING --protocol ! 41 -o wan -j MASQUERADE


/etc/radvd.conf:

interface br-lan
{
AdvSendAdvert on;

#
# Disable Mobile IPv6 support
#
AdvHomeAgentFlag off;

#
# example of a standard prefix
#
prefix the:/48:subnet:here:2::/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr off;
};

};


/etc/init.d/radvd enable

Reboot, or whatever. {/etc/init.d/(network|firewall|radvd) restart}

Sunday, June 8, 2008

FreeBSD 7.0 on Thinkpad x60s

Installation (Borrowed/adapted from here).

  1. Grab a boot-only nfs image from here.

  2. Copy the cd contents into the filesystem:

  3. mount -o loop /path/to/7.0-RELEASE-i386-bootonly.iso /mnt
    mkdir /freebsd
    cp -rP /mnt/boot/ /freebsd
    umount /mnt

  4. Edit /freebsd/boot/loader.conf to add:
    vfs.root.mountfrom="ufs:/dev/md0c"
    to use ramdisk root instead of nfs.

  5. Edit /etc/dhcpd.conf to add:

  6. host x60 {
    hardware ethernet xx:xx:xx:xx:xx:xx;
    fixed-address 10.0.0.xx;
    next-server 10.0.0.2;
    filename "pxeboot";
    option root-path "10.0.0.2:/freebsd";
    }

  7. Copy the pxeboot image to your tftp root dir:
    cp /freebsd/boot/pxeboot /var/lib/tftpboot

    NOTE: I had trouble with the 7.0 pxeboot ("Can't work out which disk we are booting from"). Crawling the web indicated that it was a 7.0 pxeboot problem and pulling the boot/pxeboot binary from a 6.3 iso image worked.
  8. I already had a tftp server installed (I use the tftpd-hpa server).

  9. Install an nfs server (temporarily if necessary (apt-get install nfs-kernel-server)).

  10. /etc/exports:
    /freebsd 10.0.0.xx(ro,subtree_check)

At this point, installation worked for me.

Getting the hardware working
  • Wireless

    1. Get the drivers loaded

    2. /boot/loader.conf
      # See man if_wpi if you want to know what you are agreeing to.
      legal.intel_wpi.license_ack=1
      if_wpi_load="YES"
      wpi_load="YES"
      wpi_amrr_load="YES"
      wpifw_load="YES"
      wlan_xauth_load="YES"

    3. WPA:
      /etc/wpa_supplicant.conf
      network={
      ssid="yourssidhere"
      psk="Your clever passphrase with lots of character variation
      }

      /etc/rc.conf
      ifconfig_wpi0="WPA DHCP"
      To start it, you can run /etc/rc.d/netif start

  • Sound

  • /boot/loader.conf
    snd_hda_load="YES"
  • X.org

  • Xorg -configure
    cp /root/xorg.conf.new /etc/X11/xorg.conf

  • Finger Print Reader

  • To be explored.

Miscellany
  • /etc/make.conf
    CPUTYPE?=core