Creating a New Distro


It's almost time to craft a new distro based on Knoppix. There are a few things to do first to get your environment ready for the big changes in store, and then you need to get rid of as much unnecessary software as possible. Only then will you install new software for the kids, and wrap up by making some other changes designed to make your new distro kid friendly.

Preparing Your Environment

Tell your terminal that /home/scott/knoppixuncompressed (or whatever your directory is) is actually the root directory; otherwise, you won't be able to install and remove software correctly. To perform this magic, use the chroot command:

 # chroot /home/scott/knoppixuncompressed 

Your shell will change and will now think that /home/scott/knoppixuncompressed is actually /. In essence, the rest of your filesystem is hidden from this shell as long as you're inside it (if you type exit, you're back in a normal shell). Keep in mind that you're automatically running as root inside this chroot environment.

You also need to mount the proc filesystem inside your chroot jail, or things really won't work well:

 # mount -t proc /proc proc 
Note 

Ignore the error message warning you that the system can't open the /etc/fstab file. No biggie.

Before you can install software, make sure that your Net connection is working by pinging a Website. For example:

 # ping http://www.granneman.com 

If it didn't work, you need to tell your chroot jail where your DNS servers are, so open /etc/ resolv.conf with vim and then add the following line, pointing it to your router, the machine that handles DNS on your LAN:

 nameserver 192.168.0.1 
Note 

Don't remember how to use vim? Refer to Chapter 1.

Save the file and try pinging your server again. Success? Great! Time to remove some crud that kids don't need from the Knoppix disk!

Removing Software You Don't Need

Before adding or removing any software, tell APT to update the list of software available on repositories:

 # apt-get update 

You'll see a string of lines stream by as APT connects to the various repositories it knows about, thanks to the /etc/apt/sources.list file. When the process finishes, the great purge can begin.

First of all, how much space is currently used? To find out, use the du (disk usage) command:

 # du -c 

This command lists every directory and its size; and it can take a minute or two. When it's finished, take a look at the last line. Here's an example:

 2804649 total 

It says that out of the box, Knoppix is using 2.8GB of space. You need to jettison as much software as possible to make room for the packages you want to make available to the kids who will use your distro. Logically, it's a good idea to start with the stuff that's taking up the most space. To find out what packages are on Knoppix, sorted by size, with the largest at the end, run this command:

 # dpkg-query -W --showformat='${Installed-Size} ${Package}\n' image from book    | sort -n 

Try it out yourself, and look at the enormous list you've generated. Hmmm it looks like the kde-i18n packages are pretty big, and if all the kids to whom you'll be giving your distro speak English, you could remove all the i18n packages. (i18n stands for internationalization: there are 18 letters between the i and the n.)

First you'd need to know the names of the i18n packages, so rerun the previous command, but this time pipe it through grep to show only packages with i18n in the name:

 # dpkg-query -W --showformat='${Installed-Size} ${Package}\n' image from book    | sort -n | grep i18n 

You could see quite a list, like this:

 kde-i18n-tr k3b-i18n kde-i18n-ja kde-i18n-pl kde-i18n-ru kde-i18n-nl kde-i18n-es kde-i18n-it kde-i18n-fr kde-i18n-de 

Don't just remove these packages with APT; instead, purge them, which also removes any other files, such as configurations, from the machine. To do so, run this command:

 # apt-get remove --purge kde-i18n-tr k3b-i18n kde-i18n-ja kdeimage from book    -i18n-pl kde-i18n-ru kde-i18n-nl kde-i18n-es kde-i18n-it image from book    kde-i18n-fr kde-i18n-de 

APT tells you what it's doing and then asks you a question:

 Reading Package Lists... Done Building Dependency Tree... Done The following packages will be REMOVED:    k3b-i18n* kde-i18n-de* kde-i18n-es* kde-i18n-fr* kde-i18n-it* kde-i18n-ja* kde-i18n-nl* kde-i18n-pl* kde-i18n-ru* kde-i18n-tr* 0 upgraded, 0 newly installed, 10 to remove and 118 not upgraded. Need to get 0B of archives. After unpacking 196MB disk space will be freed. Do you want to continue? [Y/n] 

196MB removed? Do you want to continue? Why, yes! So type Y, press Enter, and watch as APT purges those packages from the machine.

