Skip to content

Commit a858353

Browse files
foxengwkozaczuk
authored andcommitted
loader: extend root fs auto-discovery
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>
1 parent f80864d commit a858353

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

loader.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,23 +444,29 @@ void* do_main_thread(void *_main_args)
444444

445445
boot_time.event("Virtio-fs mounted");
446446
} else {
447-
// Fallback to original behavior for compatibility: try rofs -> zfs
447+
// Auto-discovery: try rofs -> virtio-fs -> ZFS
448448
if (mount_rofs_rootfs(opt_pivot) == 0) {
449449
if (opt_disable_rofs_cache) {
450450
debug("Disabling ROFS memory cache.\n");
451451
rofs_disable_cache();
452452
}
453453
boot_time.event("ROFS mounted");
454+
} else if (mount_virtiofs_rootfs(opt_pivot) == 0) {
455+
boot_time.event("Virtio-fs mounted");
454456
} else {
455457
zfsdev::zfsdev_init();
456458
auto error = mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools);
457459
if (error) {
458460
debug("Could not mount zfs root filesystem (while "
459461
"auto-discovering).\n");
462+
// Continue with ramfs (already mounted)
463+
// TODO: Avoid the hack of using pivot_rootfs() just for
464+
// mounting the fstab entries.
465+
pivot_rootfs("/");
466+
} else {
467+
bsd_shrinker_init();
468+
boot_time.event("ZFS mounted");
460469
}
461-
462-
bsd_shrinker_init();
463-
boot_time.event("ZFS mounted");
464470
}
465471
}
466472
}

0 commit comments

Comments
 (0)