notes on javascript, linux, and more

8.22.2008

Installing Debian Etch-and-a-half onto a Powerbook G3 (Wallstreet)

This is the hardware and software I used, since my bay CD Drive was broken. As you can see, I have a lot of handy junk laying around. It helps to live 3 blocks from Micro Center as well.
  • 1x PCMCIA->USB adapter
  • 1x 2GB USB Flash Drive
  • 1x IDE CD/DVD-RW Drive
  • 1x USB -> IDE hard drive enclosure, opened up (to connect the CD Drive)
  • BootX 1.2.2
  • CarbonLib_1.0.4.smi.bin
  • aladdin-expander-6.0.sea.hqx
  • Mac OS 8.1, installed to Mac's HD
  • debian-40r4a-powerpc-netinst.iso, burned to CD
  • Ethernet connection to internet
  • method to transfer files to and from the powerbook (I used a FAT32 formatted CF card in a PCMCIA adapter)

The first step is to get the bootloader installed. I used the BootX bootloader, but for some reason the downloaded .sit files wouldn't expand, except for v1.1.3. I had Stuffit Expander 5, so decided to find an upgrade. I googled around for aladdin-expander-6.0.sea.hqx and got what I needed. However, this required me to download CarbonLib. After that, the .sit files expanded with no problem. The latest BootX at the time of this writing was BootX v.1.2.2.

I placed the BootX App into Control Panels, and the BootX Extension into Extensions.
I tranferred a copy of the /boot/initrd and /boot/vmlinux files from the Etch CD to my Powerbook. I placed initrd.gz and vmlinux in /System Folder/Linux Kernels on my PowerBook. Then I unplugged my PCMCIA cards, rebooted and was presented with the BootX bootloader window. I hit tab to select linux, then I went into Options, and turned SCSI on, and set the ram disk to initrd.gz. I saved the preferences, plugged in both the USB Flash drive and the USB CD Drive to the PCMCIA adapter and booted linux.

I was presented with the Debian installer. Video was a little strange, but I figured I could deal with that later. I had to manually set the CD-ROM device to /dev/sr0 (check the debug console with ALT+F4 for info on your devices if your CD drive isn't autodetected). The ethernet drivers loaded and DHCP assigned an IP, then I partitioned my USB Flash drive (/dev/sda, NOT /dev/hda -> that's MacOS and we need it to boot with BootX). Installation of the core packages took a while with my meager 64MB of RAM.

When installation completed, I opted not to install a bootloader, as I saw reports of issues with quik and the Wallstreet. Instead, I pressed ALT+F4 to open a terminal, and copied /boot/vmlinux and /boot/initrd.img to my web server using netcat. I pressed ALT+F1 to get back to the installer, and let it reboot. I booted into MacOS, and downloaded the ramdisk image and kernel to my Linux Kernels folder, reconfigured BootX for the new kernel, initrd, and root device (/dev/sda), saved the preferences, and rebooted.. voila! A customizable debian has revived this computer. Well, not quite. My PCMCIA-> USB adapter wasn't being registered when the kernel loaded modules from the initial ram disk. So, on my main Linux desktop, I did this, using the initrd.img from the powerbook's copy of Debian.


mkdir /tmp/initrd_ppc/
cd /tmp/initrd_ppc
gunzip < /path/to/ppc/initrd.img | cpio -i --make-directories


Then I plugged in the Flash drive with the Powerbook's Debian on it:


mount /dev/sdb2 /mnt
cp -R /mnt/lib/modules/2.6.18-6-powerpc/kernel/drivers/pcmcia /tmp/initrd_ppc/lib/modules/2.6.18-6-powerpc/kernel/drivers/
cp -R /mnt/lib/modules/2.6.18-6-powerpc/kernel/drivers/usb /tmp/initrd_ppc/lib/modules/2.6.18-6-powerpc/kernel/drivers/


I didn't know what modules I would specifically need, so I just lazily added everything from PCMCIA and added USB core:


echo "rsrc_nonstatic" >> conf/modules
echo "pcmcia_core" >> conf/modules
echo "pcmcia" >> conf/modules
echo "yenta_socket" >> conf/modules
echo "usb_core" >> conf/modules
echo "i82092" >> conf/modules
echo "pd6729" >> conf/modules


Then all I had to do was pack the initrd up again:


find /tmp/initrd_ppc/ | cpio -H newc -o > initrd.cpio
gzip initrd.cpio
mv initrd.cpio.gz initrd-custom.img


Copy initrd-custom.img to the Powerbook's Mac OS partition, have BootX point to it, and you should be able to reboot into Linux. Make sure you pass 'root=/dev/sda2' as kernel arguments (or /dev/whereveryourdebianpartitionis).

Cheers,
Elijahr

PS - I later upgraded to Lenny (current Debian testing) and it went quite well. All i had to do was the standard modification of /etc/apt/sources.list and then a dist-upgrade. Then I just modifed the initrd again. I'm in the process of repurposing the laptop as a videophone and cookie dispenser for my sweet old pit bull mutt while I am at work.

References:
http://www.linuxforums.org/forum/linux-kernel/82174-extracting-initrd-image.html
http://www.davison.org.nz/projects/hardware-software/debian-3-1-sarge-on-g3-powerbook-wallstreet

8.11.2008

Preventing DynDNS.org update abuse

I have been using the free service at www.dyndns.org to keep tabs on my home server's IP address. However, I replaced my wireless/ethernet router, and the new one did not have built in dyndns.org updating, as my old one did.

I decided to use a software solution on my Debian based server. At first, I tried ddclient, but for some reason, it would stop sending updates after a few hours. Then I tried inadyn, but that caused my hostnames to get flagged for abuse. It seemed that neither of the tools was correctly checking the IP address before attempting to make the update, they were just sending the updates periodically even when my IP hadn't changed. This violates dyndns.org's abuse policy, so I just decided to write a simple wrapper script.

#!/bin/bash
DYNIP=`host foo.example.com`
DYNIP=${DYNIP#* has address }

wget -O- http://www.whatismyip.org/ 2>/dev/null > /tmp/currentip

echo current ip\: `cat /tmp/currentip`
echo ip on file\: $DYNIP

if [[ \"`cat /tmp/currentip`\" = *\"$DYNIP\"* ]]; then
echo "ip is up to date"
else
echo "must update"
/usr/sbin/inadyn
fi

rm /tmp/currentip



then i set up inadyn as follows:

# /etc/inadyn.conf

--username myuser --password mypass --alias foo.example.com --iterations 1



So now I just have my script running as a cron job once every hour. From my understanding, I shouldn't need this wrapper, but both inadyn and ddclient were mysterously updating my hostname mapping when they shouldn't have. I could very well have configured them wrong, but things looked ok to me and this solution works, so I'll let it be.

About Me

My photo
chicago, il, United States
I'm a software engineer by profession.

Labels