What's next? Once again, run the following:

 # dpkg-query -W --showformat='${Installed-Size} ${Package}\n' image from book    | sort -n 

Here's an example of the result:

 14076 scribus 15524 kstars-data 15548 libc6 15616 xserver-xfree86 15928 cupsys 16204 kcontrol 18048 enigma-data 18076 ethereal-common 19200 gimp-data 22988 kdevelop3-plugins 24372 mozilla-firefox 24552 kdelibs4 25980 libgcj4-dev 27129 kdelibs-data 33043 mozilla-thunderbird 34666 emacs21-common 38268 libwine 47168 kernel-image-2.6.11 

Are kids really going to need emacs? Probably not. How many emacs packages are on Knoppix? Find out:

 # dpkg-query -W --showformat='${Installed-Size} ${Package}\n' image from book    | sort -n | grep emacs 

The results:

 84 emacsen-common 338 emacs21-bin-common 5904 emacs21 34666 emacs21-common 

No kid is going to use emacs (you might leave vim on your distro so that adults and really, really nerdy kids can edit config files). Purge emacs and related packages with this command:

 # apt-get remove --purge emacs21-common emacs21 emacs21-binimage from book    -common emacsen-common 

APT tells you what it's going to do:

 The following packages will be REMOVED:    a2ps* emacs21* emacs21-bin-common* emacs21-common* emacsen- common* gettext-el* 0 upgraded, 0 newly installed, 6 to remove and 118 not upgraded. Need to get 0B of archives. After unpacking 45.4MB disk space will be freed. 

45MB gone? Sounds great!

This process can continue for a while. Here are other programs you could drop:

 # apt-get remove --purge mozilla-thunderbird-offline mozillaimage from book    -thunderbird-locale-de mozilla-thunderbird 

Any kid who needs to access email can use a Web browser to do so. Removing Thunderbird (which is a great program, just not for this particular distro) reclaims 34.3MB of space.

How about security tools? Does any kid need Ethereal or Nessus? And programming tools such as MySQL and KDevelop? If your child needs software like this, leave it, but most kids won't need it and you can use the space:

 # apt-get remove --purge ethereal-common nessus-plugins image from book    mysql-server kdevelop3-data 

APT lets you know that removing these packages also removes several others, including Ethereal, kdevelop3, kdevelop3-plugins, kismet, nessusd, startnessus-knoppix, and tethereal — 78.7MB of stuff.

While performing these actions, you are asked whether you want to completely purge some of the other components used by MySQL and whether you want to remove the entire Nessus directory. You can say yes to both. Just pay attention to questions like those while you're removing software, and you can get rid of even more unnecessary items.

Time for another check with du to see how you're doing in getting rid of unneeded packages:

 # du -c 

For this example, du reports that you're now down to 2503065KB — around 2.5GB. You've purged 301584KB from your distro — about 300MB or so. But there's more!

German Firefox files? They can go:

 # apt-get remove --purge mozilla-firefox-locale-de mozilla image from book    -firefox-locale-de-de 

This gets rid of 864KB.

How about OpenOffice.org?

 # dpkg-query -W --showformat='${Installed-Size} ${Package}\n' image from book    | sort -n | grep openoffice 

This presents some interesting results:

 299508 openoffice-de-en 

Keeping OpenOffice.org isn't a bad idea because kids can easily learn to use it, and it's good for them to have a good office suite for schoolwork. This particular one, however, is a combined German and English edition, and that doesn't make sense. Nuke it:

 # apt-get remove --purge openoffice-de-en 

That actually frees 307MB; but now install OpenOffice.org in just the English edition:

 # apt-get install openoffice.org 

Running this command means that you also have to install extra packages: libdb4.2++, libmyspell3, libneon23, libstlport4.6, openoffice.org-bin, openoffice.org-debian-files, and openoffice.org-l10n-en. A bunch of other packages are suggested and recommended, but you can ignore those. You need to download 55MB, and once that is unpacked and installed, it will take up 181MB of disk space. So removing the German and English version of OpenOffice.org and installing the English version saves you 127MB, which is still good.

Note 

Many of you may be thinking right now, forget OpenOffice.org! It shouldn't be in this distro at all! Remember, this is only an example distro, and you are free to do whatever you'd like with your distro when you remaster Knoppix.

