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)
...
- name: VfsFirst
args:
- -l
- devfs /dev devfs 0
- -l
- romfs /etc romfs ro
...
CMakeLists.txt
...
set_target_properties (${vfs_ENTITY} PROPERTIES
EXTRA_ARGS
" - -l
- devfs /dev devfs 0
- -l
- romfs /etc romfs ro")
...
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)
...
- name: VfsSecond
args:
- -f
- fstab
...
CMakeLists.txt
...
set_target_properties (${vfs_ENTITY} PROPERTIES
EXTRA_ARGS
" - -f
- fstab")
...
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 the fstab
file to the root directory.UNMAP_ROMFS
. If this environment variable is defined, the fstab
file will be sought in the file system defined through the ROOTFS
environment variable.-f
. This startup parameter is used to mount the file systems specified in the fstab
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)
...
- name: VfsThird
args:
- -f
- /etc/fstab
env:
ROOTFS: ramdisk0,0 / ext2 0
UNMAP_ROMFS: 1
...
CMakeLists.txt
...
set_target_properties (${vfs_ENTITY} PROPERTIES
EXTRA_ARGS
" - -f
- /etc/fstab"
EXTRA_ENV
" ROOTFS: ramdisk0,0 / ext2 0
UNMAP_ROMFS: 1")
...
Page top