May 2nd, 2005 Edition

by Adam Israel

Introduction

In this issue of Linux.Ars we're featuring a review of Knoppix Hacks, written by our very own Linux.Ars contributor Kyle Rankin. We'll also delve into the commercialization of open source projects, managing network interface naming with ifrename, and organizing your library with Alexandria.

Knoppix Hacks

Introduction/Leader

Knoppix Hacks, written by our very own Linux.Ars contributor Kyle "greenfly" Rankin, delves deep into the heart of Knoppix and shows how to use this "veritable Swiss Army knife in CD form" with a deadly and cunning accuracy.

What the heck is Knoppix anyway?

Even if you've never heard of Knoppix, you probably recogonize the "ix" suffix in the name as an icon of Unix. Linus begot Linux and Klaus Knopper begot Knoppix. Knoppix, like Linux, resulted from curiousity and personal need. Since its creation it has morphed into something much larger than its founding vision, in large part to Linux and the free software movement. Don't let this relationship deter you from exploring Knoppix. Knoppix may be based on Linux and open source software but is something anyone can use.

What, in short, is Knoppix?

KNOPPIX is a bootable CD with a collection of GNU/Linux software, automatic hardware detection, and support for many graphics cards, sound cards, SCSI and USB devices and other peripherals. KNOPPIX can be used as a Linux demo, educational CD, rescue system, or adapted and used as a platform for commercial software product demos. It is not necessary to install anything on a hard disk. Due to on-the-fly decompression, the CD can have up to 2 GB of executable software installed on it.

Who is Knoppix Hacks for?

Knoppix Hacks is an essential tool for anyone who works, professionally or not, with computers. Knoppix Hacks, just like Knoppix, is targetted at a wide audience ranging from System Administrators to the family "computer guy" called on to fix their cousin's PC.

Grouped by subject, the book is more of a cookbook than technical manual. Each hack, or recipe, stands on its own merits

There is a common misconception among people who have heard of Knoppix that it is only for Linux users. This perception couldn't be further from the truth. Knoppix, as demonstrated by the author, is an extremely useful tool regardless of your preferred operating system. This book is for anyone who has had to fix the computer of friends or family; the system administrator who has ever had to resuscitate a lifeless machine; even the average home user who's curious to try something new without replacing what they already have.

Knoppix Hacks is easy to read cover to cover, but a major asset is that you don't need to. You can jump straight to the Hack that you need and dig in. There is plenty of cross-referencing to related material throughout the book so you're never left feeling that you don't have all the facts.

The Story

My wife and I were visiting her family a few weeks ago. One of their computers had become almost unusably slow and they asked me to take a look at it. My suspicions were confirmed as soon as the monitor warmed up. The system tray was filled with a half-dozen icons that appeared to have been painted by an angry preschooler. The computer was in a sad state of disrepair. At some point in time the anti-virus had stopped auto-updating. Windows Update had never been run. The coup de grace was the dozens of malware running on the system, making its performance comparable with that of molasses in the wintertime.

Going through the task of killing all unknown processes and downloading AdAware took forever. I could barely get task manager to run, much less do anything. There has got to be a better way, I thought to myself. It turns out, there was but I didn't know it at the time.

I had used the Knoppix before, but not in any serious capacity. I considered it to be a handy little tool for something, but I didn't know for what. Now I'm kicking myself.

Let's pretend that I had a copy of Knoppix and armed with a copy of Knoppix Hacks when dealing with the family computer.

After booting up under Knoppix, mounted the hard drive as read/write (NTFS writing is supported) and edit the registry and file system to prevent malware from starting at boot. While I'm at it, I also perform a complete virus scan and download AdAware and all of the latest security patches. Unplug the network cable, reboot into Windows, install patches, run AdAware and reboot. The only thing left is to train my mother-in-law to run adaware on occasion and warn her of the evils of malware.

We've seen that Knoppix can save a system on the brink of a meltdown due to malware. You can also use it in lieu of a Windows Recovery CD to restore system files or to resize a partition. There is an entire chapter dedicated to these kind of hacks.

So, what else can Knoppix do besides earning you brownie points with your mother-in-law?

Under the Cover

Knoppix Hacks is broken down into nine chapters that discuss a wide range of topics.

Booting Knoppix and using it as a desktop or turning it into a kiosk will be easy work with the help of the first three chapters of the book. The first three chapters cover booting Knoppix and using it as a desktop.

