Difference between revisions of "Bering-uClibc 5.x - User Guide - Advanced Topics - Modifying initrd.lrp"

From bering-uClibc
Jump to: navigation, search
(Unpacking the original initrd.lrp)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{| summary="Navigation header" width="100%"
 
{| summary="Navigation header" width="100%"
! colspan="3" align="center" | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Modifying initrd.lrp|Modifying initrd.lrp]]
+
! colspan="3" align="center" | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Modifying initrd.lrp|Modifying initrd.lrp and initmod.lrp]]
 
|-
 
|-
| width="20%" align="left"  | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Setting Up a HTTP Anti Virus Proxy|Prev]]
+
| width="20%" align="left"  | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Setting Up Ad blocking with dnsmasq|Prev]]
 
! width="60%" align="center" | [[Bering-uClibc 5.x - User Guide]]
 
! width="60%" align="center" | [[Bering-uClibc 5.x - User Guide]]
 
| width="20%" align="right"  |  
 
| width="20%" align="right"  |  
Line 26: Line 26:
 
==Modify <code class="filename">initrd.lrp</code>==
 
==Modify <code class="filename">initrd.lrp</code>==
 
===Unpacking the original <code class="filename">initrd.lrp</code>===
 
===Unpacking the original <code class="filename">initrd.lrp</code>===
Although the [[Bering-uClibc 4.x]] <code class="filename">initrd.lrp</code> file has a <code class="filename">.lrp</code> extension it is not the same as the other <code class="filename">.lrp</code> files. The standard Package <code class="filename">.lrp</code> files are gzipped tar archives whereas <code class="filename">initrd.lrp</code> is a gzipped [http://en.wikipedia.org/wiki/Cpio cpio] archive.
+
Although the [[Bering-uClibc 5.x]] <code class="filename">initrd.lrp</code> file has a <code class="filename">.lrp</code> extension it is not the same as the other <code class="filename">.lrp</code> files. The standard Package <code class="filename">.lrp</code> files are gzipped tar archives whereas <code class="filename">initrd.lrp</code> is a gzipped [http://en.wikipedia.org/wiki/Cpio cpio] archive.
 
The contents must therefore be manipulated using the <tt>cpio</tt> command.
 
The contents must therefore be manipulated using the <tt>cpio</tt> command.
  
Line 50: Line 50:
 
  lib/
 
  lib/
 
     *.so
 
     *.so
    modules/
 
        *.ko
 
 
  sbin/
 
  sbin/
 
  usr/
 
  usr/
Line 65: Line 63:
 
     log/
 
     log/
  
==Modifying the Contents==
+
===Modifying the Contents===
===Adding kernel Modules===
+
One of the most common requirements is to add extra kernel Module files under <code class="filename">lib/modules/</code>.
+
The relevant <code class="filename">.ko</code> files should be extracted from <code class="filename">modules.tgz</code> (which can be found alongside <code class="filename">initrd.lrp</code> on any [[Bering-uClibc 4.x]] disk Image) and copied into the <code class="filename">lib/modules/</code> directory.
+
  
The names of additional kernel Module files should also be added to the list in file <code class="filename">var/lib/lrpkg/initrd.modules</code>.
+
====Editing the <code class="filename">init</code> script====
 
+
===Editing the <code class="filename">init</code> script===
+
 
Another fairly common requirement is to change the contents of file <code class="filename">init</code>, which is actually a symbolic link to <code class="filename">var/lib/lrpkg/root.linuxrc</code>.
 
Another fairly common requirement is to change the contents of file <code class="filename">init</code>, which is actually a symbolic link to <code class="filename">var/lib/lrpkg/root.linuxrc</code>.
This is a Bourne shell script which controls the fundamental initialization of the [[Bering-uClibc 4.x]] system.
+
This is a Bourne shell script which controls the fundamental initialization of the [[Bering-uClibc 5.x]] system.
 
Be careful making changes; if there are any syntax errors the system will fail to boot.
 
Be careful making changes; if there are any syntax errors the system will fail to boot.
  
==Generating the Modified <code class="filename">initrd.lrp</code>==
+
===Generating the Modified <code class="filename">initrd.lrp</code>===
The standard <code class="filename">initrd.lrp</code> is generated by the <code class="filename">buildpacket.pl</code> script, part of the [[Bering-uClibc 4.x]] development system (see [[Bering-uClibc 4.x - Developer Guide]]).
+
The standard <code class="filename">initrd.lrp</code> is generated by the <code class="filename">buildpacket.pl</code> script, part of the [[Bering-uClibc 5.x]] development system (see [[Bering-uClibc 5.x - Developer Guide]]).
 
The following commands replicate the logic in <code class="filename">buildpacket.pl</code>.
 
The following commands replicate the logic in <code class="filename">buildpacket.pl</code>.
 
As with the unpacking step they should be run as "root", in the <code class="filename">tmpdir</code> directory from before:
 
As with the unpacking step they should be run as "root", in the <code class="filename">tmpdir</code> directory from before:
Line 84: Line 77:
 
  cd ..
 
  cd ..
 
  mv initrd.new initrd.lrp
 
  mv initrd.new initrd.lrp
 +
 +
 +
 +
==Modify <code class="filename">initmod.lrp</code>==
 +
====Unpacking the original <code class="filename">initmod.lrp</code>====
 +
Although the [[Bering-uClibc 5.x]] <code class="filename">initmod.lrp</code> file has a <code class="filename">.lrp</code> extension it is not the same as the other <code class="filename">.lrp</code> files. The standard Package <code class="filename">.lrp</code> files are gzipped tar archives whereas <code class="filename">initmod.lrp</code> is a gzipped [http://en.wikipedia.org/wiki/Cpio cpio] archive.
 +
The contents must therefore be manipulated using the <tt>cpio</tt> command.
 +
 +
The following assumes the original <code class="filename">initmod.lrp</code> is present in the starting directory and you are logged in as "root".
 +
mv initmod.lrp initmod.old
 +
mkdir tmpdir
 +
cd tmpdir
 +
zcat ../initmod.old | cpio -i
 +
This will result in a set of files and directories under the current directory. Specifically:
 +
 +
lib/
 +
    modules/
 +
        *.ko.gz
 +
  var/
 +
    lib/
 +
        lrpkg/
 +
            initmod.help
 +
            initmod.modules
 +
            initmod.version
 +
            initmod.license
 +
 +
===Modifying the Contents===
 +
====Adding kernel Modules====
 +
One of the most common requirements is to add extra kernel Module files under <code class="filename">lib/modules/</code>.
 +
The required way to do that, differs between LEAF Bering-uClibc versions up to 5.2.x and starting with 5.2.x.
 +
 +
=====LEAF Bering-uClibc versions up to 5.1=====
 +
The relevant <code class="filename">.ko.gz</code> files should be extracted from <code class="filename">modules.tgz</code> (which can be found alongside <code class="filename">initmod.lrp</code> on any [[Bering-uClibc 5.0.x/5.1.x]] disk Image) and copied into the <code class="filename">lib/modules/</code> directory.
 +
 +
The names of additional kernel Module files should also be added to the list in file <code class="filename">var/lib/lrpkg/initmod.modules</code>.
 +
 +
=====LEAF Bering-uClibc versions 5.2 and later=====
 +
The relevant <code class="filename">.ko.gz</code> files should be extracted from <code class="filename">modules.sqfs</code> (which can be found alongside <code class="filename">initmod.lrp</code> on any [[Bering-uClibc 5.2.x]] disk Image) and copied into the <code class="filename">lib/modules/</code> directory.
 +
 +
To extract modules*.sqfs run
 +
mount -t squashfs [path]modules-*.sqfs [tempdir]
 +
The names of additional kernel Module files should also be added to the list in file <code class="filename">var/lib/lrpkg/initmod.modules</code>.
 +
 +
====Removing kernel Modules====
 +
To save space and memory you may want to remove unneeded modules from <code class="filename">lib/modules/</code>.
 +
After deleting the module in <code class="filename">lib/modules/</code>, the name of the kernel Module should also be removed from the list in file <code class="filename">var/lib/lrpkg/initrd.modules</code>.
 +
 +
===Generating the Modified <code class="filename">initmod.lrp</code>===
 +
The standard <code class="filename">initmod.lrp</code> is generated by the <code class="filename">buildpacket.pl</code> script, part of the [[Bering-uClibc 5.x]] development system (see [[Bering-uClibc 5.x - Developer Guide]]).
 +
The following commands replicate the logic in <code class="filename">buildpacket.pl</code>.
 +
As with the unpacking step they should be run as "root", in the <code class="filename">tmpdir</code> directory from before:
 +
find . -print | cpio -o -H newc | gzip -9 -c  -  > ../initmod.new
 +
cd ..
 +
mv initmod.new initmod.lrp
 +
  
  
 
----
 
----
 
{| summary="Navigation footer" width="100%"
 
{| summary="Navigation footer" width="100%"
| width="40%" align="left"  | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Setting Up a HTTP Anti Virus Proxy|Prev]]
+
| width="40%" align="left"  | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Setting Up Ad blocking with dnsmasq|Prev]]
 
| width="20%" align="center" | [[Bering-uClibc 5.x - User Guide - Advanced Topics|Up]]
 
| width="20%" align="center" | [[Bering-uClibc 5.x - User Guide - Advanced Topics|Up]]
 
| width="40%" align="right"  |  
 
| width="40%" align="right"  |  

Latest revision as of 20:16, 16 November 2016

Modifying initrd.lrp and initmod.lrp
Prev Bering-uClibc 5.x - User Guide


Introduction

In common with many other Linux distributions, LEAF Bering-uClibc uses the initrd scheme (Initial RAM Disk) in conjunction with a kernel image as part of the Linux boot process. Further information about the role of the Initial RAM Disk can be found on Wikipedia.

Beginning with Bering-uClibc 5.x the previously single initrd.lrp Package has been split into two Packages:

  • initrd.lrp implementing /linuxrc and a minimal shell along with some essential user-space utilities
  • initmod.lrp providing the kernel modules.

Any initrd (respectively initmod) file is a compromise between:

  1. Making it small, so that it is quick to download and so that it reduces the requirement for disk space.
  2. Making it large, containing a wide range of kernel Modules (device drivers) and other files for maximum compatibility with all hardware plaforms.

The Bering-uClibc 5.x initmod.lrp attempts to support the most common hardware platforms but in some cases you may find that it does not support your hardware and that additional files need to be added.

Alternatively you may wish to remove files not required for your particular hardware platform, especially for embedded devices with limited storage capacity (initmod.lrp). Or perhaps you may want to make changes to the user-space utilities ( initrd.lrp). Both are modified in the same manner.

Modify initrd.lrp

Unpacking the original initrd.lrp

Although the Bering-uClibc 5.x initrd.lrp file has a .lrp extension it is not the same as the other .lrp files. The standard Package .lrp files are gzipped tar archives whereas initrd.lrp is a gzipped cpio archive. The contents must therefore be manipulated using the cpio command.

Another consideration is that initrd contains the dev/console device file, which can only be created (during unpacking) by the "root" user - even fakeroot is not good enough.

The following assumes the original initrd.lrp is present in the starting directory and you are logged in as "root".

mv initrd.lrp initrd.old
mkdir tmpdir
cd tmpdir
zcat ../initrd.old | cpio -i

This will result in a set of files and directories under the current directory. Specifically:

bin/
    busybox
boot/
    etc/
        README
        modules
    lib/
        modules/
dev
    console
init -> var/lib/lrpkg/root.linuxrc
lib/
    *.so
sbin/
usr/
    sbin/
var/
    lib/
        lrpkg/
            initrd.help
            initrd.modules
            initrd.version
            root.linuxrc
            root.helper
    log/

Modifying the Contents

Editing the init script

Another fairly common requirement is to change the contents of file init, which is actually a symbolic link to var/lib/lrpkg/root.linuxrc. This is a Bourne shell script which controls the fundamental initialization of the Bering-uClibc 5.x system. Be careful making changes; if there are any syntax errors the system will fail to boot.

Generating the Modified initrd.lrp

The standard initrd.lrp is generated by the buildpacket.pl script, part of the Bering-uClibc 5.x development system (see Bering-uClibc 5.x - Developer Guide). The following commands replicate the logic in buildpacket.pl. As with the unpacking step they should be run as "root", in the tmpdir directory from before:

find . -print | cpio -o -H newc | gzip -9 -c  -  > ../initrd.new
cd ..
mv initrd.new initrd.lrp


Modify initmod.lrp

Unpacking the original initmod.lrp

Although the Bering-uClibc 5.x initmod.lrp file has a .lrp extension it is not the same as the other .lrp files. The standard Package .lrp files are gzipped tar archives whereas initmod.lrp is a gzipped cpio archive. The contents must therefore be manipulated using the cpio command.

The following assumes the original initmod.lrp is present in the starting directory and you are logged in as "root".

mv initmod.lrp initmod.old
mkdir tmpdir
cd tmpdir
zcat ../initmod.old | cpio -i

This will result in a set of files and directories under the current directory. Specifically:

lib/
   modules/
        *.ko.gz
 var/
    lib/
        lrpkg/
            initmod.help
            initmod.modules
            initmod.version
            initmod.license

Modifying the Contents

Adding kernel Modules

One of the most common requirements is to add extra kernel Module files under lib/modules/. The required way to do that, differs between LEAF Bering-uClibc versions up to 5.2.x and starting with 5.2.x.

LEAF Bering-uClibc versions up to 5.1

The relevant .ko.gz files should be extracted from modules.tgz (which can be found alongside initmod.lrp on any Bering-uClibc 5.0.x/5.1.x disk Image) and copied into the lib/modules/ directory.

The names of additional kernel Module files should also be added to the list in file var/lib/lrpkg/initmod.modules.

LEAF Bering-uClibc versions 5.2 and later

The relevant .ko.gz files should be extracted from modules.sqfs (which can be found alongside initmod.lrp on any Bering-uClibc 5.2.x disk Image) and copied into the lib/modules/ directory.

To extract modules*.sqfs run

mount -t squashfs [path]modules-*.sqfs [tempdir]

The names of additional kernel Module files should also be added to the list in file var/lib/lrpkg/initmod.modules.

Removing kernel Modules

To save space and memory you may want to remove unneeded modules from lib/modules/. After deleting the module in lib/modules/, the name of the kernel Module should also be removed from the list in file var/lib/lrpkg/initrd.modules.

Generating the Modified initmod.lrp

The standard initmod.lrp is generated by the buildpacket.pl script, part of the Bering-uClibc 5.x development system (see Bering-uClibc 5.x - Developer Guide). The following commands replicate the logic in buildpacket.pl. As with the unpacking step they should be run as "root", in the tmpdir directory from before:

find . -print | cpio -o -H newc | gzip -9 -c  -  > ../initmod.new
cd ..
mv initmod.new initmod.lrp



Prev Up