Reviving a Power Mac G4 with Ubuntu Server
I had been considering building my own server for a home network and decided to buy an old garage Power Mac G4 400. This is a good computer and will work great as a server definitely so I decided to install Ubuntu Server on it. I’m a Gentoo user normally but being the adventure that I am I decided to try something new.
Ubuntu official doesn’t support PowerPC documentation or installation-CDs anymore but the community do still produce installtion-CDs.
Hardware
Processor - G4 400MHz
RAM - 512 MB
Videocard - Rage 128 Pro, AGP 4xsl
Hard Drive - 10.3 Quantum Fireball LM10.2
Network - Built-in Sun GEM Gigabyte Ethernet
- TRENDnet TEG-PCITXR Gigabyte Ethernet - uses Realtek 8169 chipset
The best place to begin with an old computer is to test the hardware. Apple has done a good thing and made their PowerPC Hardware Test CDs available for download. You’ll need Mac OS X to burn CD dmg images though, I’ve tried various Windows (MagicISO) and Linux utilies (dmg2iso, dmg2img, acetoneiso2) that don’t work.
I’m building a server to use as a firewall so all the hardware is there except an additional network card. Another network card will be needed to route to another computer. Here’s good list of Power Mac G4 network cards that work in OS X, check and see if there is a Linux driver for them. The card listed above does.
Update Firmware
The firmware will need to be updated to the most recent available. You can check this by booting into Open Firmware (Apple + Option + O + F) at boot and looking at the OF version on the top then compare it to the newest on Apple’s website.
This firmware update requires Mac OS 9.1, luckily I have an old iBook 9.0 install disk that installed. The old software update panel doesn’t work any more though but the 9.1 update can be downloaded. I downloaded the files onto my Linux desktop and burned them to disk:
mkisofs -o PowerMacG4-Updates.iso G4_FW_Update_4.2.8.smi.bin \ Mac_OS_9.1_Update.smi.bin cdrecord -v -dao PowerMacG4Firmware.iso
Reset NVRAM, PRAM, Clock
It’s a real good idea to reset the NVRAM, PRAM and Clock in case any values are set incorrectly:
- Remove or disconnect the memory battery. Leave the battery disconnected for 5-10* minutes.
- Reinstall or reconnect the battery.
- Depress the CUDA (aka PMU) button (for 5 seconds) with a non-metallic (plastic, wood, etc.) device.
- If this doesn’t work, change the RAM. Either add or remove a stick then zap the PRAM (Apple+Option+P+R), wait for three chimes. After that shutdown, add/remove the RAM and start again.
Clock Set, Optional Password
Boot into Open Firmware again and set the clock (military time):
decimal dev rtc sec min hour day month year set-time
Optionally you can add security so no one can tamper your Open Firmware settings, and add protection from being able to be able to boot directly to disk, CD, or netboot.
Linux StartCD
I used Linux to download and burn the install CD, Ubuntu CD’s can be found here.
And burned them with:
cdrecord -v dao name.iso
The Power Mac G4 Sawtooth Open Firmware only has rudimentary support for Linux and cannot boot Linux CD’s by holding down C or holding down option. Rather you will need to direct OF to the Linux InstallCD’s yaboot file:
boot cd:,\install\yaboot
Select Kernel and Options
The Ubuntu Installer will now ask what kernel to load and will tell of a few options that can be passed to the kernel. For most people, the default install-ppc will do – use -smp for duelcpu systems. I decided on the expert-powerpc.
For reference, I followed and the Ubuntu Server Guide and the slightly aged Ubuntu PowerPC Guide for PowerPC related parts.
Switch to Console for a Couple Tasks
When the installer begins a couple tasks may need to be done. First if you didn’t use the Apple Hardware Test Disk, check the hard disk now for bad blocks. Also the console too add the ide-scsi device to the kernel, the Debian installer fails to recognize it. Get to the second console by pressing Ctrl + Alt + F2.
Check for Damaged Blocks on Drive(s):
Bad blocks can cause serious problems running software. If you discover a bad block it will be marked and not used but be warned when drives begin to get bad blocks the drive is almost always failing.
mac-fdisk -l mke2fs -j -c /dev/sda
DVD/CD-ROM Drive Not Detected
On this computer, the installer failed to load the driver to have the DVD/CD-ROM work (go ahead – it won’t hurt if you don’t need it):
modprobe ide-scsi
Return to the install by doing Ctl + Alt + F1
Time to Build
Basically you just go step by step. Select you langauge and in keyboards select “macintosh” for keyboard. “Detect and Mount CD-ROM” should now work, then “Load debconf…” and then “Load installer components from CD”. I did this quickly after the “Detect and Mount…” option because once the CD was forgoten by the installer.
In “…InstallerComponents” the only option I choose was “mirror select” but its buggy and didn’t work for me. You can find the mirrors available and then you have to enter the mirror without any subdirectories (e.g. ftp.osuosl.org) in the next dialog enter the subdirectorties (e.g /pub/ubuntu-releases/). I ended up choosing the default UK mirror. The mirror can later be change in /etc/apt/sources.
You’ll need to have to download some files for the download to complete so setup the network.
When you get to partitioning choose the one right for you. I decided on the LVM with encryption. This too has a bug. I got a dialog that said “No NewWorld boot partition was found…”. Yaboot (the Mac bootloader) requires this to boot. As I said its a bug and you can ignore it. It will ask you, “Go back to the menu and resume partitioning?” Select “No” and write the partition table.
The rest should be pretty self explanitory, configure the package manager, users… I opted to have a root account because I know “rm -f /” is bad. ;) Install the software you need. The Ubuntu Server Guide details plenty of options: a dns server, firewall, web server… I installed OpenSSH server because it’s easier just to have one monitor on my desk. LAMP to use apache for webadmin tasks (OSSEC-HID, snort) and DNS Server to setup a local LAN.
Now install the yaboot bootloader (skip LTSP), and thats all you need to do. End the installtion and it’ll ask you what type of clock you want. I set the clock to UTC time.
Reboot system and see your new Ubuntu server.
Package Management
I’ve built a script to use from the command line that I’ve put on the Ubuntu Forums for package management.
Etc.
change console font in /etc/default/console-setup
Debians bashrc tanks – better bashrc
vim-lite wtf?
Good luck with your new OS!
Resources
PCI, PCI-X, PCI Express – Oh boy!
Lately I bought an old pc to use as a server and needed a network card for it. I didn’t think it be such a hassle but because of multiple PCI specs finding a card wasn’t easy. Theres been alot of confusion about pci cards and what card to get for your computer – PCI cards come in alot of different types and versions. I’ve done a good amount of research on this (if there are any discrepancies, please let me know) and hopefully this post will help clear things up.
PCI
Standard PCI cards (sometimes called pci 1.0) have a 32 bit width slot, and operate at 33 MHz. Originally they started as 5 volt cards but 3.3 volt cards began to be made that use a different slot.
PCI 2.1 came a few years later that added the Universal PCI card spec that allowed cards to be used in both 3.3 and 5v slots, and upped the bus to 66 MHz. Also they created a pci 64 bit width slot for high end cards (gigabit networking,…). This meant that there could be one of 4 different slots in your computer: 5v 32bit, 3.3v 32bit, 3.3v 64bit, 5v 64bit (see graphic below). This meant you either had to buy an exact card for the slot or a universal card (which most manufactures began to build).
The PCI bus 2.3 spec came along and nix’d 5v adapters (cards). PCI 2.3 was adaptable though and supported 3.3v cards and universal pci cards.
PCI-X
PCI-X or PCI eXtended was built mainly for high end use. It has a bus speed of 66 or 133 MHz and only used the 64 bit 3.3v slot. It is fully backward compatible though with the existing PCI architecture: 33/66 MHz PCI adapters (cards) can be used in PCI-X slots and PCI-X adapters can be used in PCI slots. PCI-X 2.0 came along and really upped the bus speed to either 266 MHz or 533 MHz, but was still fully backwards compatible.
Which Card to Get?
Well really you can get any universal card and have it work. Carnildo helped me see things the easy way:
The rule of thumb for PCI and PCI-X cards is that if it fits in the slot, it’ll work. The bus and cards will negotiate the fastest, widest connection that all of them can use, so a 133MHz 64-bit card in a standard PCI slot will transfer data as if it were a 33MHz 32-bit PCI card.
Also keep in mind that, “The slowest board dictates the maximum speed on a particular bus!”
PCI Express?
PCI Express uses an entirely different architecture, different slot sizes, and is incompatible with with PCI or PCI-X. It’s expected to coexist with PCI-X and not replace it.

