Option to Change RAM-based Filesystem - 2022.1 English

PetaLinux Tools Documentation: Reference Guide (UG1144)

Document ID
UG1144
Release Date
2022-04-26
Version
2022.1 English

There is a menu config option to build the initial RAM-based root filesystem as highlighted in the following figure.

Figure 1. RAM-based Root File System

You can provide the name of the Yocto image recipe that is used to build an initial RAM filesystem in the menu config option, INITRAMFS/INITRD Image name. By default, it is set to petalinux-image-minimal for Zynq-7000 devices and MicroBlaze processors and to petalinux-initramfs-image for Zynq UltraScale+ MPSoCs and Versal ACAPs. The petalinux-initramfs-image is a small file system which is deployed into images/linux as ramdisk.cpio.gz.u-boot. It is also packed into Fit image as image.ub. This allows the specified image to be bundled inside the kernel image. An INITRAMFS/INITRD image provides a temporary root file system used for early system initialization, for example, when loading modules that are needed to locate and mount the "real" root filesystem.

After configuration, you can find the following bootargs changes in <plnx-proj-root>/configs/config:

init_fatal_sh=1:
Launch the initramfs prompt if the specified device not available.

You can see the two root file systems in <plnx-proj-root>/images/linux:

ramdisk.cpio, ramdisk.cpio.gz.u-boot etc..
rootfs.cpio, rootfs.cpio.gz.u-boot etc..
Using the petalinux-initramfs-image as the INITRD/INITRAMFS image will boot the system with tiny rootfs, search for the ext2, ext3, and ext4 SD partitions, and check for the /dev,/etc and /sbin/init file/ folder in it to validate whether the rootfs is valid and can be used as a real file system using the command switch_root. If you want to specify the SD device which has the ext rootfs, add ext4=/dev/mmcblk0p2:/rootfs in system bootargs as shown below:
petalinux-config ---> DTG Settings  ---> Kernel Bootargs  ---> [ ] generate boot args automatically
petalinux-config ---> DTG Settings  ---> Kernel Bootargs  ---> (earlycon console=ttyPS0,115200 clk_ignore_unused init_fatal_sh=1 ext4=/dev/mmcblk0p2:/rootfs) user set kernel bootargs

Disabling switch_root

If you do not want to use the switch_root command which is the default command to mount and use the ext rootfs in Zynq UltraScale+ MPSoC and Versal devices, you can disable it in build time using the following command:

petalinux-config ---> Image Packaging Configuration  --->

Update the name petalinux-initramfs-image to petalinux-image-minimal in INITRAMFS/INITRD image name and then run the petalinux-build command.

Note: If you have previously built using the petalinux-initramfs-image command, you will continue to see the ramdisk.* images in the images/linux folder. To avoid confusion, check the time stamp.
Note: If you enable Xen when switch_root is enabled, you will see build failures because Xen only supports the ramfs boot. Enabling switch_root will enable the ext4-based boot. To resolve the issue, change the above configuration to petalinux-image-minimal from petalinux-initramfs-image.