Tutorials - Porteus - Portable Linux Learn how to install Porteus, about Porteus modules and getting porteus to work with wifi internet. https://www.porteus.org/tutorials/20-development.feed 2025-05-03T09:02:17+00:00 Joomla! - Open Source Content Management An Introduction to GPU computing (CUDA) on Porteus 2011-04-07T06:03:40+00:00 2011-04-07T06:03:40+00:00 https://www.porteus.org/tutorials/20-development/107-an-introduction-to-gpu-computing-cuda-on-porteus.html captain_picard <div class="feed-description"><p>This is meant as an introduction on how to do some serious number crunching on the GPU using Porteus and the CUDA programming framework. We will start from the very basics, ie how to set up everything and all the way to compiling some simple examples.This post will be updated as needed. However, please keep in mind that for any questions related to CUDA programming itself you should use the NVIDIA forum instead.<br /><br />1) Requirements<br />2) Download the necessary files<br />3) Installation of the framework and the SDK<br />4) Build the shared libs<br />5) Do some tests<br />6) Have some fun!<br /><br />All the tests during the writing of this post were performed on an HP dv8-1190eo laptop running Porteusx64, 8GB RAM with a Geforce 230M GT graphics card.<br /><br />1) Requirements<br /><br />i) A laptop/PC running Porteus<br />ii) Some familiarity with C/C++ and programming in general (can't help you in this!)<br />iii) A supported&nbsp; NVIDIA graphics card. The i486 version of the driver can be found <a href="http://dl.porteus.org/i486/current/drivers/">here</a>, and the x64 version of the driver can be found <a href="http://dl.porteus.org/x86_64/current/drivers/">here</a>.<br /><br />If you are not sure whether your card is supported, a quick way to check is to see if your laptop or PC has an NVIDIA sticker that says something like: "GEFORCE with CUDA" or&nbsp; just go to<br /><a href="http://www.nvidia.com/object/cuda_gpus.html">http://www.nvidia.com/object/cuda_gpus.html</a> and check if your card is supported.&nbsp;&nbsp; <br /><br />2) Download the necessary files (take care to download the x64 versions where available)<br />You will need the following files freely available from NVIDIA's site:<br /><a href="http://developer.nvidia.com/object/gpucomputing.html">http://developer.nvidia.com/object/gpucomputing.html</a><br /><a href="http://www.nvidia.com/object/cuda_gpus.html">http://developer.nvidia.com/object/cuda_3_2_downloads.html</a><br /><br />The NVIDIA driver found at the Porteus site includes the CUDA driver, so you only need to download the Toolkit and the SDK.<br /><br />i) Grab the CUDA toolkit (it's the Fedora version, but it works OK):<br /><a href="http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/3_2_prod/toolkit/cudatoolkit_3.2.16_linux_64_fedora13.run">http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/3_2_prod/toolkit/cudatoolkit_3.2.16_linux_64_fedora13.run</a><br /><br />ii) Grab the SDK:<br /><a href="http://developer.download.nvidia.com/compute/cuda/3_2_prod/sdk/gpucomputingsdk_3.2.16_linux.run">http://developer.download.nvidia.com/compute/cuda/3_2_prod/sdk/gpucomputingsdk_3.2.16_linux.run</a><br />The SDK contains tons of examples and it is vital if you want to do any serious work.<br /><br />iii) Grab any extra Guides or Libraries you want. The GPU-accelerated LAPACK libraries could be useful but it will cover that in a future post.<br /><br />3) Installation of the framework and the SDK<br /><br />In order to install the files open a console in the folder where you downloaded them and type:<br /><br />&nbsp; <strong>sh ./cudatoolkit_3.2.16_linux_64_fedora13.run</strong><br /><br />The command above will install the toolkit. When prompted choose the recommended path. You can of course choose a different one, but that complicates thing<br /><br />&nbsp;<strong>sh ./gpucomputingsdk_3.2.16_linux.run</strong><br /><br />The command above will install the SDK. Again when prompted choose the recommended path. You might get a couple of warnings during the installation (I did) but everything should be OK.<br /><br />iii) Go to your .bash_profile file (it is hidden in your Home folder) and add the following lines:<br /><br /><br /><strong>PATH=$PATH:/usr/local/cuda/bin</strong><br /><br /><strong>LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64</strong><br /><br /><strong>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64</strong><br /><br /><strong>export PATH</strong><br /><br /><strong>export LD_LIBRARY_PATH</strong><br /><br /><br />and yes there is some redundancy but not including some of the lines might give some errors during the tests. Anyway, remember to change lib64 to just lib if you have the x32 version.<br /><br />iv) REBOOT!!!<br /><br />4) Build the shared and common libs<br />i) After the reboot, go to:<br />/root/NVIDIA_GPU_Computing_SDK/shared/<br /><br />Type make to build the shared libs. These are not necessary to use CUDA, but they are required for the examples. The result should be a lib: <strong>libshrutil_x86_64.a</strong> in the lib folder.<br /><br />ii) Go to:<br /><strong>/root/NVIDIA_GPU_Computing_SDK/C/common/</strong><br />Type<br /><br /><strong>make</strong><br /><br />to build the common libs. Again, this is not necessary for CUDA, just the examples. The result should be a lib: libcutil_x86_64.a in the lib folder.<br /><br />5) Do some tests<br />The folder <strong>/root/NVIDIA_GPU_Computing_SDK/C/src/</strong> contains the examples.<br />So, go to the folder named bandwidthTest/ and in a console type<br /><br /><strong>make</strong><br /><br />This will build the example and if no errors have occured a binary will have been created in <strong>/root/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/</strong> ,&nbsp; so go to this folder and run the binary bandwidthTest. The result should be something like:<br /><br /><em>--------------------------------------------------------------</em><br /><em>./bandwidthTest Starting...</em><br /><em>&nbsp;Running on...</em><br />&nbsp;<br /><em>&nbsp;Device 0: GeForce GT 230M</em><br /><em>&nbsp;Quick Mode</em><br />&nbsp;<br /><em>&nbsp;Host to Device Bandwidth, 1 Device(s), Paged memory</em><br /><em>&nbsp;Transfer Size (Bytes)&nbsp;&nbsp;&nbsp; Bandwidth(MB/s)</em><br /><em>&nbsp;33554432&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3354.7</em><br />&nbsp;<br /><em>&nbsp;Device to Host Bandwidth, 1 Device(s), Paged memory</em><br /><em>&nbsp;Transfer Size (Bytes)&nbsp;&nbsp;&nbsp; Bandwidth(MB/s)</em><br /><em>&nbsp;33554432&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3855.3</em><br />&nbsp;<br /><em>&nbsp;Device to Device Bandwidth, 1 Device(s)</em><br /><em>&nbsp;Transfer Size (Bytes)&nbsp;&nbsp;&nbsp; Bandwidth(MB/s)</em><br /><em>&nbsp;33554432&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20571.4</em><br />&nbsp;<br /><em>&nbsp;[bandwidthTest] - Test results:</em><br /><em>&nbsp;PASSED</em><br /><em>--------------------------------------------------------------</em><br /><br />The critical part is where is says <strong>PASSED</strong> which obviously means that everything is working OK.<br /><br />6) Have some fun!<br /><br />Try compiling some of the other examples, but keep in mind that some of them have extra requirements, like the OpenGL lib etc.<br /><br />Report any problems or questions in this thread:<br /><a href="http://forum.porteus.org/viewtopic.php?f=39&amp;t=376">http://forum.porteus.org/viewtopic.php?f=39&amp;t=376</a></p></div> <div class="feed-description"><p>This is meant as an introduction on how to do some serious number crunching on the GPU using Porteus and the CUDA programming framework. We will start from the very basics, ie how to set up everything and all the way to compiling some simple examples.This post will be updated as needed. However, please keep in mind that for any questions related to CUDA programming itself you should use the NVIDIA forum instead.<br /><br />1) Requirements<br />2) Download the necessary files<br />3) Installation of the framework and the SDK<br />4) Build the shared libs<br />5) Do some tests<br />6) Have some fun!<br /><br />All the tests during the writing of this post were performed on an HP dv8-1190eo laptop running Porteusx64, 8GB RAM with a Geforce 230M GT graphics card.<br /><br />1) Requirements<br /><br />i) A laptop/PC running Porteus<br />ii) Some familiarity with C/C++ and programming in general (can't help you in this!)<br />iii) A supported&nbsp; NVIDIA graphics card. The i486 version of the driver can be found <a href="http://dl.porteus.org/i486/current/drivers/">here</a>, and the x64 version of the driver can be found <a href="http://dl.porteus.org/x86_64/current/drivers/">here</a>.<br /><br />If you are not sure whether your card is supported, a quick way to check is to see if your laptop or PC has an NVIDIA sticker that says something like: "GEFORCE with CUDA" or&nbsp; just go to<br /><a href="http://www.nvidia.com/object/cuda_gpus.html">http://www.nvidia.com/object/cuda_gpus.html</a> and check if your card is supported.&nbsp;&nbsp; <br /><br />2) Download the necessary files (take care to download the x64 versions where available)<br />You will need the following files freely available from NVIDIA's site:<br /><a href="http://developer.nvidia.com/object/gpucomputing.html">http://developer.nvidia.com/object/gpucomputing.html</a><br /><a href="http://www.nvidia.com/object/cuda_gpus.html">http://developer.nvidia.com/object/cuda_3_2_downloads.html</a><br /><br />The NVIDIA driver found at the Porteus site includes the CUDA driver, so you only need to download the Toolkit and the SDK.<br /><br />i) Grab the CUDA toolkit (it's the Fedora version, but it works OK):<br /><a href="http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/3_2_prod/toolkit/cudatoolkit_3.2.16_linux_64_fedora13.run">http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/3_2_prod/toolkit/cudatoolkit_3.2.16_linux_64_fedora13.run</a><br /><br />ii) Grab the SDK:<br /><a href="http://developer.download.nvidia.com/compute/cuda/3_2_prod/sdk/gpucomputingsdk_3.2.16_linux.run">http://developer.download.nvidia.com/compute/cuda/3_2_prod/sdk/gpucomputingsdk_3.2.16_linux.run</a><br />The SDK contains tons of examples and it is vital if you want to do any serious work.<br /><br />iii) Grab any extra Guides or Libraries you want. The GPU-accelerated LAPACK libraries could be useful but it will cover that in a future post.<br /><br />3) Installation of the framework and the SDK<br /><br />In order to install the files open a console in the folder where you downloaded them and type:<br /><br />&nbsp; <strong>sh ./cudatoolkit_3.2.16_linux_64_fedora13.run</strong><br /><br />The command above will install the toolkit. When prompted choose the recommended path. You can of course choose a different one, but that complicates thing<br /><br />&nbsp;<strong>sh ./gpucomputingsdk_3.2.16_linux.run</strong><br /><br />The command above will install the SDK. Again when prompted choose the recommended path. You might get a couple of warnings during the installation (I did) but everything should be OK.<br /><br />iii) Go to your .bash_profile file (it is hidden in your Home folder) and add the following lines:<br /><br /><br /><strong>PATH=$PATH:/usr/local/cuda/bin</strong><br /><br /><strong>LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64</strong><br /><br /><strong>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64</strong><br /><br /><strong>export PATH</strong><br /><br /><strong>export LD_LIBRARY_PATH</strong><br /><br /><br />and yes there is some redundancy but not including some of the lines might give some errors during the tests. Anyway, remember to change lib64 to just lib if you have the x32 version.<br /><br />iv) REBOOT!!!<br /><br />4) Build the shared and common libs<br />i) After the reboot, go to:<br />/root/NVIDIA_GPU_Computing_SDK/shared/<br /><br />Type make to build the shared libs. These are not necessary to use CUDA, but they are required for the examples. The result should be a lib: <strong>libshrutil_x86_64.a</strong> in the lib folder.<br /><br />ii) Go to:<br /><strong>/root/NVIDIA_GPU_Computing_SDK/C/common/</strong><br />Type<br /><br /><strong>make</strong><br /><br />to build the common libs. Again, this is not necessary for CUDA, just the examples. The result should be a lib: libcutil_x86_64.a in the lib folder.<br /><br />5) Do some tests<br />The folder <strong>/root/NVIDIA_GPU_Computing_SDK/C/src/</strong> contains the examples.<br />So, go to the folder named bandwidthTest/ and in a console type<br /><br /><strong>make</strong><br /><br />This will build the example and if no errors have occured a binary will have been created in <strong>/root/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/</strong> ,&nbsp; so go to this folder and run the binary bandwidthTest. The result should be something like:<br /><br /><em>--------------------------------------------------------------</em><br /><em>./bandwidthTest Starting...</em><br /><em>&nbsp;Running on...</em><br />&nbsp;<br /><em>&nbsp;Device 0: GeForce GT 230M</em><br /><em>&nbsp;Quick Mode</em><br />&nbsp;<br /><em>&nbsp;Host to Device Bandwidth, 1 Device(s), Paged memory</em><br /><em>&nbsp;Transfer Size (Bytes)&nbsp;&nbsp;&nbsp; Bandwidth(MB/s)</em><br /><em>&nbsp;33554432&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3354.7</em><br />&nbsp;<br /><em>&nbsp;Device to Host Bandwidth, 1 Device(s), Paged memory</em><br /><em>&nbsp;Transfer Size (Bytes)&nbsp;&nbsp;&nbsp; Bandwidth(MB/s)</em><br /><em>&nbsp;33554432&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3855.3</em><br />&nbsp;<br /><em>&nbsp;Device to Device Bandwidth, 1 Device(s)</em><br /><em>&nbsp;Transfer Size (Bytes)&nbsp;&nbsp;&nbsp; Bandwidth(MB/s)</em><br /><em>&nbsp;33554432&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20571.4</em><br />&nbsp;<br /><em>&nbsp;[bandwidthTest] - Test results:</em><br /><em>&nbsp;PASSED</em><br /><em>--------------------------------------------------------------</em><br /><br />The critical part is where is says <strong>PASSED</strong> which obviously means that everything is working OK.<br /><br />6) Have some fun!<br /><br />Try compiling some of the other examples, but keep in mind that some of them have extra requirements, like the OpenGL lib etc.<br /><br />Report any problems or questions in this thread:<br /><a href="http://forum.porteus.org/viewtopic.php?f=39&amp;t=376">http://forum.porteus.org/viewtopic.php?f=39&amp;t=376</a></p></div> Compilation and usage of custom Porteus kernel 2011-01-12T15:33:54+00:00 2011-01-12T15:33:54+00:00 https://www.porteus.org/tutorials/20-development/91-compilation-and-usage-of-custom-porteus-kernel.html <div class="feed-description"><p><strong>Before you start: make a backup of your existing Porteus installation!</strong></p> <p><span style="color: #ff0000;">WARNING: after upgrading, all kernel dependent Porteus modules like VirtualBox or proprietary GPU drivers will need to be recompiled against the&nbsp;new kernel version too.</span><br /><span style="color: #ff0000;">WARNING: If you are changing something in the kernel config and recompiling the&nbsp;kernel once again, you may need to replace all of the kernel modules (M) in the ramdisk and 000-kernel.xzm accordingly.</span></p> <p><strong>Hardware requirements:</strong><br />More than&nbsp;2GB of memory if you are running Porteus with the copy2ram cheatcode and compiling with the sources in your live filesystem, and<br />1,0GB of free space on your usb stick or hard drive if you are building up a&nbsp;maximum compatibility kernel (i.e., all options enabled), so that you can save your&nbsp;kernel sources.&nbsp; Note that if you are compiling from within Porteus, it is best to place the source code in your live filesystem (this article uses the /root/ directory) -- however, if you have 2GB of RAM or less and you are compiling a maximum compatibility kernel, it is best to place the source code on a hard drive or usb stick (formatted with a linux filesystem) while it is compiling.&nbsp; Otherwise, you may run out of room in aufs and your compile will fail.</p> <p>Let's start:</p> <h3>Section I Kernel</h3> <p>First of all make sure that Porteus development package is activated:</p> <p class="code"><strong><code>activate /mnt/sdb1/porteus/optional/005-devel.xzm</code></strong></p> <p>Download your new kernel version and unpack it somewhere:</p> <p class="code"><strong><code>wget <a href="http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.9.tar.bz2"></a><a href="http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.7.8.tar.xz">http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.7.8.tar.xz</a><a href="http://distfiles.gentoo.org/distfiles/linux-2.6.37.tar.bz2"><br /></a>tar -xf linux-3.7.8.tar.xz -C /root/</code></strong></p> <p>Get the aufs patch (you must have 'git' utility installed on your system) for 3.7.x kernel with script below:</p> <p class="code"><strong><code>$!/bin/sh<br /><br />mkdir /tmp/aufs$$<br />cd /tmp/aufs$$<br />git clone&nbsp;git://git.code.sf.net/p/aufs/aufs3-standalone aufs3-standalone.git<br />cd aufs3-standalone.git<br /># uncomment line below to get aufs for stable kernel<br />git checkout origin/aufs3.7<br /># uncomment line below to get aufs for latest -rc kernel<br />#git checkout origin/aufs3.x-rcN<br />mkdir ../a ../b<br />cp -r {Documentation,fs,include} ../b<br />rm ../b/include/uapi/linux/Kbuild 2&gt;/dev/null || rm ../b/include/linux/Kbuild<br />cd ..<br />diff -rupN a/ b/ &gt; /root/linux-3.7.8/aufs.patch<br /><br /># extra patches:<br />cat aufs3-standalone.git/*.patch &gt;&gt; /root/linux-3.7.8/aufs.patch<br /><br /># cleanup:<br />rm -r /tmp/aufs$$</code></strong></p> <p>(in case of using different kernel version plase change 'git checkout origin/aufs3.7' command to for example 'git checkout origin/aufs3.9')</p> <p>Patch the kernel:</p> <p class="code"><strong><code>cd /root/linux-3.7.8<br />patch -p1 &lt; aufs.patch</code></strong></p> <p>Once you have the kernel patched, you need to configure it. The best way is to use the old Porteus kernel config file. The configs for Porteus are compiled as a kernel module, so you have to modprobe it and unzip it to the directory where your new kernel sources are before you can apply them:</p> <p class="code"><strong><code>modprobe configs &amp;&amp; zcat /proc/config.gz &gt; .config<br />make oldconfig</code></strong></p> <p>If you are not sure which option to choose, it is&nbsp;best to keep the enter key&nbsp;pressed (default options are usually safe).</p> <p>Check if your configuration is correct:</p> <p class="code"><strong><code>make menuconfig</code></strong></p> <p>Navigate to "File systems" menu and make sure that FUSE will be compiled in (*). Then go to -&gt; "Miscellaneous filesystems". Aufs and Squashfs must also be compiled in (*), as well as xz compression for Squashfs (*)</p> <p>Make sure that kernel supports initrd compressed with xz.<br />Mark other drivers and features as you like <img title="Very Happy" alt=":D" src="forum/images/smilies/biggrin.gif" border="0" /></p> <p>Now it's time to build a kernel, so:</p> <p class="code"><strong><code>make &amp;&amp; make modules_install &amp;&amp; make firmware_install</code></strong></p> <p>It's going to&nbsp;take a long time, so you'd&nbsp;better grab a beer&nbsp;<img title="Smile" alt=":)" src="forum/images/smilies/smile.gif" border="0" /></p> <p>(Note:&nbsp; If you have a dual core processor, you can run this with 'make -j3' to speed things up a bit)</p> <p>If no errors are reported you can copy your shiny new kernel to the Porteus /boot directory:</p> <p class="code"><strong><code>cp arch/x86/boot/bzImage /mnt/sdb1/boot/syslinux/vmlinuz</code></strong></p> <p>Comments:</p> <ol style="text-align: left;"> <li>It's a good idea it to store your compiled sources somewhere (it's around 1GB when uncompressed), in case you need to add or change something.&nbsp; If you have a backup you won't have to go through the whole process once again, and compilation will be much faster.</li> <li>If you use Porteus on different machines try to compile as many drivers as possible as modules&nbsp;(M), so the kernel won't be so bloated&nbsp;(my gentoo kernel is only 2MB when stripped to the&nbsp;maximum)</li> <li>The best place for compilation is RAM (fastest). Boot porteus without changes= cheatcode or use tmpfs instead: <a href="http://en.wikipedia.org/wiki/Tmpfs"></a><a href="http://en.wikipedia.org/wiki/Tmpfs">http://en.wikipedia.org/wiki/Tmpfs</a></li> </ol> <h3>&nbsp;</h3> <h3>Section II Updating 000-kernel.xzm module with new drivers</h3> <h3>&nbsp;</h3> <p>Now we need to get rid of the old drivers from 000-kernel.xzm, so:</p> <h3>&nbsp;</h3> <p class="code"><strong><code>cp -r /mnt/live/memory/images/000-kernel.xzm/ /root/000-kernel<br />rm -r /root/000-kernel/lib/modules/*<br />rm -r /root/000-kernel/lib/firmware/*<br />cp -r /mnt/live/memory/changes/lib/firmware /root/000-kernel/lib<br />cp -r /mnt/live/memory/changes/lib/modules/your-new-kernel-version /root/000-kernel/lib/modules<br />rm /mnt/sdb1/porteus/base/000-kernel.xzm<br />dir2xzm /root/000-kernel/ /mnt/sdb1/porteus/base/000-kernel.xzm</code></strong></p> <p>Reboot and enjoy the new kernel :)</p> <h3>&nbsp;</h3> <h3>Section III Updating initial ramdisk for pxe boot</h3> <p>To create new initrdpxe.xz please use following script:</p> <p class="code"><strong><code>#!/bin/sh<br /><br />cd `pwd`<br />mkdir pxe<br />cd pxe<br />cp -a --parents /lib/modules/`uname -r`/kernel/drivers/net/ethernet .<br />for x in dca mii libphy sungem_phy ssb uio crc-ccitt; do<br />&nbsp; pth="/lib/modules/`uname -r`/$(grep $x.ko: /lib/modules/`uname -r`/modules.dep | cut -d: -f1)"<br />&nbsp; cp -a --parents $pth .<br />done<br />depmod -b .<br />find | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 &gt; ../../initrdpxe.xz<br />cd ..<br />rm -r pxe<br />mv ../initrdpxe.xz .<br />mv /root/initrd.xz /mnt/sdb1/boot/syslinux/pxelinux.cfg/initrdpxe.xz</code></strong></p> <p>Good luck!</p></div> <div class="feed-description"><p><strong>Before you start: make a backup of your existing Porteus installation!</strong></p> <p><span style="color: #ff0000;">WARNING: after upgrading, all kernel dependent Porteus modules like VirtualBox or proprietary GPU drivers will need to be recompiled against the&nbsp;new kernel version too.</span><br /><span style="color: #ff0000;">WARNING: If you are changing something in the kernel config and recompiling the&nbsp;kernel once again, you may need to replace all of the kernel modules (M) in the ramdisk and 000-kernel.xzm accordingly.</span></p> <p><strong>Hardware requirements:</strong><br />More than&nbsp;2GB of memory if you are running Porteus with the copy2ram cheatcode and compiling with the sources in your live filesystem, and<br />1,0GB of free space on your usb stick or hard drive if you are building up a&nbsp;maximum compatibility kernel (i.e., all options enabled), so that you can save your&nbsp;kernel sources.&nbsp; Note that if you are compiling from within Porteus, it is best to place the source code in your live filesystem (this article uses the /root/ directory) -- however, if you have 2GB of RAM or less and you are compiling a maximum compatibility kernel, it is best to place the source code on a hard drive or usb stick (formatted with a linux filesystem) while it is compiling.&nbsp; Otherwise, you may run out of room in aufs and your compile will fail.</p> <p>Let's start:</p> <h3>Section I Kernel</h3> <p>First of all make sure that Porteus development package is activated:</p> <p class="code"><strong><code>activate /mnt/sdb1/porteus/optional/005-devel.xzm</code></strong></p> <p>Download your new kernel version and unpack it somewhere:</p> <p class="code"><strong><code>wget <a href="http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.9.tar.bz2"></a><a href="http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.7.8.tar.xz">http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.7.8.tar.xz</a><a href="http://distfiles.gentoo.org/distfiles/linux-2.6.37.tar.bz2"><br /></a>tar -xf linux-3.7.8.tar.xz -C /root/</code></strong></p> <p>Get the aufs patch (you must have 'git' utility installed on your system) for 3.7.x kernel with script below:</p> <p class="code"><strong><code>$!/bin/sh<br /><br />mkdir /tmp/aufs$$<br />cd /tmp/aufs$$<br />git clone&nbsp;git://git.code.sf.net/p/aufs/aufs3-standalone aufs3-standalone.git<br />cd aufs3-standalone.git<br /># uncomment line below to get aufs for stable kernel<br />git checkout origin/aufs3.7<br /># uncomment line below to get aufs for latest -rc kernel<br />#git checkout origin/aufs3.x-rcN<br />mkdir ../a ../b<br />cp -r {Documentation,fs,include} ../b<br />rm ../b/include/uapi/linux/Kbuild 2&gt;/dev/null || rm ../b/include/linux/Kbuild<br />cd ..<br />diff -rupN a/ b/ &gt; /root/linux-3.7.8/aufs.patch<br /><br /># extra patches:<br />cat aufs3-standalone.git/*.patch &gt;&gt; /root/linux-3.7.8/aufs.patch<br /><br /># cleanup:<br />rm -r /tmp/aufs$$</code></strong></p> <p>(in case of using different kernel version plase change 'git checkout origin/aufs3.7' command to for example 'git checkout origin/aufs3.9')</p> <p>Patch the kernel:</p> <p class="code"><strong><code>cd /root/linux-3.7.8<br />patch -p1 &lt; aufs.patch</code></strong></p> <p>Once you have the kernel patched, you need to configure it. The best way is to use the old Porteus kernel config file. The configs for Porteus are compiled as a kernel module, so you have to modprobe it and unzip it to the directory where your new kernel sources are before you can apply them:</p> <p class="code"><strong><code>modprobe configs &amp;&amp; zcat /proc/config.gz &gt; .config<br />make oldconfig</code></strong></p> <p>If you are not sure which option to choose, it is&nbsp;best to keep the enter key&nbsp;pressed (default options are usually safe).</p> <p>Check if your configuration is correct:</p> <p class="code"><strong><code>make menuconfig</code></strong></p> <p>Navigate to "File systems" menu and make sure that FUSE will be compiled in (*). Then go to -&gt; "Miscellaneous filesystems". Aufs and Squashfs must also be compiled in (*), as well as xz compression for Squashfs (*)</p> <p>Make sure that kernel supports initrd compressed with xz.<br />Mark other drivers and features as you like <img title="Very Happy" alt=":D" src="forum/images/smilies/biggrin.gif" border="0" /></p> <p>Now it's time to build a kernel, so:</p> <p class="code"><strong><code>make &amp;&amp; make modules_install &amp;&amp; make firmware_install</code></strong></p> <p>It's going to&nbsp;take a long time, so you'd&nbsp;better grab a beer&nbsp;<img title="Smile" alt=":)" src="forum/images/smilies/smile.gif" border="0" /></p> <p>(Note:&nbsp; If you have a dual core processor, you can run this with 'make -j3' to speed things up a bit)</p> <p>If no errors are reported you can copy your shiny new kernel to the Porteus /boot directory:</p> <p class="code"><strong><code>cp arch/x86/boot/bzImage /mnt/sdb1/boot/syslinux/vmlinuz</code></strong></p> <p>Comments:</p> <ol style="text-align: left;"> <li>It's a good idea it to store your compiled sources somewhere (it's around 1GB when uncompressed), in case you need to add or change something.&nbsp; If you have a backup you won't have to go through the whole process once again, and compilation will be much faster.</li> <li>If you use Porteus on different machines try to compile as many drivers as possible as modules&nbsp;(M), so the kernel won't be so bloated&nbsp;(my gentoo kernel is only 2MB when stripped to the&nbsp;maximum)</li> <li>The best place for compilation is RAM (fastest). Boot porteus without changes= cheatcode or use tmpfs instead: <a href="http://en.wikipedia.org/wiki/Tmpfs"></a><a href="http://en.wikipedia.org/wiki/Tmpfs">http://en.wikipedia.org/wiki/Tmpfs</a></li> </ol> <h3>&nbsp;</h3> <h3>Section II Updating 000-kernel.xzm module with new drivers</h3> <h3>&nbsp;</h3> <p>Now we need to get rid of the old drivers from 000-kernel.xzm, so:</p> <h3>&nbsp;</h3> <p class="code"><strong><code>cp -r /mnt/live/memory/images/000-kernel.xzm/ /root/000-kernel<br />rm -r /root/000-kernel/lib/modules/*<br />rm -r /root/000-kernel/lib/firmware/*<br />cp -r /mnt/live/memory/changes/lib/firmware /root/000-kernel/lib<br />cp -r /mnt/live/memory/changes/lib/modules/your-new-kernel-version /root/000-kernel/lib/modules<br />rm /mnt/sdb1/porteus/base/000-kernel.xzm<br />dir2xzm /root/000-kernel/ /mnt/sdb1/porteus/base/000-kernel.xzm</code></strong></p> <p>Reboot and enjoy the new kernel :)</p> <h3>&nbsp;</h3> <h3>Section III Updating initial ramdisk for pxe boot</h3> <p>To create new initrdpxe.xz please use following script:</p> <p class="code"><strong><code>#!/bin/sh<br /><br />cd `pwd`<br />mkdir pxe<br />cd pxe<br />cp -a --parents /lib/modules/`uname -r`/kernel/drivers/net/ethernet .<br />for x in dca mii libphy sungem_phy ssb uio crc-ccitt; do<br />&nbsp; pth="/lib/modules/`uname -r`/$(grep $x.ko: /lib/modules/`uname -r`/modules.dep | cut -d: -f1)"<br />&nbsp; cp -a --parents $pth .<br />done<br />depmod -b .<br />find | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 &gt; ../../initrdpxe.xz<br />cd ..<br />rm -r pxe<br />mv ../initrdpxe.xz .<br />mv /root/initrd.xz /mnt/sdb1/boot/syslinux/pxelinux.cfg/initrdpxe.xz</code></strong></p> <p>Good luck!</p></div>