Thanks
Thanks to the guys at the Gentoo forums who helped me straighten this.
Updating BIOS with Linux
If you don’t have Windows installed and you need to upgrade your BIOS, Linux does have the tools to be able to create a BIOS flash CD. Not many companies make Linux flash utilities and alot of these utilites are DOS utilities so a bootable DOS disk is needed. This is a simple, easy way to create a BIOS flash CD.
First, get a BIOS image. You’ll need to download a BIOS image for your board. For information on what Flash utility to use, a good place to look is your computer manufacturers homepage. Award BIOS and American Megatrends BIOS are the most popular BIOS’s used on motherboards.
Editing FreeDOS Minimal Boot Image
FreeDOS provides a bootable DOS image. Download the DOS image to the Desktop:
wget http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.0/fdboot.img
and mount it:
mount -t vfat -o loop /home/user/Desktop/fdboot.img /media/ISO
The BIOS flash utility and BIOS image will need to be added to the freedos image. I prefer to use /media/ISO but any empty directory will do. The bootable image has a fixed size (1,440 Kb, the size of a floppy disk) and hence /media/ISO will also have that limited memory. The size needs to remain fixed in order to create a bootable floppy of it. You can see the space used in the image by:
du -b /media/ISO
Add the flash utility DOS executable and the BIOS image (there should be just enough room for it). I prefer to put these in a new directory but it’s up to you.
cd /media/ISO mkdir bios cp /home/user/Desktop/flashprog.exe /home/user/Desktop/bios-image /media/ISO/bios
The data added to the FreeDos image will be save when the ISO is unmounted:
umount /media/ISO
Now return to the Desktop and convert the appended FreeDos image to a bootable ISO:
mkisofs -r -b fdboot.img -c boot.cat -o fdboot-bios.iso fdboot.img
The -b option defines the floppy image used for booting; the -c option will create a boot.cat file that directs to fdboot.img and is necessary for booting; the -o option defines the output file, in this case a bootable iso; and finally the image file needs to be added.
Now just burn the iso to the CD/DVD:
cdrecord fdboot-bios.iso
Flash BIOS in Linux with Flashrom
Flashrom is a utility to directly flash the bios directly in Linux. It’s design to be a comprehensive utility and supports a good number of hardware devices. Above that, flashrom is easy to use. Check their page for compatibility, or install flashrom and see if it recognizes your chipset. I’d tell more but the flashrom website does a good job of telling about the utility. I also updated the Gentoo ebuild for flashrom.
Questions
Because BIOS sizes are getting larger, we may need to learn how to create larger bootable images. mkisofs mentions that is can create an El Torito (bootable) iso with either 1200 Kb, 1440 Kb, or 2880 Kb images. I know how to create an empty vfat image can be created with:
mkfs.msdos -C newimage.img 2880
And, of course, it can be mounted and the freedos files can be copied there, but how could we make it bootable?
Resources
Linux Html Editors; What Works, What Doesn’t
I’ve been using Linux for about two years now and I love to see Linux progress, but one thing I’ve had a difficult time trying to do is html editing. Linux has a number of html editors (Bluefish, Quanta Plus, Komodo Edit, Screem) but I left them all behind because I found with each the process became too laborious for creating quick web pages. A quick synopsis of why these editors didn’t work for me:
Bluefish is the most common Linux html editor(though I would label it a html-css-php editor). Bluefish has a nice feature that lets you add common tags to a toolbar, unfortunately the space of the toolbar runs out quickly and you’ll find yourself digging alot for tags. Bluefishes oversight (as of last testing a year ago) is that it doesn’t wrap tags around text. Highlighting a sentence and then clicking the tag will output the tag at the beginning of the text (both open and close).
Komodo Edit is a growing code editor in Linux that many people are beginning to migrate to. I hear it is a good editor for many different projects, however, html isn’t one of them. With the html plugin you’ll get a few tags HTML tags but HTML support is very very limited.
Quanta Plus also suffers ergonomically like Bluefish. A very complete html-css-php editor with good syntaxing. Quanta Plus does have a few easy to reach html tag buttons but you’ll find yourself digging alot for the others.
Of all the mentioned html editors, Screem by far is the Best because it concentrates on HTML and XML use and does them well. After taking a bit to set up Screem, Screem became a nice tool to work with.
Unfortunately Screem is not being developed anymore and you’ll still find yourself digging for tags. Also Screem tends to crash every now and then. Here’s the config for screem to save you time (includes auto-save option):
Why none of the above editors make more tags available in the toolbar and feel that all tags should be nested in one menu?… I don’t know. But I found two applications that were designed better for basic html editing. They both do a good job of making tags and features more available: Amaya and Arachnophilia.
And Then There Was Amaya
HTML’s lost editor from the web consoritium itself, Amaya looks to be a great upcoming editor in it’s own right. Ergonmically Amaya has done a really good job of making popular tags accessible:
One of the better designed interfaces I’ve seen for a web editor. Amaya makes most tags available on the right toolbar with immediately below them options for those tags. Creating pages in Amaya is easy, quick and straightforward. I wrote a couple pages in Amaya and enjoyed it thoroughly. However this was when I discovered Amaya’s key flaw: Amaya inserts hard returns for carriage returns at the end of each visual line. Meaning that hard returns are Automatically entered depending on the width of the Amaya window. In proper HTML this isn’t a problem and pages appear correctly, but if you also use your HTML editor for blog posts like I sometime do, you end up with paragraphs that look like this:
This is just random typing that says nothing of real value, I just have to type enough to demonstrate
this bug, or oversight possibly. At version number ten this is a hard to believe that this errant
feature wasn’t one of the first bugs fixed.
Note: the version I used for this test is version 10.0.1, the newest Amaya release is 10.1_pre5 but I saw no mention in the release notes of this bug being fixed.
Something New, Something Unexpected… Arachnophilia
I’d just about given up on finding an HTML editor I could use without the process becoming too tedious when I happened upon Arachnophilia.
Arachnophilia isn’t technically a Linux program rather it’s a java program. I’ve avoided using java programs in the past because my computer wasn’t fast enough and would grind to a halt using java. On my newer computer with java (dev-java/sun-jdk-1.6.0.11) programs runs better.
There is no installing Arachnophilia, all you have to do is download the Arachnophlia jar and direct java to start it:
java -jar Arachnophilia.jar
Arachnophlia is well designed and allows easy accesibility to tags.
Three toolbars of tags are already available and include most commands used, but more can be easily added:

