Remastering Hacks
There are so many howtos cropping up, each with individual tips and customization examples for Knoppix remasters, that it seems good to have a place to put generic tips, no matter how you go about remastering, be it using scripts, completely by hand, or via a HD install, Morphix, etc... Please add your tips and example "hacks" here.
Contents
- 1 Remastering Process Tips
- 2 Installing software and clearing up space with Apt
- 2.1 Get the best apt mirror
- 2.2 Update all packages
- 2.3 Configuring locale settings
- 2.4 Character based package management with Aptitude
- 2.5 Cleaning up space when removing apps
- 2.6 Removing a bunch of internationalization support to save space using Apt and grep
- 2.7 What to do when behind a proxy
- 2.8 Useful packages for install packages and cleaning up locales
- 3 Boot
- 4 Startup
Remastering Process Tips
Saving space while running chroot environment
- If you booted from CD, even on a HD install instead of copying the original CD and KNOPPIX directory to the HD, you can use them directly from their mount points.
- Another alternative is to mount an ISO image of the original CD as a loop device and mount the KNOPPIX image as a cloop device. You will save close to 2 GB of space. Script to mount from an ISO image:
#!/bin/bash # Assumes that the current directory is the working space # original.iso is an image of the CD we will be using as master mount -t iso9660 original.iso ./oldcd -o ro,loop # initialize the compressed loop device losetup /dev/cloop1 ./oldcd/KNOPPIX/KNOPPIX mount -t iso9660 /dev/cloop1 ./KNOPPIX -o ro,loop
Installing software and clearing up space with Apt
Get the best apt mirror
- Get apt-spy and use it to modify the sources.list file with the best mirrors for your particular region. This will speed up the downloading. Backup the original sources.list just in case.
- Another technique is to modify sources.list. Replace the string .de. in the FTP addresses (ftp.de.debian.org) with the code corresponding to your country. Examples: USA -> .us. (ftp.us.debian.org), Brazil -> .br. (ftp.br.debian.org). Check the Debian site for debian.org mirrors in your country.
- Remember to uncomment the Linuxtag FTP addresses to get the latest and greatest from Knoppix
Update all packages
- Use apt-get update to get the lists with the latest releases and patches. Do not update a package if you don't need to, it may lead to the use of additional disk space (precious commodity when you want to keep everything below 700 MB) and you may brake something else without knowing. Abuse the -s option to simulate the installation.
- Before doing the update, I modified my default releases to testing, that means that the software I'll be using will have a good balance of stability and features. Knoppix uses unstable by default, which is too risky for my personal taste.
Configuring locale settings
- Run the command dpkg-reconfigure locales as the root user. This will allow you to select/de-select the locales that you will use, and choose a default locale for your system.
Character based package management with Aptitude
- I use aptitude to get/remove applications, it is character based so it works with init 2. As you mark packages for install/update/removal, it will tell you how much disk space you will save/use, try to solve depencies problems and give you plenty control to fix them manually when possible.
- After you are done, aptitude may leave some files behind. Here's a clean up script I use:
# !/bin/bash # Clean package files generated by aptitude rm /var/log/aptitude rm /var/lib/apt/lists/*debian* rm /var/lib/apt/lists/*knoppix*
Cleaning up space when removing apps
- When removing/purging applications, they may leave behind non-empty directories. Usually this is announced by aptitude, apt-get or any other installation utilty. Make sure to check the messages and manually remove those directories.
Removing a bunch of internationalization support to save space using Apt and grep
The following command returns a listing of all packages installed.
dpkg-query -l | less
While that command is useful, you can use grep to sort out which packages you to remove. The following command shows me packages that kde uses for internationalization support and strips off all the other extraneous information.
dpkg-query -l | grep i18n | grep kde | cut -d' ' -f3
I can feed this to apt-get so that it will remove those packages.
apt-get remove `dpkg-query -l | grep i18n | grep kde | cut -d' ' -f3`
You could remove openoffice and other German tools as follows:
apt-get remove openoffice-de-en manpages-de trans-de-en
What to do when behind a proxy
If you are behind a proxy and must authenticate against it to access the internet, then use the following command. export http_proxy="http://username:passwd@yourproxy.company.com:portnumber/"
Useful packages for install packages and cleaning up locales
Add three useful packages:
apt-get install localepurge aptitude
Localepurge will only keep the locales that are marked. This means that it will free up additional space. After running through the configuration removing locales you don't need, you must run it from the command line:
localepurge
NOTE: localepurge may not be able to be installed by the apt-get install command (ie. you get the error "Couldn't find package localepurge" when you try to install), but you can install it with the aptitude interface.
Aptitude is a console menu front end to apt and dpkg.
Package updates within the GUI
apt-get install synaptic
Synaptic is a graphical front end to apt & dpkg.
Boot
Boot logo
The boot logo: The boot image is logo.16 and is a lss16 format image. To start make a 16 color image (in Gimp, create the image and use the Image -> Mode -> Indexed menu to export to 16 colors) you want to use. The image must be 640x480 or less. 640x400 leaves room at the bottom for the boot prompt. Save the image as a bmp format (in gimp you can save as ppm as well to skip the first conversion). Then run:
bmptoppm mylogo.bmp > logo16.ppm ppmtolss16 < logo16.ppm > logo.16
Startup
Adding init scripts that should run
Say you need to make sure certain services are started up at boot time. You would think you could put them in the proper /etc/rc<num>.d/ directory and they would just work eh. Ha. Ha. To get something to always start, you have to actually modify the /etc/init.d/knoppix-autoconfig script and have it start the services. The init scripts will always be in the /etc/init.d/ directory, but they won't stay in the /etc/rc<num>.d directories, even if you put them there. It will make you sad.
For example, to add a custom VPN script and turn on some of the NFS client utils, one could add some lines after the automounty stuff:
# Start automounter now /etc/init.d/autofs start >/dev/null && echo "${GREEN}Automounter started for: ${MAGENTA}${AUTOMOUNTS}${GREEN}.${NORMAL}" fi # # CUSTOM SCRIPTY STUFF # if [ -f /etc/init.d/portmap ] ; then /etc/init.d/portmap start >/dev/null && \ echo "${GREEN}Portmapper started" fi if [ -f /etc/init.d/nfs-common ] ; then /etc/init.d/nfs-common start >/dev/null && \ echo "${GREEN}NFS Common Services started" fi # Start VPN if [ -f /etc/init.d/vtundvpn ] ; then /etc/init.d/vtundvpn start >/dev/null && \ echo "${GREEN}VPN started" fi # # END CUSTOM SCRIPTY STUFF #
Note: In v6.x this has gotten much easier. Just edit /etc/rc.local and add the services you want to start to the SERVICES variable in that script.