Difference between revisions of "Bering-uClibc 5.x - User Guide - Advanced Topics - Modifying initrd.lrp"
m (→Unpacking the original initrd.lrp typo) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
! colspan="3" align="center" | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Modifying initrd.lrp|Modifying initrd.lrp and initmod.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 | + | | 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 106: | Line 106: | ||
====Adding kernel Modules==== | ====Adding kernel Modules==== | ||
One of the most common requirements is to add extra kernel Module files under <code class="filename">lib/modules/</code>. | 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.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.x]] disk Image) and copied into the <code class="filename">lib/modules/</code> directory. | + | 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/ | + | 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==== | ====Removing kernel Modules==== | ||
Line 126: | Line 136: | ||
---- | ---- | ||
{| summary="Navigation footer" width="100%" | {| summary="Navigation footer" width="100%" | ||
− | | width="40%" align="left" | [[Bering-uClibc 5.x - User Guide - Advanced Topics - Setting Up | + | | 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:
- Making it small, so that it is quick to download and so that it reduces the requirement for disk space.
- 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 |