The core four chapters break down how to use Knoppix as a disaster and system recovery tool. This is the creme de la creme of Knoppix Hacks. Here we get into what I think are the most important and useful functions of Knoppix. Sure, there are plenty of uses for Knoppix but the vast number of tools available for recovering a busted system make it a winner. Chapters five through seven cover forty-three different recipes. Creating emergency servers to temporarily replace an unavailable machine, network auditing, and collecting forensic evidence CSI-style from compromised machines are just the start. Neither Linux nor Windows is safe from the power of Knoppix. Need to repair that damaged XFS file system? Knoppix can do that. Need to edit your Windows registry or reset your password? It can do that, too.

The final two chapters look at some of the various customized versions of Knoppix available as well as creating your own blend of Knoppix. There are already some task-specific Knoppix-based LiveCDs out there -- KnoppMyth uses MythTV, the open source TiVo replacement, to kickstart your home theater PC or create a cluster to distribute software compiles with clusterknoppix. If you can't find an alternative Knoppix to fit your need, the final chapter will teach you everything you need to know to create your very own customized version.

Returning to my earlier tale of woe -- turning to Hack #78 - Scan for Viruses - we start out with a description of the problem, in this case a virus-ridden machine. Next Kyle steps us through a list of advantages that Knoppix has as a virus scanner, such as using read-only media with a completely independent operating system. When you boot Knoppix, Windows is left dormant on the hard drive - as are all viruses and malware infecting it. This makes it easier to eliminate them, since they can't infect the Knoppix OS, CD or hide away in memory. Lastly, he walks you through using the Knoppix Live Installer to install the most current virus scanning tools to the RAM disk and then steps you through the process of scanning, identifying and removing any virus-infected files.

Interview with the Author

I was actually the one who was approached initially about doing a "Hacks" book about Knoppix. The idea of a book full of Knoppix Hacks really appealed to me, because I had been doing system recovery with Knoppix for quite some time (and with other recovery disks before that). There were a lot of common recovery scenarios and other sysadmin scenarios (like disk imaging) that I thought would be really cool all listed in a single book. In some ways I was inspired by the Linux Server Hacks book, which lists a lot of great tips for day-to-day sysadmin work. I suppose my goal was to make Knoppix Hacks the first book you reach for when something has gone horribly wrong on a server. Of course, while I used Knoppix primarily for recovery, many people have used it for entirely different reasons, whether to demo Linux, as a full Linux distribution that follows them around, to easily install a Linux to their hard drive, or as a launching point for their own live CD. It made sense for the book reflect this with chapters devoted to each of the different types of use.

That's a tough one. I'm going to cheat and name a few that I really like for different reasons. My favorite all-around hack is probably Hack #55 which goes over how to restore an erased partition table using the gpart tool. I like that one the best because I actually accidentally erased my complete partition table on my heavily-customized laptop and thought I had lost everything, and Knoppix came to the rescue and was able to restore it. Probably the hack that surprised me the most when I discovered it was Hack #76 which discusses how to boot Knoppix on top of a Windows machine and actually edit the Windows registry--something I had no clue was possible before. In fact, the "Rescue Windows" chapter is probably my favorite chapter because a lot of those hacks completely surprised me when I first discovered them.

I end up using Knoppix really almost every time there's some sort of computer emergency. Luckily for me this doesn't turn out to be every day. It's funny actually. When a tool consistently saves the day the way Knoppix does, you start to take it for granted. I use Knoppix many times when I'm messing around with my boot loader because I end up being lazy or sloppy since I know that Knoppix can restore the boot code and even the partition table if I mess up. At work I've recently started using it to deal with spyware since it requires much less wrestling to remove the spyware's files when Windows is shut down.

I was actually rather amazed at how cooperative and giving the Knoppix community was. A majority of the hacks that discuss Knoppix-based distributions are actually written by the creators of that distribution. In particular Fabian Franz (Knoppix developer and creator of FreeNX) and Alex de Landgraaf (creator of Morphix) were very helpful not just with their written contributions to the book but with technical critique.

Really, while I was writing the book was one of the few times I didn't make any big mistakes! I was actually pretty careful when I was testing the hacks and set up special test installs on different hard drives that I could afford to lose, just in case. I wouldn't call it a mistake, but the biggest setback I had when writing the book I think was when I was writing some of the remastering hacks and the remastering portion of the kiosk hack. I wanted everything to be perfect. Remastering itself isn't that complicated once you know the steps, but it is time consuming (it takes about an hour or so to run through the complete remastering process) so I found myself sitting and waiting to try out the new ISO I created only to discover some little mistake I made, and so I would have to start back from the beginning.

Conclusion

I frequently have to trade my developer hat for that of a systems administrator, so the hacks to create an emergency router and web server catch my interest. Its ability to repair and restore from damaged file systems is impressive, and the section on creating a custom Knoppix image really has really piqued my interest.

