x=/boot/vmlinuz-2.6.26-2-amd64 dd if=$x skip=`grep -a -b -o -m 1 -e $'\xf1\x8b\x08\x00 $x | cut -d: -f 1` bs=1 | zcat > /tmp/vmlinux
Sunday, December 13, 2009
One-liner to extract vmlinuz to vmlinux
The hex string is the gzip offset. I've seen variations of this around, many using od. (The od approach doesn't work when the magic string spans output lines).
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
Move the firmware over
in sbin/init, I added
just above the line
Repack:
My pxelinux.cfg entry looks like this:
Fetching sysrcd.dat over tftp isn't very fast, and it may be worth looking into the http method.
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:
If it doesn't seem to work correctly when you open a *.otl file, ensure than your vimrc has
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.
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:
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:
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:
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.
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:
If you need to target different ports, I think you can do something like
But I haven't tested it (dig around in the iptables man page under DNAT).
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:
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:
- Install Qemu.
- Put freedos in a qemu image
- Insert USB Device, figure out name (/dev/da0 in my case)
- Make an empty image that is exactly the same size (
dd if=/dev/da0 of=flashthing.hd ) - Boot the qemu image with -hdc flashthing.hd
- fdisk it (xfdisk, I don't remember, probably reboot, should give you d:)
- format \s d:
- 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). - 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 - 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 - 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)
cd cdrom andcommand.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:
(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 = :!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:
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.
/etc/hotplug.d/iface/10-ipv6:
/etc/config/network:
/etc/config/firewall:
/etc/firewall.user:
/etc/radvd.conf:
/etc/init.d/radvd enable
Reboot, or whatever. {/etc/init.d/(network|firewall|radvd) restart}
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}
Subscribe to:
Posts (Atom)