Skip to content
WALDEMAR KOZACZUK edited this page Jul 18, 2022 · 10 revisions

OSv supports a variety of filesystems which are described in the below paragraphs. Layers-wise, it comes with the VFS layer (see fs/vfs/*) and particular filesystem implementations found under fs/**/* with the exception of ZFS.

Root Filesystem

During boot time, OSv initially mounts the BootFS filesystem (see vfs_init() and mount_rootfs()) and then proceeds to mount and pivot to a 'real' filesystem like RoFS, ZFS or VirtioFS (for details see this code in loader.cc) unless the --nomount kernel option was specified. The root filesystem can be explicitly selected using the --rootfs option, otherwise, the loader will try to discover it by trying RoFS, then Virtio-FS, and eventually ZFS.

Please note that OSv also supports the /etc/fstab file where one could add an extra filesystem mount point. In addition, one can mount an extra filesystem by supplementing appropriate options to the command line like so:

scripts/run.py --execute='--rootfs=rofs --mount-fs=zfs,/dev/vblk0.2,/data /hello

In order to build an image with a specific type of filesystem, you need to specify the fs option (which defaults to zfs) like so:

scripts/build image=tests fs=rofs

RamFS

RoFS

ZFS

The ZFS code has been based on the FreeBSD implementation as of circa 2014 and since adapted to work in OSv. The ZFS is a sophisticated filesystem that traces its roots in Solaris and you can find some resources about it on this Wiki page. The majority of the ZFS code can be found under the subtree bsd/sys/cddl/. The ZFS filesystem driver has been fairly recently extracted from the kernel as a separate shared library libsolaris.so which is dynamically loaded during boot time from a different filesystem (most likely BootFS or RoFS) before ZFS filesystem can be mounted.

There are three ways ZFS can be mounted on OSv:

  1. The first and the original one assumes mounting ZFS at the root (/) from the 1st partition of the 1st disk - /dev/vblk0.1.
  2. The second one involves mounting ZFS from the 2nd partition of the 1st disk - /dev/vblk0.2 at an arbitrary non-root mount point, for example /data.
  3. Similarly, the third way involves mounting ZFS from the 1st partition of the 2nd or higher disk - for example /dev/vblk1.1 at an arbitrary non-root mount point as well. Please note that both the second and third options assume that the root filesystem is non-ZFS - most likely RoFS or Virtio-FS.

The disadvantage of the 1st option is that the code and data live in the same read-write partition, whereas the other two options allow one to isolate code from mutable data. Ideally one would put all code and configuration on RoFS partition, colocated on the same disk (2) or not (3), and mutable data on the separate partition on the same disk (2) or different (3). It has been shown that booting and mounting ZFS from a separate disk is also slightly faster (by 30-40ms) compared to the original option 1.

VirtioFS

NFS

Clone this wiki locally