There's yet another way you can squeeze some space. Remember that you've installed several software packages, and the installers are still sitting on your hard drive. To verify this, check how much space those installers are taking up:

 # du -c /var/cache/apt/archives 

The results come in quickly:

 53812     ./var/cache/apt/archives 

53MB of software you don't want. Tell APT to delete it:

 # apt-get clean 

Beautiful. What else? Well, a lot of times distros include several development packages designed for programmers or those who compile software. The kids using your distro don't need those, but how many are there? Here's how to check:

 # dpkg-query -W --showformat='${Installed-Size} ${Package}\n' image from book    | sort -n | grep dev 

The result shows 88 packages, totaling 135MB! Holy space waste, Batman!

Note 

You need to be careful while getting rid of the -dev packages, and read APT's warning closely because things may change in Knoppix between the time when this was written and when you're reading it.

Unfortunately, you can't just remove these packages all at once, or a lot more packages that depend upon them will be removed as well, like most of KDE. Instead, you'll need to remove them a bit at a time, paying careful attention to make sure you don't throw the baby out with the bath water. Following is an example of the process:

 # apt-get remove --purge libxrender-dev libartsc0-dev image from book    libaspell-dev libbz2-dev pciutils-dev render-dev libwrap0 image from book    -dev libpopt-dev autotools-dev libesd0-dev libgpg-error image from book    -dev libxcursor-dev libfam-dev 

18.8MB gone.

 # apt-get remove --purge libqt3-mt-dev libxft-dev libmad0 image from book    -dev xlibs-dev comerr-dev libxmuu-dev pm-dev libusb-dev image from book    libtasn1-2-dev libxrandr-dev libcupsys2-dev libxtst-dev image from book    libsm-dev libxp-dev libpam0g-dev libxpm-dev libxtrap-dev image from book    kudzu-knoppix-dev libopencdk8-dev libxv-dev libpcre3-dev image from book    libart-2.0-dev libjpeg62-dev libice-dev libogg-dev image from book    libexpat1-dev liblcms1-dev libaudiofile-dev 

35.8MB outta here.

 # apt-get remove --purge libglib1.2-dev libxmu-dev libpng12 image from book    -dev libxi-dev x-dev libsasl2-dev libgcrypt11-dev image from book    libjack0.80.0-dev libtiff4-dev libxext-dev libmng-dev image from book    libidn11-dev libgnutls11-dev libarts1-dev xlibmesa-glu image from book    -dev libxaw7-dev libjasper-1.701-dev libasound2-dev 

7.5MB disappeared.

 # apt-get remove --purge libglib2.0-dev libxml2-dev dietlibc image from book    -dev manpages-dev libaudio-dev libfreetype6-dev qt3-dev image from book    -tools libncurses5-dev binutils-dev libssl-dev image from book    libncurses5-dev binutils-dev 

38.7MB bye-bye.

 # apt-get remove --purge libgcj4-dev uudeview zlib1g-dev 

27.6MB skidoo.

Amazing. What's left in this example are six dev packages that you can't remove without taking a lot of stuff you want to keep along with them, but that's acceptable. du -c reports that you've another deleted 112MB. Excellent!

That takes care of the dev stuff. Anything else? What about Apache? The kids you're targeting probably don't need a Web server:

 # apt-get remove --purge apache2-utils apache-utils libapache image from book    -mod-ssl apache apache-common libapache-mod-php4 

That sends 8MB to the bit bucket.

Here's another command that you can use:

 # deborphan 

The preceding command lists any libraries that aren't being used by any software packages on the system. Once you get the list, you can remove them:

 # apt-get remove --purge libcvsservice0 libnasl2 libzzip-0-12 image from book    libgmp3 libsvn0 libnspr4 libadns1 libkadm55 libtiffxx0 

Another 3.2MB toodle-oo!

Installing the Software You Want

So far in this example, the only packages you installed were ones to make sure that you didn't lose some functionality you wanted to keep (OpenOffice.org). Mostly you've been streamlining your distro as much as possible. Now it's time to install stuff that you want kids to use.

How about some cool tools for learning how to type, discovering math, and painting on the computer:

 # apt-get install tuxtype tuxmath tuxpaint 

