Hack 99 Morph Morphix

 < Day Day Up > 

Hack 99 Morph Morphix

figs/moderate.gif figs/hack99.gif

The modular nature of Morphix that has made it so popular also makes it very easy for a user to create custom discs .

Morphix [Hack #80] is a Knoppix-based distribution that has made many changes to the structure of Knoppix to make it more modular. These modules make it much easier to add and remove software for your own remastering . This hack takes a closer look at how Morphix is built, how it can be changed, and how you can have the modularity of Morphix make your life easier. If you want to skip the details and dive into making your first "morph," jump down to Section 9.7.2, below.

9.7.1 Structure of a Morphix Live CD

A Morphix live CD has a number of unique directories:

/ exec

One difference in these directories is the file types: the first three ( /base , /mainmod , and /minimod ) are compressed filesystems (modules); the last three are provided for extra flexibility. Morphix's modules can be compressed using a number of compression techniques, like cloop , squashfs , or zisofs . Of course, each of these directories has a special purpose, which are described below:


This directory contains the normal boot files, similar to the /KNOPPIX directory. The morphix file in this directory is comparable with the KNOPPIX file. It is a lot smaller, however (~30 MB versus ~700 MB), and contains only the bare necessities for getting your live CD up and running. A kernel, kernel modules, and hardware detection reside in the boot.img and morphix files.


A mainmodule is essentially your filesystem after your live CD has booted up. It contains everything, from your command-line tools to your window manager and graphical applications. Typically, most software on a Morphix ISO is kept in the mainmodule .

Once base has done its work, it attempts to find any files in the /mainmod directory of your live CD. If there are multiple files, it prompts the user to select one of these mainmodule s. If there are none, the user is dropped to a bash prompt.

The mainmodule that gets selected (automatically or manually) is then mounted. The base module scripts link the necessary directories and copy the detected configuration files into the mounted mainmodule . The system then chroots into the directory of the mounted mainmodule . Scripts in the /morphix directory of this mainmodule are then executed too. For example, in a normal Morphix ISO you can run startx , and your favorite window manager pops up and you can do business as usual, without even noticing the modular structure of Morphix underneath. An interesting ability of mainmodule s is that these don't necessarily have to be Debian-based. Morphix has Slackware, Fedora, and SUSE derivatives, showing the flexibility mainmodule s provide.


Minimodule s are a third type of module. Essentially compressed images with a script inside, minimodule s can be as simple or as complex as you want them to be. They are mounted alongside the mainmodule at boot time. For demonstration purposes, here are a few examples:

  • Morphix Game 0.4-1 has an Enemy Territory minimodule . This module seamlessly integrates with Morphix Game 0.4-1, and if a morpher decides he doesn't want to include Enemy Territory, he simply removes its minimodule .

  • Morphix Gnome and KDE 0.4-1 have a WINE minimodule . Likewise, if a morpher doesn't want to include WINE on his live CD, he simply has to remove this file from his live CD image.

There are minimodule s for console-specific tools, Quake 3 Arena and Unreal Tournament 2003 demos, OpenOffice.org, Speedtouch USB modems, PHP4/Nanoweb/MySQL, and a whole range of others. Morphix offers preliminary scripts to automatically generate these minimodule s from Debian packages; however, this area is still under quite a lot of discussion and development.

You can also do more down-to-earth changes using minimodule s. If you want to have different minimodule s containing different home directories for your live CDs, take a look at CD-Persistant , a minimodule that even allows you to burn your home directory directly to a running live CD using multisession CD-ROMs, or Xbroadcast , which attempts to locate remote XDMCP hosts on your local network.

Needless to say, minimodule s offer an extreme amount of flexibility, maybe even too much. For this reason, the following three directories for applying changes to your live CD during boot time have become a part of Morphix over the last year. No more do you have to rebuild your compressed images for small changes.


If you simply want to start a few bash scripts at boot time, this directory is the place to put them. Knoppix gives you a single file to be executed at boot time; Morphix gives you a directory.


Using translucency, the overlay technique in Morphix, you can place files anywhere on the filesystem. This is of course handy for minimodule s but also for more simple purposes. Place a file in /copy/etc and it is placed in /etc of your live CD. Place a file in /copy/usr/local and it is placed in /usr/local . Morphers, being a lazy bunch, enjoy using /copy for quick hacks.


If your mainmodule supports dpkg (which means it is Debian-based), put a Debian package in this directory, and the package is installed at boot time. Since this uses dpkg directly, you must make sure you handle your own dependencies for any packages you add here. As installing Debian packages does require some RAM, and each package increases the time your live CD takes to boot, make sure you don't put too many packages in here. When you want to install large packages, using minimodule s or mainmodule s quickly becomes a better alternative.

9.7.2 Your First Morph

Now that you know how a Morphix live CD can be structured, it is time to make a new live CD. Even if you skimmed over the last section, "morphing" isn't hard to start with. This first example is simple: it changes the default background of a live CD. There are plenty of scripts available to automate most or all of the process, but I won't use them here. Please note that you must be root for some of these commands.

For this morph, you must change the contents of your CD-ROM ISO. So you must make sure you can access the files on it. Make a directory and mount the ISO:

 #  mkdir /tmp/morphlight  #  mount -o loop   MorphixCombined-LightGUI-0.4-1.iso   /tmp/morphlight  

Alas, you can't directly modify the files on the ISO, so you must copy the files on the ISO to a new directory:

 #  mkdir /tmp/mylivecd  #  cp -a /tmp/morphlight/* /tmp/mylivecd  

The background is located at /morphix/background.png . Instead of figuring out in which module it is located, use the /copy directory to copy your new background (located at ~/mybackground.png for this example) over the original one at boot time:

 #  mkdir /tmp/mylivecd/copy/morphix  #  cp ~/mybackground.png /tmp/mylivecd/copy/morphix/background.png  

Now make a new CD-ROM ISO from the /tmp/mylivecd directory:

 #  mkisofs -l -v -J -V  "  My New LiveCD  "  -r -b base/boot.img -c   base/boot.cat -hide -rr -moved -o  /tmp/mylivecd.iso      /tmp/mylivecd  

Well, that's it! You can burn your ISO using your favorite CD-R burning tool, and you're done. One freshly baked live CD with your own background, coming right up:

 #  cdrecord speed=8 dev=0,0,0   /tmp/mylivecd.iso  

Of course, this was a pretty simple morph. You can do quite amazing things using Morphix without remastering modules directly. For lots of step-by-step recipes and more elaborate documentation, take a look at the HOWTOs on http://www.morphix.org.

 < 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