The book shows one hundred ways of using Knoppix to get things done, and does so in a way that's easy to follow. Knoppix Hacks has something for Linux and Windows alike, and even comes with a LiveCD to get you started. I've found the book to be one of the most informative I've read in recent memory. It has proven to be an invaluable part of my bookshelf.

Developer's Corner

I read an interesting discussion on ZDNet about the commercialization of open source projects, in this case JasperReports. This isn't the first time an open source project has been "acquired". What impact may this sort of action have on a project? On one hand, if the aquiring company pledges to keep the product open source as well provide commercial support to those who need it. If the company's intentions are not altruistic, however, there is nothing to stop them from turning the product closed source and shutting out the community from any further free updates. This leaves the community and any remaining unencumbered developers responsible to fork the last free version of the code. Project forking can be successful, as in the case of Xorg forking the XFree86 codebase but it requires a tremendous amount of community support and even financial backing, depending on the scope of the project.

In related news, it's sad to see the hard feelings that can result from the abuse of open source for commercial gain. When Apple first announced that they were adopting the KHTML rendering engine, there was much buzz about the potential for improvements that would flow back to the community. The trickle of information that began just as quickly dried up.

Do you have any idea how hard it is to be merging between two totally different trees when one of them doesnít have any history? Thatís the situation KDE is in. We created the khtml-cvs list for Apple, they got CVS accounts for KDE CVS. What did we get? We get periodical code bombs in the form of them releasing WebCore. Many of us wanted to even sign NDAís with Apple to at least get access to the history of their internal vcs and be able to be merging the changes incrementally, the way they can right now. Nothing came out of it. They do the very, very minimum required by LGPL.

The frustration is quite understandable. What Apple is doing is not strictly violating the letter of the LGPL but is arguably violating the spirit of it. Apple benefits from building upon an already existing codebase; Apple's users benefit by way of Safari using a mature rendering engine; KHTML doesn't benefit from improvements in the codebase. KHTML will have to suffer the comparisons to Safari with no manageable way short of reimplementing Safari's improvements from scratch.

In a perfect world information would flow freely in both directions. This comment about Safari and KHTML describes some of the difficulties that Apple engineers have in issuing patches upstream to the KHTML developers. Differences in version control systems and major forking and integration with proprietary code can make this difficult. Apple's work on Darwin and the recently released Launchd show that they are serious about open source development. So, is Apple making a good faith effort? Probably. Is it fair that the KHTML developers feel frustrated? Sure.

Is this a fundamental flaw of the LGPL? Under the terms of the license, Apple is obligated to release the code to their customers but nothing states that they need to release version history or anything else that would ease the integration of their code back into the KHTML codebase. This makes one wonder if commercial developers would be less likely to embrace open source if they were required to provide the information the community requires to adopt their modifications? As unlikely as it is, what's to prevent someone to obfuscating their code before releasing it back to the community, thereby fulfilling the letter of the law?

Tools, Tips, and Tweaks

ifrename

I've always been annoyed with the inconsistency of interface names, particularly when dealing with removable network cards. Typically, the driver for the particular card chooses the next available name. This usually means eth0, eth1, wlan0, wlan1, ath0, ath1, and so on. This works fine in most cases but what if you want a more granular control over your interface naming?

Introducing ifrename, part of the Linux wireless extensions that are commonly installed with most distributions. Ifrename allows you to consistently name your network interfaces and iftab allows you to persist the name after a reboot.

/etc/iftab

# This file assigns persistent names to network interfaces.  See iftab(5).
eth0 mac XX:XX:XX:XX:XX:XX
# internal wireless card
wlan0 mac XX:XX:XX:XX:XX:XX

In most cases the default interface name will work, but if for whatever reason you want to make sure that your interface name is always consistent, then ifrename might be right for you.

Cool App of the Week

Alexandria

I was toying with the idea of written an application to manage my rather large collection of books so I decided to search gnomefiles to see if there were any existing solutions that would do the job. I found Alexandria, a GNOME application for managing books.


Image:Alexandria-screenshot.png

From what I can tell, Alexandria is in a class of its own. It's easy to use and integrates with providers such Amazon and Barnes & Noble to find books and cover art. If you have an old Cuecat you can use it to scan the ISBN of your books and speed up the process of loading your library. You can even export your library to XHTML and theme it with CSS to create an online version of your library. If you like to loan books out to friends you can also track who you lent it to and when it was borrowed.

The best part about Alexandria is that it's simple to use and the interface is clean. If you've ever thought of organizing your books then Alexandria is worth a few minutes to check out.

/dev/random