Packaging the RFS as an ext2 Image in LinuxLink Classic
After you have collected the packages for an initrd, you need to package it as a gzipped ext2 filesystem image. You can do this by using Target Configurator, or from the command line.
Creating an ext2 Image Using Target Configurator
This section assumes that you are familiar with the RFS Editor and the Kernel Configuration Editor; if not, please refer to the Target Configurator documentation. This documentation is available on LinuxLink tc guide , in the /doc/user_guide_tc.pdf file installed with Target Configurator, or in the online documentation (choose Help > Help Contents from the main workbench menu) .
To create an ext2 image using Target Configurator:
- Open the RFS Editor, and click on the Image Options tab.
- Select Create RFS image and choose Initial RAM Disk (ext2) as the image type.
- Enter the uncompressed size of the image in the Image Size field. It needs to be large enough to hold the files in your RFS, plus any overhead from filesystem structure or files created in post-installation scripts.
When you next build the RFS, a file called initrd.image.gz will be created in the root of your project. This is the initrd image.
For many bootloaders, the kernel and the initrd are kept as separate files. Usually, both are placed in a location accessible to the bootloader. When the bootloader starts the kernel, it passes the kernel a pointer to the location of the initrd. In this case you can take the image created in the packaging step without further alteration. However, some bootloaders (particularly those that are not Linux-specific) do not contain a way to pass the initrd location to the kernel. In these cases, you can load the initrd image separately, or possibly combine the kernel and initrd into one file.
Loading the initrd Separately
If the bootloader does not have a way to pass the initrd location to the kernel, you can load the initrd image separately by using a bootloader command. Make sure that the kernel has initial RAM disk support enabled, and that the initial RAM disk image fits in the amount of available memory.
Combining the Kernel and initrd into One File
In some cases, it might be possible to combine the kernel and initrd into a single file. Special code is inserted at the beginning of the kernel to locate the initrd without help from the bootloader. For some architectures, combining the kernel and initrd into a single file is performed by the kernel Makefile after building the kernel. Instead of calling the usual target (for example, zImage) you would call an special initrd target, such as zImage-initrd. This target will automatically build the kernel and combine it with an initrd image picked up from a pre-defined location.
When you next build the project, it will produce a kernel and initrd combined in a single file. You can then provide this file to your bootloader in the normal way.
Creating an ext2 Image From the Command Line
Note
Refer to Configuring the Kernel to Support RAM Disks for an explanation of the kernel configuration options needed when you are using an initrd.
Use the following procedure to create an ext2 initrd image from the command line:
-
Create a blank file to hold the contents of your RAM disk. This file will become the RAM disk image file:
# dd if=/dev/zero of=ramdisk.image bs=1024 count=8192
This example creates a zeroed-out 8 MB output file called ramdisk.image. You must use a block size (bs option) of 1024 bytes (1 KB); the ext2 filesystem currently only supports 1 KB blocks. If you need a larger or smaller RAM disk, adjust the count option and the kernel configuration accordingly.
- Use one of the following procedures to create and mount the image:
- Use mkfs and mount -o.
- Use losetup, mke2fs, and mount /dev/loop0.
- If you are working on a Windows machine, use genext2fs.