There are cases the initramfs should be used for Linux root filesystem. Please see the kernel documentation <Documentation/filesystems/ramfs-rootfs-initramfs.rst> for the details of initramfs.
There are two ways to use initramfs:
1. The initramfs archive is loaded separately to memory from loading the kernel image;
2. The initramfs archive is built into kernel image and loaded to memory along with the kernel image.
Method 1 provides the flexibility as the the iniramfs archive could be located differently from where the kernel image is stored, while method 2 requires minimum user interaction when loading the initramfs archive to memory.
For a detailed discussion about Method 1 please refer to the following E2E FAQ: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1176944/faq-linux-how-to-boot-sitara-am3x-am4x-am6x-devices-from-initramfs-cpio-archive-ram-disk
The instructions here are using AM62x Processor SDK Linux v8.6.0.42 as an example, describing how to use method 2. The instruction assumes the Processor SDK Linux v8.6.0.42 is installed in <SDK> folder. The procedure is applicable to other processors and SDK versions.
1. Prepare the initramfs
Since the entire initramfs will be loaded into memory, its footprint should be as small as possible. This example uses the tiny rootfs provided in the Processor SDK for the initramfs. Follow the commands below to prepare the initramfs:
$ cd <SDK>/filesystem/ $ mkdir tinyfs $ tar xvf tisdk-tiny-image-am62xx-evm.tar.xz -C tinyfs $ cd tinyfs $ ln -s /sbin/init init $ cd dev $ sudo mknod -m 0666 null c 1 3
Note: the step "ln -s /sbin/init init" in the instruction above is important, kernel panic would happen if it is missed.
2. Configure kernel initramfs
Modify kernel defconfig file to specify the path of the tinyfs:
In
<SDK>/board-support/linux-<version>/arch/arm64/configs/tisdk_am62xx-evm_defconfig
change
CONFIG_INITRAMFS_SOURCE=""
to
CONFIG_INITRAMFS_SOURCE="<SDK>/filesystem/tinyfs"
3. Build kernel
$ cd <SDK>/ $ make linux
4. Update kernel image to SD card
- Create a bootable SD card using the WIC image provided in the SDK. Recommended to use tisdk-base-image-am62xx-evm.wic.xz because its size is smaller.
- Mount the SD card to the Linux PC, assuming the mounting point is <SD-card-mounting-point>.
- Copy kernel image to the boot/ folder in the SD card root partition:
$ sudo cp board-support/linux-<version/arch/arm64/boot/Image <SD-card-mounting-point>/boot/Image-initramfs $ cd <SD-card-mounting-point> $ sudo ln -sf Image-initramfs Image
- Umount the SD card and boot SK-AM62 with it.