<html><head><title>Advanced Diary</title>
</head>
<body bgcolor="#ebfceb" leftmargin=5 topmargin=5 rightmargin=5 bottommargin=5>
<font size=2 color="#000000" face="Arial">
<div><font size=3><b><u>Building My Development Kernel</u></b></font></div>
<div><br></div>
<div><b><u>Assumptions</u></b></div>
<div><br></div>
<div>1. Logged in as root.</div>
<div><br></div>
<div>2. Linux version is 2.6.29.3 ... replace as appropriate.</div>
<div><br></div>
<div>3. RAM disc play area directory at /root/initrd-2.6.29.3, with subdir 'initrd'.</div>
<div><br></div>
<div>4. OK to see errors on screen - else redirect error output via "2>"</div>
<div><br></div>
<div>5. /usr/src/linux is symlinked to /usr/src/linux-2.6.29.3</div>
<div><br></div>
<div>6. Boot manager is GRUB ~ I know nothing about LILO or others.</div>
<div><br></div>
<div>7. Based on having the following <b>additional </b>entry in grub.conf, aka menu.lst, (the original distro entry gives vital "recovery disc" mode) ... </div>
<div><br></div>
<div><font face="Courier New"> title Barry's Dev Kernel</font></div>
<div><font face="Courier New"> root (hd0,0)</font></div>
<div><font face="Courier New"> kernel /bzImage-2.6.29.3 ro root=/dev/hda2 vga=794 splash=off</font></div>
<div><font face="Courier New"> initrd /initrd-2.6.29.3.img</font></div>
<div><br></div>
<div> Note that because I have a separate boot partition, the above kernel & initrd image paths have an implicit '/boot' in front of them.</div>
<div><br></div>
<div><b><u>Building the Kernel</u></b></div>
<div><br></div>
<div><table width="100%" border=1 cellpadding=2 bordercolor="#c0c0c0" cellspacing=0 bgcolor="#ffffff">
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div align=center><b><u>Do this ...</u></b></div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div align=center><b><u>To achieve this ...</u></b></div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div align=center><b><u>Take note of this</u></b></div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div><b><br></b></div>
<div><b>Initial preparations ...</b></div>
</font>
</td>
<td width=223><br>
</td>
<td width=383><br>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cd /usr/src/linux</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Change to parent dir of Linux tree.</div>
</font>
</td>
<td width=383><br>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>Backup any .config or generated files you don't want to lose!</div>
</font>
</td>
<td width=223><br>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>It's too late afterwards!</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>make mrproper</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Deletes current kernel config, and all generated files. Superset of 'make clean', so no need to do both!</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Back up current config & any generated files you want to keep!</div>
<div><br></div>
<div><b>Not needed</b> for most builds. Use for first build of new kernel tree, or if build problems suggest a complete virgin build needed.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>make menuconfig, etc</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Configure the kernel</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div><b><u>IF</u></b> you need to configure the kernel, do it <b>after</b> 'make mrproper'! Good idea to back up your new config immediately anyway.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>make clean</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Deletes most generated files, leaving just enough to build external modules. Leaves current config alone.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Back up any generated files you want to keep! </div>
<div><br></div>
<div><b>Not needed</b> for incremental development builds. Use typically whenever a complete re-build needed, without wanting to reset everything back to being a completely virgin config & build.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div><b><br></b></div>
<div><b>Building the Kernel ...</b></div>
</font>
</td>
<td width=223><br>
</td>
<td width=383><br>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>make bzImage</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Build the kernel image.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Builds the kernel image according to the current .config</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>make modules</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Build the driver modules.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Builds the driver modules according to the current .config</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>make modules_install</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Install the newly build modules.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Updates module objects into /lib/modules/2.6.29.3/<i>blah...</i></div>
<div>Updates various module dependencies files.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div><b><br></b></div>
<div><b>Preparing the RAM disc image ...</b></div>
</font>
</td>
<td width=223><br>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div><b>Not needed</b> unless RAM disc image needs to change.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>mkinitrd -f initrd.img 2.6.29.3</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Create a default RAM disc image.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>It's only a default - needs more adding into it. The kernel version # tells mkinitrd which modules to base it on ... see /lib path above.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cp initrd.img /root/initrd-2.6.29.3/initrd.img.gz</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Copy RAM image to prep area</div>
</font>
</td>
<td width=383><br>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cd /root/initrd-2.6.29.3</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Change to prep area directory</div>
</font>
</td>
<td width=383><br>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>gunzip initrd.img.gz</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Unzip the RAM image.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>The zip file disappears and left with a single RAM image file.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cd initrd</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Change to image directory</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>CPIO will unpack to current dir, so need to be here.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cpio -i -make-directories < ../initrd.img</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Unpack the RAM disc image into local dir structure below 'initrd'.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Image file must be in parent dir, as we don't want it to be part of the RAM disc image when we repack it again!</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>Add whatever additional modules needed into RAM disc image tree.</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>To provide initial device drivers in temporary startup root file system</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Drivers go into /root/initrd-2.6.29.3/initrd/lib (assuming it's being done from /root). <i>I unpacked distro image to see what needed.</i></div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>Add additional module load instructions to RAM disc's 'init' script.</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Loads the newly added drivers at startup from the RAM disc.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Edit the script file /root/initrd-2.6.29.3/initrd/init. </div>
<div><b>Important note:</b> I had to remove the 'splash' command from this script else it totally blew up and all file system mounts failed!</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>Ensure still in initrd dir</div>
</font>
</td>
<td width=223><br>
</td>
<td width=383><br>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>find . | cpio --create --'format=newc' | gzip > <br>
../initrd.tmp <i>(meant to be all on one line!)</i></div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Pack/zip new RAM disc image.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>The .gz usually dropped for RAM disc image, unless actually playing with gunzip. initrd.tmp is the new zipped RAM disc image.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cp ../initrd.tmp /boot/initrd-2.6.29.3.img</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Install the new RAM disc image.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Will get used at the next startup.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div><b><br></b></div>
<div><b>Install the new Kernel ...</b></div>
</font>
</td>
<td width=223><br>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>I leave this till after fiddling with RAM disc image, to minimise risk of booting with mismatched kernel and RAM disc images.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cd /usr/src/linux</div>
</font>
</td>
<td width=223><br>
</td>
<td width=383><br>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cp arch/i386/boot/bzImage /boot/bzimage-2.6.29.3 <i>(meant to be all on one line!)</i></div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Install the new kernel image</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>Will get used at the next startup.</div>
</font>
</td>
</tr>
<tr valign=top>
<td width=261><font size=2 color="#000000" face="Arial">
<div>cp System.map /boot/System.map</div>
</font>
</td>
<td width=223><font size=2 color="#000000" face="Arial">
<div>Debug symbols available.</div>
</font>
</td>
<td width=383><font size=2 color="#000000" face="Arial">
<div>So debug info matches the running kernel (I think that's it).</div>
</font>
</td>
</tr>
</table>
</div>
</font>
</body></html>