root/morphix/trunk/how_tos/morphingmorphix.html

Revision 2, 7.4 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1 <h1>Morping Morphix</h1>
2
3 <p>In this hack we will take a closer look at how Morphix is built up,
4 how it can be changed and how you can have the modularity of Morphix
5 make your life easier. If you want to skip the details and dive into
6 making your first 'morph', jump down to the next section below.
7
8 <h2>Structure of a Morphix Live CD</h2>
9
10 <p>As stated in the Morphix overview hack, a Morphix live CD has a
11 number of directories:
12
13 <pre>
14 /base
15 /mainmod
16 /minimod
17 /exec
18 /copy
19 /deb
20 </pre>
21
22 <p>We will look at each of the directories on a Morphix live CD and how
23 they would allow you to change your live CD. The main difference is
24 the file types: the first three (/base, /mainmod and /minimod) are
25 compressed filesystems (modules), the last three are provided for
26 extra flexibility. Morphix' modules can be compressed using a number
27 of compression techniques, like cloop, squashfs or zisofs.
28
29 <p>/base
30
31 <p>This directory contains the normal boot files, similar to the /KNOPPIX
32 directory. The morphix file is comparable with the KNOPPIX file in
33 this directory. It is a lot smaller (~30MB) however, and contains only
34 the bare necessities for getting your live CD up and running. Kernel,
35 kernel modules and hardware detection reside in the boot.img and
36 morphix files.
37
38 <p>/mainmod
39
40 <p>A mainmodule is essentially your filesystem after your live CD has
41 booted up. It contains everything ranging from your commandline tools
42 to your windowmanager and graphical applications. Typically, most
43 software of a Morphix iso is kept in the mainmodule.
44
45 <p>Once base has done its work, it attempts to find any files in the
46 /mainmod directory of your live CD. If there are multiple files, it
47 will prompt the user to select one of these mainmodules. If there are
48 none, the user will be dropped to a bash prompt.
49
50 <p>The mainmodule that gets selected (automatically or manually) is then
51 mounted. The base module scripts link the necessary directories and
52 copies the detected configuration files into the mounted
53 mainmodule. The system then chroot's into the directory of the mounted
54 mainmodule. Scripts in the /morphix directory of this mainmodule are
55 executed too. For example, in a normal Morphix iso you startx,
56 your favorite window manager pops up and you can do business as usual,
57 without even noticing the modular structure of Morphix underneath.
58
59 An interesting ability of mainmodules is that these don't necessarily
60 have to be Debian-based. Morphix has Slackware, Fedora and SuSE
61 derivatives, showing the flexibility mainmodules provide.
62
63 <p>/minimod
64
65 <p>Minimods is the third type of module we currently offer. Essentially
66 compressed images with a script inside, minimodules can be as simple
67 or complex as you would like them to be. They are mounted alongside
68 the mainmodule at boot time. For demonstration purposes, a few examples:
69
70 <ul>
71 <li>Morphix Game 0.4-1 has an Enemy Territory minimodule. This module
72   seemlessly integrates with Morphix Game 0.4-1, and if a morpher
73   decides he doesn't want to include Enemy Territory, he simply
74   removes this module.
75
76 <li>Morphix Gnome and KDE 0.4-1 have a WINE minimodule. Likewise, if a
77   morpher doesn't want to include WINE on his live CD, he simply has to
78   remove this file from his live CD image.
79 </ul>
80
81 <p>There are minimodules for Console-specific tools, Q3A and UT2k3 demos,
82 OpenOffice.org, Speedtouch USB modems, PHP4/Nanoweb/MySQL, and a whole
83 range of others. Morphix offers preliminary scripts to autogenerate
84 these minimodules from Debian packages, however this is an area still under
85 quite a lot of discussion and development.
86
87 <p>You are able to do more down-to-earth changes using
88 minimodules. If you want to have different minimodules containing different
89 home directories for your live CDs, take a look at CD-Persistant, which
90 even allows you to burn your home directory directly to a running
91 live CD, using multisession cdroms, or Xbroadcast, which will attempt
92 to locate remote XDMCP hosts on your local network.
93
94 <p>Needless to say, minimodules offer an extreme amount of flexibility, maybe even
95 too much. For this reason, the following three directories for applying changes
96 to your live CD during boot time have gotten a place in Morphix over the last
97 year.  No more do you have to rebuild your compressed images for small changes.
98
99 <p>/exec
100
101 <p>If you simply want to start a few bash scripts at boot time, this directory
102 is the place to put them. Knoppix gives you a single filename which is
103 executed at boot time, Morphix gives you a directory.
104
105 <p>/copy
106
107 <p>Using translucency, the overlay technique in Morphix, you can place
108 files anywhere on the filesystem. This is of course handy for
109 minimodules, but also for more simple purposes. Place a file in
110 /copy/etc and it is placed in /etc of your live CD. Place a file in
111 /copy/usr/local and it is placed in /usr/local. Morphers, being a lazy
112 bunch, enjoy using /copy for quick hacks :-)
113
114 <p>/deb
115
116 <p>Throw a debian package in here and if your mainmodule supports dpkg (ie. it
117 is Debian-based) the package is installed at boot time. Since this uses dpkg
118 directly, you will need to make sure you handle your own dependencies for any
119 packages you add here. As installing debian packages does cost some
120 RAM, make sure you don't throw too many packages in here (it also
121 increases the time your live CD takes to boot!). When wanting to
122 install large packages, using mini/main modules quickly becomes a
123 better alternative. But, when you need another quick hack...
124
125 <h2>Your first Morph</h2>
126
127 <p>Now we know how a Morphix live CD can be structured, lets make us a
128 new Live CD to illustrate. Even if you only skimmed over the last
129 section, 'morphing' isn't hard to start with. Lets say you want to do
130 something simple, like change the default background of your live
131 CD. There are plenty of scripts available to automate most or all of
132 the process, but we won't use them here. Please note that you will
133 need to be root for some of these commands.
134
135 <p>We need to change the contents of our CD-ROM iso. First things
136 first, lets make sure we can access the files on it. Lets make a
137 directory and mount the iso:
138
139 <pre>
140 mkdir /tmp/morphlight
141 mount MorphixCombined-LightGUI-0.4-1.iso /tmp/morphlight
142 </pre>
143
144 <p>Alas, we can't directly modify the files on the iso. So, as we
145 really want to modify the iso, we need to copy the iso files to a new
146 directory:
147
148 <pre>
149 mkdir /tmp/mylivecd
150 cp -a /tmp/morphlight/* /tmp/mylivecd
151 </pre>
152
153 <p>Now, where was that background located? Checking the XFCE4
154 settings, you discover it is located at /morphix/background.png. Not
155 wanting to figure out in which module it is located, you use the
156 /copy-directory instead to copy your new background (located at
157 ~/mybackground.png) over the other one at boot time:
158
159 <pre>
160 mkdir /tmp/mylivecd/copy/morphix
161 cp ~/mybackground.png /tmp/mylivecd/copy/morphix/background.png
162 </pre>
163
164 <p>Now, lets make us a new CD-ROM iso from this directory:
165
166 <pre>
167 mkisofs -l -v -J -V "My New LiveCD" -r -b base/boot.img -c \
168         base/boot.cat -hide -rr -moved -o /tmp/mylivecd.iso \
169         /tmp/mylivecd
170 </pre>
171
172 <p>Well, that was it! You can burn your iso using your favorite CD-R
173 burning tool, and you're done. One freshly baked live CD with your own
174 background, coming right up:
175
176 <pre>
177 cdrecord speed=8 dev=0,0,0 /tmp/mylivecd.iso
178 </pre>
179
180 <p>Of course, this was a pretty simple morph. You can do quite
181 amazing stuff using Morphix without needing to remaster modules
182 directly, for lots of step-by-step recipes and more elaborate
183 documentation take a look at the HowTos on www.morphix.org
184
Note: See TracBrowser for help on using the browser.