Starting with Knoppix 3.8.1, UnionFS—a stackable unification filesystem—was added to the distro. This was an enormous change because at one blush, several longstanding problems installing software on top of a CD-based distro were solved, and many new possibilities became available to Knoppix users. To maximize your use of Knoppix, you need to understand what UnionFS does and how you can use it. This is extremely important, and the authors of Hacking Knoppix assume throughout this book that you have read this section.
The knoppix-mkimage script is amazingly useful. It enables you to save virtually any change you make to Knoppix while you're running it. Think about that for a second. Previously, you couldn't really install new programs on top of Knoppix because the /usr directory was read-only (yes, there were a few hackish ways around that, which you'll see in Chapter 10). You could save changes made to your home directory, but that was about it. Now, thanks to a fantastic new technology called UnionFS, you can basically make any change you want to your running copy of Knoppix, save those changes to a structure that in essence layers on top of the read-only Knoppix, reboot Knoppix, and have all those changes you made automatically restored and available for your use.
With a Knoppix CD and a USB flash drive, you can sit in front of almost any computer and, in a few minutes, find yourself using Knoppix with your settings, configurations, programs, and customizations. That is, if you don't realize it yet, wicked cool!
Note | For details about UnionFS and how it works, see "A Stackable Unification File System" at http://www.fsl.cs.sunysb.edu/project-unionfs.html, Linux Journal's "Kernel Korner—Unionfs: Bringing File-systems Together" at http://linuxjournal.com/article/7714, and "LinuxHints/KnoppixUnionFS" at http://www.hants.lug.org.uk/cgi-bin/wiki.pl?LinuxHints/KnoppixUnionFS. |
To use UnionFS with Knoppix, first run the knoppix-mkimage script by selecting the Knoppix menu → Configure → Create a Persistent KNOPIX Disk Image. An introduction screen (see Figure 1) is displayed with all the details.
Figure I-1: The knoppix-mkimage introduction screen
Note | Don't worry about the title bar of the window, which refers to an older script that created a Knoppix home directory instead of an entire disk image. The Knoppix developers will clean up that bit of legacy code sometime soon. |
Familiarize yourself with this overview, and then click Yes. Next, select the writable media you want to use to store your files, as shown in Figure 2.
Figure I-2: Where do you want to store your persistent image?
Knoppix automatically detects hard drives, USB flash drives, Zip drives, and other writable media that it can use. A USB flash drive would give you maximum portability. Feel free, though, to use your hard drive if you plan to reboot Knoppix a lot on the machine you're using. If you're going to use your hard drive, don't worry about wiping out everything—you'll be asked in just a moment to select how big you want your disk image to be, so you could even select a partition containing Windows if you wanted.
Next, indicate whether you want to encrypt the disk image you're going to create (see Figure 3).
Figure I-3: For maximum security, encrypt your persistent image.
If you're really paranoid, then by all means, choose Yes; just be aware that you're going to have to enter a 20-character password every time you boot. If you're talking the security of important documents, however, this is hardly a burden. If you don't need to worry about securing your disk image, click No.
Then you have a big decision to make: how big should your persistent disk image be (see Figure 4)?
Figure I-4: How big do you want your persistent image to be?
The size you choose here is totally dependent upon how you plan to use Knoppix. If you're going to be using Knoppix on the same desktop machine for quite a period of time, you may want to create a multi-gigabyte disk image. If you're going to store the image on a USB flash drive, you're probably thinking in terms of a few hundred megabytes or so. Just make sure that the device you choose has enough room on it. If you're just starting out with UnionFS and the knoppix-mkimage script, that means a minimum of 100MB, which nowadays is chicken feed.
Caution | Make sure that you specify the size of the persistent disk image in MB! A 2GB image, therefore, would be entered as 2000 (or 2048 if you want to be pedantic). |
Click OK, and knoppix-mkimage does its job. This can take a while, so be patient. If it appears that the script is hung, be patient a bit longer. It's working.
Finally knoppix-mkimage finishes, indicating success, as shown in Figure 5.
Figure I-5: Your persistent image has been created.
To use your new persistent disk image, you have to use a cheatcode (a special instruction for Knoppix) at boot time. Use knoppix home=scan to have Knoppix search for your persistent home directory at boot time. You can specify the location as well; for instance, if you stored the image on your hard drive, you would use knoppix home=/dev/hda1 to use the persistent disk image on the hda1 partition.
You can also use knoppix-mkimage to save files you add, configuration files you change, and even applications that you download and install using APT, which are discussed in Chapter 10. Thanks to your persistent disk image, the changes you make will be available upon reboot, and you won't have to re-download, re-install, and re-configure Knoppix every time you use the distro.
If you're feeling particularly clever, you can save more than one disk image (see Figure 6).
Figure I-6: I like to keep at least a couple of different disk images on my USB flash drive.
Figure 6 shows two images on my USB flash drive: knoppix.img, the current one, and knoppix.img.security, an alternative that's focused on security testing. Normally I use knoppix.img, but if I know I'm going to be doing intensive security work, I change the name of knoppix.img to knoppix.img.normal, and then alter the name of knoppix.img.security to knoppix.img. When I start Knoppix, I simply use knoppix home=scan as usual, but this time the image devoted to security is employed.
When it's time to go back to the normal disk image, I reverse the image renaming process, and I'm good to go. Best of all, you can have as many disk images as you need … or will fit onto your media!
As you read the rest of this book, in many places we assume that you're using a persistent disk image, so go ahead right now and get that set up. You'll be glad you did, and it will make your experience with Hacking Knoppix more efficient and fun.