Difference between revisions of "Bering-uClibc 4.x - User Guide - Advanced Topics - Modifying initrd.lrp"
Davidmbrooke (Talk | contribs) m (Navigation link tidyups) |
Davidmbrooke (Talk | contribs) (Added note about cpio being added to Bering-uClibc 4.1) |
||
Line 21: | Line 21: | ||
==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 | + | 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. |
The contents must therefore be manipulated using the <tt>cpio</tt> command. | The contents must therefore be manipulated using the <tt>cpio</tt> command. | ||
− | The cpio command is not installed as standard on a [[Bering-uClibc 4. | + | The <tt>cpio</tt> command is not installed as standard on a [[Bering-uClibc 4.0]] machine so the file processing described below should be performed using another Linux installation. |
− | Another consideration is that <code class="filename">initrd</code> contains the <code class="filename">dev/console</code> device file, which can only be created (during unpacking) by the "root" user - even fakeroot is not good enough. | + | |
+ | '''Note:''' This has been fixed for [[Bering-uClibc 4.1]] and the <tt>cpio</tt> command has been enabled in BusyBox. See [http://sourceforge.net/apps/trac/leaf/ticket/26 Trac ticket #26]. | ||
+ | |||
+ | Another consideration is that <code class="filename">initrd</code> contains the <code class="filename">dev/console</code> device file, which can only be created (during unpacking) by the "root" user - even <tt>fakeroot</tt> is not good enough. | ||
The following assumes the original <code class="filename">initrd.lrp</code> is present in the starting directory and you are logged in as "root". | The following assumes the original <code class="filename">initrd.lrp</code> is present in the starting directory and you are logged in as "root". | ||
Line 77: | Line 80: | ||
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: | ||
− | find . -print | cpio -o -H newc | gzip -9 -c - > ../initrd.new | + | find . -print | cpio -o -H newc | gzip -9 -c - > ../initrd.new |
cd .. | cd .. | ||
mv initrd.new initrd.lrp | mv initrd.new initrd.lrp |
Revision as of 16:47, 25 June 2011
Modifying initrd.lrp | ||
---|---|---|
Prev | Bering-uClibc 4.x - User Guide |
Contents
Introduction
In common with many other Linux distributions, Bering-uClibc 4.x uses an Initial RAM Disk (initrd) file 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.
Any initrd
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 4.x initrd.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.
Unpacking the original initrd.lrp
Although the Bering-uClibc 4.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.
The cpio command is not installed as standard on a Bering-uClibc 4.0 machine so the file processing described below should be performed using another Linux installation.
Note: This has been fixed for Bering-uClibc 4.1 and the cpio command has been enabled in BusyBox. See Trac ticket #26.
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 modules/ *.ko sbin/ usr/ sbin/ var/ lib/ lrpkg/ initrd.help initrd.modules initrd.version root.linuxrc root.helper log/
Modifying the Contents
Adding kernel Modules
One of the most common requirements is to add extra kernel Module files under lib/modules/
.
The relevant .ko
files should be extracted from modules.tgz
(which can be found alongside initrd.lrp
on any Bering-uClibc 4.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/initrd.modules
.
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 4.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 4.x development system (see Bering-uClibc 4.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
Prev | Up |