Sunday, August 21, 2005

Configuring xfree86 on Pismo: XF86Config-4

And Debian is slowly coming to life on my Pismo powerbook (G3/500 Firewire). After a few false starts and quite a bit of googling, I came up with this XF86Config-4 file, which works perfectly with the Pismo's lcd screen, keyboard, trackpad, and an external USB Logitech optical mouse I have plugged in (with true plug-and-play). It did not work with a Microsoft wireless optical laptop mouse I tried, and I'm sure I could have added that mouse to the config file and tinkered with it, but instead I returned that $50 mouse, bought another $20 Logitech optical mouse, and saved 30 bucks and a bit of headache. One caveat: xinit's startup output reports an error, that it couldn't load the r128 module, and that DRI wouldn't work. DRI is Direct Rendering Interface, and I believe it's necessary for things like gaming and intensive 3D rendering. Since I won't be doing any of that on this machine (it's just an old Pismo after all), it's not an issue - the IceWM window manager works fine, as do Firefox and XEmacs, and so far that's all I need. I haven't tested the config file with gnome or kde, but I don't see why it wouldn't work with them too (but on a Pismo, I recommend IceWM - it's lightweight and snappy, and all you really need). The steps I took: 1) Installed the following debian packages: discover, mdetect, and tpconfig, for supporting auto-detection and configuration of the screen, mouse, and trackpad. I don't know if these were essential or not, but I installed them and everything subsequently worked. I configured tpconfig with the --tapmode=0 option, to disable trackpad-tapping as button clicks. 2) Installed xfree86, icewm, and all dependent packages using dselect. 3) Modified the default /etc/X11/XF86Config-4 file until it looked like the text below. 4) Created a script, /usr/local/bin/ice, that looks like this, chmod 777'd it, and ran it:

#!/bin/bash
xinit /usr/bin/icewm -- :0
This started the xserver and the icewm window manager, and I could sleep a happy man. And now, the config file.

# XF86Config-4 (XFree86 X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the XF86Config-4 manual page.
# (Type "man XF86Config-4" at the shell prompt.)
#
# This file is automatically updated on xserver-xfree86 package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xfree86
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following commands as root:
#
#   cp /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.custom
#   md5sum /etc/X11/XF86Config-4 >/var/lib/xfree86/XF86Config-4.md5sum
#   dpkg-reconfigure xserver-xfree86

Section "Files"
  FontPath    "unix/:7100"            # local font server
  # if the local font server has problems, we can fall back on these
  FontPath    "/usr/lib/X11/fonts/misc"
  FontPath    "/usr/lib/X11/fonts/cyrillic"
  FontPath    "/usr/lib/X11/fonts/100dpi/:unscaled"
  FontPath    "/usr/lib/X11/fonts/75dpi/:unscaled"
  FontPath    "/usr/lib/X11/fonts/Type1"
  FontPath    "/usr/lib/X11/fonts/CID"
  FontPath    "/usr/lib/X11/fonts/Speedo"
  FontPath    "/usr/lib/X11/fonts/100dpi"
  FontPath    "/usr/lib/X11/fonts/75dpi"
  ModulePath    "/usr/X11R6/lib/modules"
  ModulePath    "/usr/X11R6/lib/modules/dri"
  ModulePath    "/usr/X11R6/lib/modules/drivers"
EndSection

Section "Module"
  Load    "GLcore"
  Load    "bitmap"
  Load    "dbe"
  Load    "ddc"
  Load    "dri"
  Load    "extmod"
  Load    "freetype"
  Load    "glx"
  Load    "int10"
  Load    "record"
  Load    "speedo"
  Load    "type1"
  Load    "vbe"
EndSection

Section "InputDevice"
  Identifier    "pismo-keyboard"
  Driver        "keyboard"
  Option        "CoreKeyboard"    "true"
  Option        "XkbRules"    "xfree86"
  Option        "XkbModel"    "macintosh"
  Option        "XkbLayout"    "us"
EndSection

Section "InputDevice"
  Identifier    "trackpad-or-usb"
  Driver        "mouse"
  Option        "CorePointer"        "true"
  Option         "Protocol"         "ExplorerPS/2"
  Option        "Device"        "/dev/input/mice"
  Option        "Buttons"        "4"
  Option         "Emulate3Buttons"    "1"
  Option        "ZAxisMapping"        "4 5"
EndSection

Section "Modes"
  Identifier     "mode-0"
  ModeLine     "1024x768" 65.0 1024 1064 1200 1344 768 771 777 806 -hsync -vsync
EndSection

Section "Monitor"
  Identifier    "pismo-lcd"
  ModelName    "Monitor Model"
  UseModes    "mode-0"
  HorizSync    30.0 - 70.0
  VertRefresh    50.0 - 160.0
  Option        "DPMS"
