Knoppix Hacks (2nd Edition). O'reilly

by Kyle Rankin

Tips and Tools For Using the Linux Live CD to Hacks, Repair and Enjoy Your PC

Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo

e-book shop
Knoppix Hacks Second Edition

About the Author
Kyle Rankin is a system administrator who enjoys troubleshooting, problem
solving, and system recovery. He is also the author of Knoppix Pocket Reference,
Linux Multimedia Hacks, and Ubuntu Hacks for O’Reilly Media. He
has been using Linux in many different forms since 1998, and has used live
CDs to demo Linux and troubleshoot machines—from DemoLinux to the
LinuxCare bootable toolbox to Knoppix. He watched too much MacGyver
during his developmental years, and carries a Swiss Army knife and a Knoppix
CD with him at all times. Kyle is currently the president of the North
Bay Linux Users’ Group in California (

First of all, I want to thank my wife, Joy, the real writer in the family, for
supporting me through this process. It’s not easy to take so much time away
from someone you love for a project like this. Thanks for understanding and
helping me manage my priorities, particularly now that this book is at a second edition.

Thanks also to Fabian, who has helped answer questions from the very
beginning and who has been a major contributor to the book, both in content
and in critique. And thanks to all the other contributing writers who
have helped tell their particular part of the Knoppix story. In true community
spirit, thanks to Eaden McKee and the rest of the forum
for their excellent documentation, in particular the remastering instructions.
Extra thanks to Greg for making the original version of this book possible
and to Brian and Tom for all of their work in editing the book. Also thanks
to Wayne and Juan for assisting with the technical review. Thanks to all my
friends for your continued encouragement, especially Jorge, whom I thought
of whenever I wrote a system-recovery hack.

And of course, who can forget Klaus Knopper, the guy who started it all?
Thanks for Knoppix; it has certainly saved me more than once. It’s a true
testament to your ingenuity that Knoppix is so flexible and just plain useful
that it has been used by so many other projects.

As with so many great open source projects, Knoppix started because Klaus
Knopper had an itch to scratch. Klaus wanted to take many of his favorite
open source tools with him so he could work wherever he went and on any
computer he had access to. Because he didn’t want the expense of a laptop
or the worry of losing or damaging it, he created a bootable Linux CD distribution
called Knoppix. With Knoppix, Klaus was able to go from computer
to computer and get right to work with an operating system and environment
he was familiar with, and without the need to install software on every
computer he came into contact with. Many people only view Knoppix as a
Linux demo disk, a job it does perform quite well, but even from the beginning,
Knoppix was to be used to get real work done.

Klaus wanted to be able to work on any computer, regardless of the hardware
in the system, so he continued to improve the hardware support for
Knoppix until it was able to recognize and automatically configure much of
the hardware it came in contact with. There are a lot of live Linux CDs, but
Knoppix’s excellent hardware support, combined with the general flexibility
of the included software, has made Knoppix the most popular.

Over the years, I have used many different live CDs both as demonstration
disks and for system recovery. I have never been a Boy Scout, but I have
always liked the idea of being prepared for anything, and at any moment, I
might have been carrying a DemoLinux CD or a LinuxCare Bootable Business
Card with me, along with a number of other tools, including a Swiss
Army knife. I’ve found that it’s handy to have both a screwdriver and a knife
in my pocket while crawling under a desk to fix a machine or running
cabling through the ceiling, and the Swiss Army knife gives me those tools in
a compact form. My use of the Swiss Army knife probably has a lot to do
with all the MacGyver watching I did as a kid. I marveled at how he seemed
to get out of just about any jam with a few simple tools that fit in his pocket.

Knoppix has quickly become my preferred software Swiss Army knife. I no
longer have to carry around a lot of different CDs and floppies, because a
single Knoppix CD provides everything I need. What’s better, I can easily
(and legally) make copies of it for my friends, or customize it to have the
special tools only I need because it is an open source CD.

Since the first release of this book, Knoppix has continued to evolve and add
all sorts of powerful features such as UnionFS (now Aufs), which makes the
possibilities of what you can do with Knoppix almost endless. In addition to
the standard CD, Knoppix now has a DVD version with an almost overwhelming
amount of software. Because of advances such as these, a number
of new hacks were added to the book, quite a few were completely rewritten,
and all have been updated. A lot of live CDs are available these days,
mostly for very specific purposes, but I still believe that Knoppix is the best
overall live disk out there.

This book shows you how to use Knoppix to its full potential with steps to
use it as your desktop distribution, your rescue CD, and a launching point
for your own live CD. You will find ways to use Knoppix that you may have
never considered, and you may even think of ways to use Knoppix beyond
what this book covers. I started this book as a Knoppix fan, but once I starting
writing down the sheer number of things it can do, I quickly became a
Knoppix zealot. I hope you find this book and Knoppix itself as useful and
indispensable as I have.

Why Knoppix Hacks?
The term hacking has a bad reputation in the press. They use it to refer to
someone who breaks into systems or wreaks havoc with computers as their
weapon. Among people who write code, though, the term hack refers to a
“quick-and-dirty” solution to a problem, or a clever way to get something
done. And the term hacker is taken very much as a compliment, referring to
someone as being creative, having the technical chops to get things done.
The Hacks series is an attempt to reclaim the word, document the good
ways people are hacking, and pass the hacker ethic of creative participation
on to the uninitiated. Seeing how others approach systems and problems is
often the quickest way to learn about a new technology.

Knoppix Hacks provides the hacker with an excellent multi-purpose tool for
all of their hacking needs. The sheer flexibility of Knoppix means the clever
hacker can get all of her work done with a single CD. Rescue CDs often
bring out the hacker in people since you must often find clever ways to get a
system functional again or recover lost data. Knoppix gives you all the repair
tools you need as you go from plan A to plan Z, and Knoppix Hacks shows
you how to use those tools in ways you may never have considered.

How to Use This Book
You can read this book from cover to cover if you like, but each hack stands
on its own, so feel free to browse and jump to the different sections that
interest you most. If there’s a prerequisite you need to know about, a crossreference
will guide you to the right hack.

It’s important to note that although Knoppix can be installed directly to a
hard disk (and indeed there is an entire chapter devoted to that in this
book), the hacks in this book assume you are running Knoppix directly from
CD, unless otherwise noted. The first chapter is an introduction to Knoppix
itself and the Knoppix live-CD boot process. Refer to this chapter if you
have any problems getting the CD to boot on your particular hardware or if
certain hardware doesn’t function. If you are new to Linux itself, the next
two chapters provide you with a guide to the Knoppix desktop and a primer
for the major desktop software Knoppix includes. If you find you really like
the Knoppix desktop and want to use it on a system permanently, go to
Chapter 4 for steps to install Knoppix directly to your computer.
The middle chapters cover more advanced uses for Knoppix, particularly for
system administration and recovery. Use these chapters as a quick reference
when you need to repair a system or just as a simple way to do much of your
daily work with a single CD.

Use the final chapters in the book if you are interested in creating your own
Knoppix-based CD. There’s a chance the features you need have already
been included in another live CD based on Knoppix, so check out the other
Knoppix-based distributions in Chapter 8 before you start through the
remastering process. You can use the final chapter in the book as a step-bystep
reference for the remastering of your own Knoppix CD with the software
and features you want.

How This Book Is Organized
Knoppix is incredibly flexible and can be used for many tasks, but these
tasks generally fall into a few different categories: desktop use, system
administration, system recovery, and live-CD remastering. The first few
chapters act as an introduction to Knoppix and help you boot Knoppix on
your hardware and then use it as your Linux desktop. The middle chapters
feature Knoppix as a system administrator multitool with tips on how to do
many common system recovery tasks both on Linux and Windows. The
final chapters focus on Knoppix as a platform to create other live CDs with
an introduction to many popular Knoppix-based distributions and steps to
create your own.
Chapter 1, Boot Knoppix
Before you can use Knoppix, you must get it booted on your system.
This chapter guides you through the process of getting the latest version
of Knoppix and booting it on your hardware. The main focus of the
chapter is the use of special boot time parameters, called cheat codes, to
tweak the settings Knoppix uses as it boots.
Chapter 2, Use Your Knoppix Desktop
Knoppix boots directly into a full KDE desktop environment. This chapter
covers all of the features of the Knoppix desktop and introduces the
major desktop and Internet applications Knoppix includes, as well as
how to connect to the Internet. Use this chapter to get up to speed on
the Knoppix desktop.
Chapter 3, Tweak Your Desktop
This chapter covers how to tweak settings on the Knoppix desktop,
including installing software directly to ramdisk. This chapter also covers
the use of persistent storage, which saves all of your settings and
data between reboots, so your data and configuration can be as portable
as Knoppix itself.
Chapter 4, Install Linux with Knoppix
Knoppix makes it easy to install Linux on your own machine. This
chapter walks you through the Knoppix installation process with a few
common installation scenarios, including how to turn an install into a
regular Debian system.
Chapter 5, Put Knoppix in Your Toolbox
Knoppix isn’t just for desktop use. This chapter discusses how to use
Knoppix as your system administration multitool with tips on how to
replace a failed server with Knoppix in an emergency, clone systems,
and perform security audits.
Chapter 6, Repair Linux
When your Linux system breaks and you need a rescue disc, look no
further than Knoppix. This chapter helps you repair a system that won’t
boot, with tips on restoring the boot loader, repair filesystems, and
recover from failing hard drives.
Chapter 7, Rescue Windows
The Windows Recovery CD isn’t all it’s cracked up to be, and when
your Windows system breaks, you can use Knoppix to rescue it. This
Preface | xxiii
chapter helps you back up files and settings, reset passwords, hack the
registry, and even scan for viruses.
Chapter 8, Knoppix Reloaded
There are a number of other live CDs that have been based on Knoppix.
Each derivative has its own special focus, and this chapter covers
some of the most popular Knoppix-based distributions and why you
might want to try them in addition to Knoppix. Before you remaster
your own CD, check out these distributions.
Chapter 9, Knoppix Remastered
Knoppix is very flexible, but if you have a special need or your favorite
software is missing from it, you can easily remaster Knoppix to include
the special features, or custom branding, you desire. This chapter walks
you step by step through the remastering process and features special
tricks and tweaks to make the most out of your personalized distribution.

Apart from its applicability for everyday work, GNU/Linux is a great way to
learn about operating systems. The Free Software license allows you to take
the software apart, see inside, and understand how it works. You can also
change the software to fit your needs. It can make you feel like a child happily
taking a colorful and complex toy apart into thousands of little gears and
switches, just to see how it functions, disregarding the fact that it may be very
difficult to ever reassemble that toy again. The difference with GNU/Linux,
of course, is that you can work on a copy of the software source code and
won’t break the original. And sometimes, while reassembling, you can build
something entirely different and colorful without even planning to.

The Past
When, in 1999, bootable business card–sized Linux “Rescue CDs” appeared
as giveaways at computer expos, I was extremely curious about how they
worked. And since they were free software, I was able to look inside and try
to figure out how the software worked. After I successfully made a bootable
CD, I decided to make a “personal rescue CD.” That way, it would be possible
to use the software that I needed from a CD, rather than carry around an
expensive and fragile laptop. Computers are available everywhere anyway,
so why not just have the software in your pocket instead? The idea was to
put in the CD and start working right away, without having to worry about
installation or configuration of any kind.

But hardware is evil. (Everyone knows this, even if he’s not a computer
expert.) Vendors seem to create their own standards on demand, which are
not standardized at all, and don’t even provide technical specifications.
Compatibility in hardware depends more on luck or chance than on
approved norms, so I had to decide among choosing a system that was so
cheap in its hardware requirements that it would work on virtually every PC
(which would probably mean that graphics worked only in VESA mode, at
best), installing a manual hardware selector in order to load the necessary
drivers, or scripting some kind of automatic configuration. For some reason,
the last option seemed the most flexible and optimized solution, so I started
writing scripts that would automatically install a Linux distribution on hardware
components: identify hardware components, load the matching drivers,
and create configuration files that are optimized for the hardware, yet
tolerant enough to work around small glitches in the hardware specification.
This is still an ongoing process, because hardware manufacturers nowadays
seem to be in a semipermanent fight against common standardization of
hardware specification. But to my own amazement, my solution still seems
to work quite well on a great number of machines, despite the sheer unlimited
number of hardware configurations and intricacies.

In 2000, my friends from the LinuxTag association talked me into publishing
Knoppix as a publicly available and joinable project. They also provided hosting
space. The idea was to get more feedback (and possibly workarounds or
code contributions) applicable to different computers and exotic hardware
components that I had no access to. As new versions with added features were
released, the number of downloads and, naturally, feedback (as well as questions
to answer) grew tremendously. (Had I known that so many people
would find this very experimental project useful, and that there is now even an
O’Reilly book being published about it, I would have probably given it a more
elaborate name than “Knoppix.” But now it’s too late, of course.)

The Present
Today, with thousands of Knoppix downloads per day and with about a
dozen derivatives, each with a special focus group, language, or supported
architecture, it seems that my experiment has gotten a little out of hand. I’m
trying my best to keep up with the technical development, and I provide regular
updates of the download edition and add new features and gimmicks.

And occasionally, there are “Special Editions” like the LinuxTag Conference
DVD, which contains a maxi edition of Knoppix with a lot more software
than the CD version.

By saying this, I’m probably fitting the cliché that says programmers are naturally
lazy in writing documentation, but, lucky for me, it seems that others
are now writing manuals and documentation for Knoppix, which means I
can stay focused on development. It’s really useful to have a book at hand
that not only contains technical information about the structure of a system,
but also explains some of its components in detail, and I have learned a
lot from this book about Knoppix. (In particular, I’ve learned that some
things are not really as complicated as I thought they were.) Had I read this
book earlier, I probably would have created Knoppix differently!

There are so many things you can do with Knoppix. The primary design is to
use Knoppix as a desktop system platform for tasks, such as office work (using, for example) and Internet connectivity; power users and system
administrators may use it for rescue operations (grabbing data from a
defective or nonbooting filesystem on a different OS), or ad-hoc installations
of web, file, or print servers, with or without hard-disk installation. With the
terminal server utility (which is just a shell script that creates configuration
files for DHCP, NFS, and squid, and starts all of them), you can boot an entire
classroom of PCs over a local network, using just a single CD-ROM, which
comes in handy if you want to run an Internet cafe, for example. It’s also a
good tool for learning about operating systems or for functioning as a base if
you want to customize your own bootable GNU/Linux CD.

The Future
Knoppix, the downloadable edition from LinuxTag, will continue being a
public experiment with a snapshot of the current, most representative desktop
programs, rescue tools, and some popular servers installed. The challenge
of keeping hardware support up-to-date is always difficult. Some of the
newer hardware components, especially hotpluggable devices, require that
binary firmware files be uploaded to the device during activation. Unfortunately,
the licenses of the firmware don’t allow free redistribution in every
case, so some hardware will never be supported in the download edition,
even if drivers are available for private use. One attempt to circumvent this
nontechnical problem with proprietary licenses is the “live installer” that was
added by Fabian Franz for Knoppix Version 3.4. Maybe a “Knoppix customizing
toolkit” would allow you to individually create such personal editions
with a collection of software and drives. But currently, it seems to be virtually
impossible to automate every single step of the customization process,
though Morphix has made some interesting progress in this direction.

The Book
This book takes Knoppix’s boot process apart, explains how to do hardware
autoconfiguration, describes some of the excellent GNU/Linux tools
for recovery of data or system repair, and assists you in finding out more
about operating systems in general. Perhaps some part of this book will
encourage you to create your own live CD with your own toolkit collection
installed. You can do this by using the included Knoppix CD as a base or by
downloading a fresh version from the Internet. This book shows you how.
Happy hacking!
—Klaus Knopper


e-book shop

Purchase Now !
Just with Paypal

Product details
 File Size
 3,395 KB
 418 p
 File Type
 PDF format
 2008 O’Reilly Media, Inc 

Table of Contents
Foreword . . .. . . xi
Credits . . .  . . xv
Preface . . . xix
Chapter 1. Boot Knoppix . . . . 1
1. Boot Knoppix on a Desktop 2
2. Boot Virtualized Knoppix 5
3. Get Knoppix 6
4. Use Knoppix Cheat Codes 9
5. Speak Different Languages 11
6. Free Your CD to Make Knoppix Run Faster 13
7. Straighten Out Your X Settings 16
8. Use Advanced Knoppix Cheat Codes 19
9. Run Knoppix on a Laptop 21
10. Explore Expert Mode 22
11. Check RAM for Errors with Memtest86+ 23
Chapter 2. Use Your Knoppix Desktop .  . . 27
12. Explore the Desktop 28
13. Customize the Desktop Look 34
14. Get Office Work Done 39
15. Configure Your Printer 44
16. Use Peripheral Devices 46
17. Have Fun and Play Some Games 49
18. Rock Out with Knoppix Multimedia 50
19. Connect to the Internet 55
20. Connect to the Internet with GPRS Bluetooth 57
21. Explore the Internet 62
22. Get Help 65
23. Try Other Desktop Environments 66
24. Become Root 70
Chapter 3. Tweak Your Desktop . . . . 72
25. Use Aufs 72
26. Create Persistent Knoppix Settings 75
27. Use Your Linux Desktop Settings 79
28. Use Your Windows Desktop Settings 83
29. Make a Kiosk 86
30. Make a Party Arcade 90
31. Network Boot Knoppix 94
32. Create a Knoppix “Thin Client” 96
33. Develop Applications 97
34. Install Nvidia 3D Drivers 100
35. Point-and-Klik to Install Applications 104
36. Create Your Own Klik Recipe 106
37. Install Programs to the Live Disk 107
38. Browse the Web Anonymously 109
39. Install Multimedia Codecs 111
Chapter 4. Install Linux with Knoppix . . . 112
40. Explore the Knoppix Installer 113
41. Install Knoppix as a Single-Boot System 118
42. Install Knoppix on a Multiboot System 120
43. Convert Knoppix to Debian Unstable 122
44. Install Gentoo with Knoppix 124
45. Update a Knoppix Install from the CD 126
Chapter 5. Put Knoppix in Your Toolbox . . . 128
46. Run Remote Desktops 129
47. Run X Remotely with FreeNX 133
48. Browse Windows Shares 138
49. Create an Emergency Router 139
50. Create an Emergency File Server 146
51. Create an Emergency Web Server 148
52. Make an Emergency Mail Relay 150
53. Run Other Emergency Services 154
54. Wardrive with Knoppix 158
55. Audit Network Security 166
56. Check for Root Kits 174
57. Collect Forensics Data 176
58. Clone Hard Drives 180
59. Wipe a Hard Drive 184
60. Test Hardware Compatibility 186
61. Copy Settings to Other Distributions 192
62. Add Knoppix to Your PXE Boot Environment 194
63. Set Up a Webcam Server in a Snap 197
64. Create a Weekend Wiki 198
Chapter 6. Repair Linux . .  . 201
65. Repair Lilo 202
66. Repair Grub 203
67. Kill and Resurrect the Master Boot Record 205
68. Find Lost Partitions 207
69. Resize Linux Partitions 209
70. Repair Damaged Filesystems 211
71. Recover Deleted Files 214
72. Rescue Files from Damaged Hard Drives 217
73. Back Up and Restore 221
74. Migrate to a New Hard Drive 223
75. Mount Linux Software RAID 225
76. Create Linux Software RAID 227
77. Migrate to Software RAID 230
78. Migrate Software RAID 1 to RAID 5 233
79. Add an Extra Drive to a Software RAID 5 Array 235
80. Mount LVM Partitions 237
81. Reset Linux Passwords 239
82. Fix Broken Init Services 240
83. Repair Debian Packages 243
84. Repair RPM Packages 245
85. Copy a Working Kernel 246
86. Turn a Physical Machine into a VMware Virtual Machine 247
Chapter 7. Rescue Windows .. . 253
87. Fix the Windows Boot Selector 254
88. Back Up Files and Settings 256
89. Resize Windows Partitions 258
90. Reset Lost NT Passwords 261
91. Edit the Windows Registry 264
92. Restore Corrupted System Files 267
93. Scan for Viruses 269
94. Download Windows Patches Securely 272
95. Knoppix on Intel Macs 273
Chapter 8. Knoppix Reloaded . .. . . 276
96. Master Morphix 277
97. Educate Yourself with Freeduc 279
98. Damn Small Linux 281
99. INSERT Security Here 284
100. Download Local Area Security 287
101. Full Protection with S-T-D 290
102. Distribute Compiles with distccKNOPPIX 314
103. Distribute the Load with ClusterKnoppix 315
104. Analyze Quantian 322
105. Find GIS Knoppix on the Map 325
106. TiVo Your Computer 326
107. Compose Musix 329
108. Contribute to Knoppix 331
Chapter 9. Knoppix Remastered . . . 333
109. Create a Customized Knoppix 334
110. Trim the Fat 341
111. Personalize Knoppix 344
112. Keep Your Custom Disk Up to Date 349
113. Automate Knoppix Remastering 351
114. Morph Morphix 353
115. Auto-Build Morphix Modules MapLab Tutorial Map 356
116. Change the Default Language on an ISO Image 358
117. Remaster Knoppix Without Remastering 360
118. Change Boot Defaults Without Remastering 363
119. Tweak the initrd Without Remastering 366
120. Put Knoppix on a USB Drive 367

Index . . . . . 369

═════ ═════

Loading... Protection Status