Skip to content

Commit

Permalink
loader: extend root fs auto-discovery
Browse files Browse the repository at this point in the history
This extends the (fallback) root file system auto-discovery mechanism to
include virtio-fs, so now the search order becomes rofs -> virtio-fs ->
zfs.

While at it, we also ensure that when even zfs fails, we mount the fstab
entries before continuing with ramfs as the root file system.

Signed-off-by: Fotis Xenakis <[email protected]>
Message-Id: <VI1PR03MB3773F53D7D312B17CEDFF3BBA67F9@VI1PR03MB3773.eurprd03.prod.outlook.com>
  • Loading branch information
foxeng authored and wkozaczuk committed Mar 30, 2021
1 parent f80864d commit a858353
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -444,23 +444,29 @@ void* do_main_thread(void *_main_args)

boot_time.event("Virtio-fs mounted");
} else {
// Fallback to original behavior for compatibility: try rofs -> zfs
// Auto-discovery: try rofs -> virtio-fs -> ZFS
if (mount_rofs_rootfs(opt_pivot) == 0) {
if (opt_disable_rofs_cache) {
debug("Disabling ROFS memory cache.\n");
rofs_disable_cache();
}
boot_time.event("ROFS mounted");
} else if (mount_virtiofs_rootfs(opt_pivot) == 0) {
boot_time.event("Virtio-fs mounted");
} else {
zfsdev::zfsdev_init();
auto error = mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools);
if (error) {
debug("Could not mount zfs root filesystem (while "
"auto-discovering).\n");
// Continue with ramfs (already mounted)
// TODO: Avoid the hack of using pivot_rootfs() just for
// mounting the fstab entries.
pivot_rootfs("/");
} else {
bsd_shrinker_init();
boot_time.event("ZFS mounted");
}

bsd_shrinker_init();
boot_time.event("ZFS mounted");
}
}
}
Expand Down

0 comments on commit a858353

Please sign in to comment.