Bering-uClibc 4.x - User Guide - Advanced Topics - Modifying initrd.lrp

From bering-uClibc
Jump to: navigation, search
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.

Any initrd 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 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:

init -> var/lib/lrpkg/root.linuxrc

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 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  -  > ../
cd ..
mv initrd.lrp

Prev Up