So editing is quick and painless: select the text, click the tag. The best feature about Arachnophilia is that it allows you to add new html tags:

Now I got an HTML editor I truely like in Linux. If you’re just looking for basic HTML editing, Arachnophilia is a great choice. If you need to do php work, or css, take a look at the editors above.
A Few Other Possibilities
Through WINE some other HTML editors that might be able to run. I haven’t tried any of these:
Free
- ? Notepad++
- ? Coffee Cup – not offered anymore, but a download should be able to be found.
- ? EditPlus
Non-Free
Resources
Encrypting/Decrypting a File Easily With a Couple Bash Scripts
Once in a while a person might like to encrypt a file for security purposes. In Linux it is real easy to create good encryption using openssl with the Triple-DES Cipher.:
openssl des3 -salt -in unencrypted-data.file \ -out encrypted-data.file.des3
After entering this command, openssl will ask for you to enter the password twice. And decryption is likewise:
openssl des3 -d -salt -in encrypted-data.file.des3 \ -out unencrypted-data.file
Remembering this command though is the tricky bit so I decided to create a couple bash scripts that made the process thoughtless. I named the bash scripts “crypten” and “cryptde“.
#!/bin/bash # crypten - a script to encrypt files using openssl FNAME=$1 if [[ -z "$FNAME" ]]; then echo "crypten <name of file>" echo " - crypten is a script to encrypt files using des3" exit; fi openssl des3 -salt -in "$FNAME" -out "$FNAME.des3"
The filename ends with .des3 to be easy to recognize.
#!/bin/bash
# cryptde - a script to decrypt files using openssl
FNAME=$1
if [[ -z "$FNAME" ]]; then
echo "cryptde <name of file>"
echo " - cryptde is a script to decrypt des3 encrypted files"
exit;
fi
openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
I like to put my bash scripts in a ~/.bin folder. Don’t forget to make both files executable:
chmod +x crypten cryptde
This shouldhelp make encrypting/decrypting files easier.
Grub Password-protection
Password-protecting Grub may be necessary if the BIOS doesn’t have password support and you could be in a better environment.
Decide what the password is going to be and don’t forget it ;). To encrypt a password to put in your grub configuration file, use:
Password:
Retype password:
$1$ZOGor$GABXUQ/hnzns/d5JYqqjw
Type in the password twice and copy the md5 encrypted password to /boot/grub/menu.lst:
password –md5 $1$ZOGor$GABXUQ/hnzns/d5JYqqjw
The password line must be on one of the first few lines of the menu.lst file. If there are a lot of comments at the beginning of the grub.conf file don’t try to put it after them or it won’t work either. Also, take out the timeout value if you have one as it can sometimes cause problems.
Now each boot entry much be told to be locked if you want it to be:
lock
root (hd0,4)
kernel /boot/kernel-2.6.27 root=/dev/sda5
Tallyho!