EndSection

Section "Device"
  Identifier    "ati-rage-128"
  Driver        "r128"
  BoardName    "Unknown video card"
  Option        "HWcursor"
  Option        "UseFBDev" "true"
  BusID        "PCI:0:16:0"
EndSection

Section "Screen"
  Identifier     "screen-0"
  Device         "ati-rage-128"
  Monitor        "pismo-lcd"
  DefaultDepth    24
  SubSection "Display"
    Depth    8
    Modes    "1024x768"
  EndSubSection
  SubSection "Display"
    Depth     16
    Modes     "1024x768"
  EndSubSection
  SubSection "Display"
    Depth      24
    Modes    "1024x768"
  EndSubSection
EndSection

Section "ServerLayout"
  Identifier    "Default Layout"
  Screen        "screen-0"
  InputDevice    "pismo-keyboard"
  InputDevice    "trackpad-or-usb"
EndSection

Section "DRI"
  Mode    0666
EndSection

Saturday, August 20, 2005

Debian on a Powerbook: Airport

Debian uses my Pismo's airport card quite naturally, but it took a while to learn how exactly to configure it to do so. In short, 1) Include the airport module during Debian's installation process. 2) Use dselect to install the 'wireless-tools' package, which provides iwconfig and other tools. 3) Modify /etc/network/interfaces to look like this (see the Debian reference's wi-fi setup section):
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# don't automatically connect to eth0, the wired ethernet - Jake
#auto eth0
iface eth0 inet dhcp

# the airport card - connect automatically
auto eth1

# configure the airport interface eth1
iface eth1 inet dhcp
      wireless-essid jakenet
      wireless-key XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XX
Note that you cannot specify the wireless network encryption key as the ascii password you use in OS X. You need to use the hex key, which OS X's Airport Admin Utility will show you if you select the wireless network in question, click 'Config', and click 'Password'. I did this using my other Mac, on which I originally configured the base station and wireless network. Once I'd modified /etc/network/interfaces, I rebooted ('reboot' at the command line), to make sure everything would work going forward. You can also bring up the wireless connection without rebooting by typing 'ifup eth1' , which will refer to the modified /etc/network/interfaces to pick up the network name and encryption key, and connect to the wireless network. I think 'ifup' stands for 'interface up'. Originally I thought it meant 'if up', meaning that it would bring the interface down. There's a nerd for you - overthinking the problem and getting it wrong.

Tuesday, August 16, 2005

When Installing Debian . . .

Some reflections from day two of setting up Debian on a Pismo Powerbook. Don't run tasksel. It will install way too much for you at once. Better to wait until Debian is installed and humming nicely, and then install things a few at a time with dselect. This way you'll know exactly what's on your system, and you won't waste hard drive space, which on a 12GB Powerbook is at a premium. I was worried at first that I wouldn't know enough to install the right packages, but part of dselect's power is its knowledge of package dependencies. When you select something for installation it will tell you right away what other packages it requires to run. So even if you select a little graphical calculator program, it will first add the entire X windowing system and the GNOME window manager to the dependency list - you can't go wrong. I just pressed return to whatever dependencies it suggested, because it certainly knew better than me. Don't even run dselect - that is until the initial Debian installer is finished and you're sitting at the Debian prompt. I found it much easier to set things up once I was out of the installer and knew that there were no more surprises waiting. Play with dselect a bit. Once the installer's finished and you're in Debian proper, run 'dselect' and start poking around. Learn what the keys do, look at the different sort options (type 'o' to cycle through the sort options). Learn how to use dselect, because you'll be using it a lot. It took me a while to understand how I could view all my already-installed packages together in order to remove some. First package to install: lynx. Lynx is a text-based web browser, which I discovered tonight because I haven't set up X11 yet. Install lynx first because it frees you up from having to keep a second computer next to you as you set up the rest of your Debian system. If you have a question, type 'lynx http://www.google.com' at the command line, and look up the answers on the web right there. It's also damn cool to surf the web without a graphics system installed. lynx supports forms, downloads and cookies - everything, it seems, except images, javascript and plugins. Even my gmail account worked fine when I switched to the non-Javascript interface. It's good enough that I'm considering not installing graphics support at all.

Monday, August 15, 2005

Installing Debian on a Powerbook G3/500 Firewire (Pismo)

Last night I installed Debian (GNU's Linux) on my old Pismo powerbook which I'd otherwise written off as trash: Panther was just one spinning beach ball after another, and the hard drive was only 12GB - not the ideal multimedia machine. Since I have a newer Mac that I can use for media, this little Pismo is more than adequate as a dedicated software development box, and I've read that Linux is much more efficient than OS X on older hardware in terms of hard drive space, RAM and CPU speed required. I'm documenting my installation experience for any despondent googlers trying to do the same thing. Debian itself installed without a fight. I ran into two snags that I'm documenting here: 1) Getting the powerbook to boot into the Debian installer in the first place, and 2) Running into a space problem in the /var directory due to my partitioning scheme. Problem 1: Booting the Powerbook into the Debian installer In short, don't bother with installation CD's - you don't need them. Instead, install using just your hard drive and an internet connection, as described in section 4.5.2 in Debian's installation manual and on this most useful page. Doing so is a four-step process: 1) obtaining the Debian boot/installer files, 2) copying them to the root directory, 3) determining the root directory's partition number, 4) using that number to boot into the Debian installer. 1) First, obtain the following files, as described in Debian's manual: yaboot yaboot.conf vmlinux initrd.gz Obtaining these files wasn't entirely straightforward for me. Maybe there's an easier way, but the only place I could find them was embedded in the .iso image file of Debian's downloadable minimal installation CD image. Download the powerpc .iso file (which will take a while - it's 200M). Then double-click it to open it (Panther knows how to open these files), revealing a disk image. Double-click the disk image to mount it on your desktop. You'll find the above files in the /install and /install/powerpc directories within that disk image. 2) Copy the files to the root directory. Once you have these files, copy them from the disk image to the root directory of your hard drive ("Macintosh HD" in the Finder). You must copy them to this location - not just move them - because they need to physically reside at that location on the disk. So if you first copied them from the disk image to your desktop, hold down the Option key when dragging them from the Desktop to the "Macintosh HD" directory. 3) Determine the partition number of the root directory and write it down. Open the Terminal application (located in /Applications/Utilities) type 'pdisk' and press return. The pdisk utility will start, and will wait for your command. Type 'L' and press return. pdisk will list the partitions on your hard drive. The first one is partition 1, the second partition 2, etc. The first few partitions contain boot information and drivers used by OS 9. The rest of the system, including the root directory, sits on the biggest partition, which in my case was the last one, partition 6, and was directly after the last OS 9 driver. Write that number down. 4) Boot into the Debian installer Restart your mac into OpenFirmware (it's like Mac's boot manager) by holding down Option-Apple-O-F immediately after the "bong". You can let go of them when you have a text prompt on the screen, which for me showed up within a few seconds. At the prompt, tell it to boot into the Debian installer using the command boot hd:x,yaboot where x is the partition of the root directory on your hard drive as determined above. In my case, I typed 'boot hd:6,yaboot', and pressed return. This will then load the Debian installer, which will guide you fairly gently through the rest of the installation process, with lots of user-friendly questions and explanations. NOTE: I installed using a Road Runner cable modem and DHCP, and the Debian installer connected to the internet within about 10 seconds without any help from me. Problem 2: Putting /var on the wrong partition The least friendly step of the Debian installation is drive partitioning. Debian throws you into the mac-fdisk utility to partition your drive, which is not intuitive or user-friendly. I recommend this most useful page on installing Debian on an iBook, that explains how to use the mac-fdisk utility (and in general how to install Debian from the hard drive, though it specifies different files to put in the root directory than the Debian manual). For my partitioning scheme, I created the required boot partitions, a 'swap' partition of 512M (the same as the maximum allowed RAM on a Pismo), a 'root' partition of 300M, and a 'tmp' partition of 200M (mounted to /tmp). I then decided that I would lump /usr, /var and /home into one partition, because I wasn't sure how I'd end up distributing things among these directories. So I just created a final partition called 'main' containing the rest of the space on the drive. Debian then installed happily, but when I finally got to the 'tasksel' part of the installation process, which uses the /var directory extensively to store downloaded Debian archives, it complained that it didn't have enough free space in the /var directory, which meant that the /var directory wasn't in the big 'main' partition as I'd thought it would be. Apparently Debian puts /var in the 'root' partition. Running 'fdisk -l' showed that the big partition was mounted at /usr, meaning that only directories under /usr would use any of the big partition's space. At first I thought I'd have to repartition, but after some research I found an easier solution: I moved /var onto the big partition, but without doing anything fancy involving partition utilities. To do this, I created a new directory /usr/var, recursively copied /var into this new directory, and created a link from /var to /usr/var. Voila: /var now physically resides on the big partition and has as much space as it needs, while the link makes it look like it's in the root partition as Debian installed it. The commands involved (logged in as root): mkdir /usr/var cd /var cp -pr ./* /usr/var cd / mv var var-old ln --symbolic /usr/var var Once I did that, I could install Debian packages to my heart's content, using tasksel, apt or dselect, without worrying about partition sizes. I then did the same for /home, moving it under /usr. Now they all have as much space as they need among them, without having to put everything under one big 'root' partition as some people do. This way, if the /usr partition fails, odds are good that the /root partition will not fail with it, and I can still boot into the machine.