Hack 95 Trim the Fat

 < Day Day Up > 

figs/moderate.gif figs/hack95.gif

Knoppix has been able to squeeze a lot of useful tools on a single CD image. When you want to add your tools to the mix, you must use some tricks to keep the total file size low enough to fit on a CD .

So you've gone through all of the steps, and, finally, your remastered CD is finished. You are about to reach over for a blank CDR when you notice your CD image is 740 MB! Welcome to the challenge Klaus Knopper faces with every release: keeping almost 2 GB of great software compressed under 700 MB. The Knoppix 3.4 release was delayed for some time partially because some of the popular packages in Knoppix, like KDE and OpenOffice.org, had continued to increase in size. To get everything to fit, Klaus had to remove the complete KOffice suite along with TeX and a few other packages.

You might decide to create your own Knoppix CD because there are some programs that are not included in Knoppix that you want on the CD. To add those programs, other programs must go, but there are some steps you can take while you are in the chroot environment to make the process easier.

9.3.1 Find Programs to Remove

The first step in slimming down your CD is to find programs you don't need. Knoppix comes with a lot of software, and depending on how you plan to use Knoppix, you may be able to do without large parts of the system.

If you are unsure of which software you want to remove, it might help to see which programs are taking up the most space. The following command lists all of the packages installed on the system, sorted by size:

 root@ttyp0[/]#  dpkg-query -W showformat='${Installed-Size} ${Package}\n  '  sort -n  . . . 28684 libwine 30056 kernel-image-2.4.26 31944 mozilla-browser 34662 emacs21-common 45556 kernel-image-2.6.6 243092 openoffice-de-en 

The file sizes in the output are in kilobytes. As you can see, the largest single package on the system happens to be openoffice-de-en. So, if you want to free up around 250 MB of uncompressed space on your CD, delete the openoffice-de-en package by running:

 root@ttyp0[/]#  apt-get purge remove openoffice-de-en  

This command not only removes the openoffice-de-en package, but with the --purge option, it also clears the system of any configuration files the package might have used. You will find that every little bit helps when you are trying to make space.

9.3.2 Dependencies

When you remove a package, apt-get also removes any packages that depend on that package. For instance, if you remove the emacs21-common package, you see that other packages are also removed, freeing up a total of 42.1 MB. Apt-get lists the amount of disk space that will be freed once you remove a package and prompts you to continue, so you can pretend to remove a package just to see how much space will be freed without actually doing any damage. Just make sure to answer "no" when you are prompted to continue.

 root@ttyp0[/]#  apt-get purge remove emacs21-common  Reading Package Lists... Done Building Dependency Tree... Done The following packages will be REMOVED:   emacs21* emacs21-bin-common* emacs21-common* gettext-el* 0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded. Need to get 0B of archives. After unpacking 42.1MB disk space will be freed. Do you want to continue? [Y/n]  n  Abort. 

Dependencies are also important to consider as you remove programs, because you might inadvertently remove a package you need to keep by removing a package it depends on.

Be extra aware of which dependencies will be removed when you remove library packages (packages usually starting with lib), because they typically have many other programs that depend on them.

You can also check which packages depend on a certain package with the apt-cache command:

 root@ttyp0[/]#  apt-cache rdepends libwine  uniq  libwine Reverse Depends:   libwine-twain   wine-utils   wine   libwine-print 

This example pipes the output through the uniq command because the reverse dependencies option in apt-cache often generates multiple lines with the same package name , so with the uniq command you see only unique packages that depend on this package.

9.3.3 Please Sir, I Want to Remove More

After removing programs that you know you won't need, there still might be ways to trim down the system by removing programs known as orphans . Orphans are packages (usually libraries) that have no other packages depending on them. Knoppix includes Debian's tool called deborphan for this purpose. To list all of the orphaned libraries on your system sorted by their size, run:

 root@ttyp0[/]#  deborphan -z  sort -n  

By default, deborphan lists only libraries, not other types of packages. The reason for this is that generally a library's purpose is to have other programs use and depend on it. When no programs depend on a library anymore, it has no further use. Many regular programs that you might use don't have any other packages depending on them, yet you generally don't want to remove them. On a default Knoppix install, deborphan returns no packages, because Klaus already beat you to removing the orphans. If you have maintained a remastered CD for some time, however, you might find that libraries are orphaned from time to time as packages upgrade and leave behind old libraries they no longer need.

If you want to just quickly remove all orphans from your system, run the following command:

 root@ttyp0[/]#  deborphan  xargs apt-get -y purge remove  

Remove the -y option from apt-get if you want to be prompted before following through with the command.

9.3.4 Use the Best Possible Compression

When you create the compressed Knoppix filesystem with:

 root@ttyp1[hda1]#  mkisofs -R -U -V  "  Knoppix Hacks filesystem  "  -P  "  Knoppix Hacks  "  -hide-rr-moved -cache-inodes -no-bak -pad source/KNOPPIX  nice -5 /usr/bin/create_compressed_fs - 65536 > master/KNOPPIX/KNOPPIX  

you can add the --best option after the /usr/bin/create_compressed_fs command to increase the compression even further. On a 700-MB image, this option can save an extra 20 MB but takes much longer to complete.

9.3.5 Final Tips

If you have tried all of the other methods , and you still need to free up space but aren't sure where, there are still a few other tricks you can try.

Whenever you download new packages using apt-get , a copy of the package is cached under /var/cache/apt/archives . Always make sure to run apt-get clean before you create the disk image.

If you are still having trouble figuring out which programs are taking up the most space on the filesystem, try the following command, which will sort all of the directories on your system by how much space they are using:

 root@ttyp0[/]#  du -cb /  sort -n  

Finally, remember that certain file types compress better than others, which means they are smaller when in the compressed KNOPPIX filesystem. So if you have a choice between removing a 5-MB text file and a 5-MB .mp3 file, remove the .mp3 file, because the .mp3 file is already about as compressed as it will go, and the text file will compress much smaller.

 < Day Day Up > 

Knoppix Hacks. 100 Tips and Tricks
Knoppix Hacks. 100 Tips and Tricks
Year: 2004
Pages: 166

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