Mounting file systems when VFS starts
When the VFS program starts, only the RAMFS file system is mounted to the root directory by default. If you need to mount other file systems, this can be done not only by calling the mount()
function but also by setting the startup parameters and environment variables of the VFS program.
The ROMFS
and squashfs
file systems are intended for read-only operations. For this reason, you must specify the ro
parameter to mount these file systems.
Using the startup parameter -l
One way to mount a file system is to set the startup parameter -l <entry in fstab format>
for the VFS program.
In these examples, the devfs and ROMFS file systems will be mounted when the VFS program is started:
init.yaml.(in)
CMakeLists.txt
Using the fstab file from the ROMFS image
When building a solution, you can add the fstab
file to the ROMFS image. This file can be used to mount file systems by setting the startup parameter -f <path to the fstab file>
for the VFS program.
In these examples, the file systems defined via the fstab
file that was added to the ROMFS image during the solution build will be mounted when the VFS program is started:
init.yaml.(in)
CMakeLists.txt
Using an "external" fstab file
If the fstab
file resides in another file system instead of in the ROMFS image, you must set the following startup parameters and environment variables for the VFS program to enable use of this file:
ROOTFS
. This environment variable mounts the file system containing thefstab
file to the root directory.UNMAP_ROMFS
. If this environment variable is defined, thefstab
file will be sought in the file system defined through theROOTFS
environment variable.-f
. This startup parameter is used to mount the file systems specified in thefstab
file.
In these examples, the ext2 file system that should contain the fstab
file at the path /etc/fstab
will be mounted to the root directory when the VFS program starts:
init.yaml.(in)
CMakeLists.txt