User:Zulu Foxtrott/GentooOnARM/EasyInstall/Initramfs

Optional: Building an initramfs
If the main partition has been encrypted, building an initial RAM file system (initramfs) is required.

Another common reason for building an initramfs is when important file system locations (like or ) are on separate partitions.

As outlined in the section before an initramfs provides a minimal root filesystem and some tools (applications) to the kernel. It usually takes care of making the "real" root filesystem accessible. Depending on the tools included, different tasks can be performed. Thus it's possible to configure it not only to mount separate partitions or decrypt devices but also to do something else.

First, create a directory for the initramfs:

Creating the intiramfs filesystem structure
Create a minimal root filesystem structure in that directory, using with the command line argument   to allow that all necessary parent directories are created as well:

TODO: compare

Creating necessary device nodes
The initramfs' directory needs to be populated with the necessary device nodes. Device nodes are block or character special files - files that can generate or receive data. They can be created with the command. The argument  followed by the file permissions allows to set these correctly (in the example the numeric notation is used). Following that is the name of the new device node before its type ( for character devices and   for block devices) is defined. This is concluded by the major and minor device numbers. (The major number identifies the device type and thus the driver and the minor number identifies the device served by the driver.)

Create the required character device nodes:

After creating the tty device node, its group ownership should be changed:

This is not necessary for the console device node, but its file permissions are more restricted:

Finally create the required block device node with the correct permissions and adjust the group ownership as recommended:

Now that all necessary device nodes have been created, it is time to add some tools so the initramfs can actually serve its purpose.

Adding tools (applications)
Any application that needs to be executed before the "real" root filesystem is available to the kernel must be present on the initramfs. In the best case these tools are included in the stage tarball that has been downloaded and unpacked earlier in the installation process. Sometimes, however, when this is not the case, it may become necessary to be creative. If the host system's and the target system's architecture are identical they could be installed on the host system and copied from there, for instance. In any case the simplest approach is to use only statically linked binaries, which means only one file will have to be copied over to the initramfs instead of many files to different directories of the initramfs.

busybox cryptsetup

script
kernel compilation still difficult?

The initramfs will be stored in. The resulting file can be found by simply listing the files starting with initramfs: