1#/bin/sh
2#
3#	$NetBSD: zfsroot.rc,v 1.5 2020/04/14 12:14:59 roy Exp $
4
5# Assumption - boot.cfg loads this ramdisk.
6# Assumption - The needed kernel modules: solaris and zfs; are either on this
7#              ramdisk OR loaded by boot.cfg.
8#              Finding the correct dev node to mount to get them is too magic.
9#              NetBSD cannot build and distribute a kernel with ZFS builtin.
10# Assumption - the root pool is set to legacy mount.
11
12# Configurable - define the ZFS root pool and ROOT.
13# XXX Can these be set in boot.cfg?
14rpool=rpool
15rroot=ROOT
16
17# Setup some stuff incase things go south and we drop to the shell
18export HOME=/
19export PATH=/sbin:/bin:/usr/sbin:/usr/bin
20umask 022
21
22echo "Importing $rpool"
23/sbin/zpool import -f -N "$rpool"
24
25echo "Mounting $rpool/$rroot to /altroot"
26/sbin/mount -t zfs "$rpool/$rroot" /altroot;
27
28/sbin/sysctl -w init.root=/altroot
29