Bering-uClibc 4.x - User Guide - Advanced Topics - Modifying initrd.lrp
|Prev||Bering-uClibc 4.x - User Guide|
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.
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
Although the Bering-uClibc 4.x
initrd.lrp file has a
.lrp extension it is not quite 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.x machine so the file processing described below should be performed using another Linux installation.
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
.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
The names of additional kernel Module files should also be added to the list in file
Another fairly common requirement is to change the contents of file
init, which is actually a symbolic link to
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 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
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