Now what? Well, Debian Jr. offers several different packages that you can use. To see the list, search the APT database:

 # apt-cache search junior 

It's quite a list:

 junior-arcade - Debian Jr. arcade games junior-art - Debian Jr. Art junior-doc - Debian Jr. Documentation junior-games-card - Debian Jr. Card Games junior-games-gl - Debian Jr. 3D Games (hardware acceleration required) junior-games-net - Debian Jr. Network Games junior-games-sim - Debian Jr. Simulation Games junior-games-text - Debian Jr. Text Games junior-gnome - Debian Jr. for Gnome junior-internet - Debian Jr. Internet tools junior-kde - Debian Jr. for KDE junior-math - Debian Jr. educational math junior-programming - Debian Jr. programming junior-puzzle - Debian Jr. Puzzles junior-sound - Debian Jr. sound junior-system - Debian Jr. System tools junior-toys - Debian Jr. desktop toys junior-typing - Debian Jr. typing junior-writing - Debian Jr. writing 

Cool! Here's a quick-and-dirty way to install all of them at once:

 # apt-get install $(apt-cache search junior- | awk '{print $1}') 

Whoa, Nelly! That's going to install 183 packages that will require a 138MB download and then take up 347MB of space on the distro. You'd be back near where you started. Forget it!

A better method is to install only the Debian Jr. packages you actually want, or to just pick and choose the individual software items in each Debian Jr. metapackage.

For instance, if you want to check out Debian Jr. Internet packages, see what would happen if you installed it:

 # apt-get install junior-internet 

Here's what APT tells you:

 The following extra packages will be installed:    dillo libnspr4 mozilla mozilla-browser mozilla-mailnews mozilla- psm Suggested packages:    mozilla-chatzilla xprt latex-xft-fonts Recommended packages:    myspell-en-us myspell-dictionary The following NEW packages will be installed:    dillo junior-internet libnspr4 mozilla mozilla-browser mozilla- mailnews mozilla-psm 0 upgraded, 7 newly installed, 0 to remove and 83 not upgraded. Need to get 12.7MB of archives. After unpacking 39.1MB of additional disk space will be used. 

If that looks good to you, go ahead and enter Y. Otherwise, enter N and be done with it, or install the individual packages that make up junior-internet, like mozilla-browser or dillo.

The Debian Jr. typing package is another in which you may be interested:

 # apt-get install junior-typing 

Find out what packages will be installed:

 Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed:    gtypist tipptrainer tipptrainer-data-de typespeed wamerican wenglish wxwin2.4-i18n xletters The following NEW packages will be installed:    gtypist junior-typing tipptrainer tipptrainer-data-de typespeed wamerican wenglish wxwin2.4-i18n xletters 0 upgraded, 9 newly installed, 0 to remove and 83 not upgraded. Need to get 2037kB of archives. After unpacking 6412kB of additional disk space will be used. 

Look good? Go for it. Otherwise, ignore them, or feel free to pick and choose the software you want.

A distro for kids should be fun, don't you think? Check out the games:

 # apt-cache search junior-games | awk '{print $1}' 

These are the Debian Jr. metapackages that come up:

 junior-games-card junior-games-gl junior-games-net junior-games-sim junior-games-text 

Looks good. Here's how to install them the easy way:

 # apt-get install $(apt-cache search junior-games | awk image from book    '{print $1}') 

APT informs you that you're going to install 34 games, which will require a download of 33MB and 70.9MB of space on your drive. You've made room, and this should fit.

Of course, you could continue deleting and installing software, but it's time to move on. You need to perform any final clean-ups before proceeding.

 # apt-get clean 

That gets rid of 155MB you didn't need, but there's more. As you've been working, you may have been generating system mail. Use the following to remove it:

 # rm -rf /var/mail/root 

Finally, remove anything in the /tmp directory:

 # rm -rf /tmp 

Whew! Before leaving your chroot environment, unmount the proc filesystem:

 # umount /proc 
Caution 

Do not forget to unmount the proc filesystem, or your Knoppix may not function the way you want it to!

Now it's time to leave chroot:

 # exit 

You're now back in your normal shell, but, no, you're not finished yet.



Hacking Knoppix
Hacking Knoppix (ExtremeTech)
ISBN: 0764597841
EAN: 2147483647
Year: 2007
Pages: 118

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net