Solved. Re: Dualboot and ZFS

Victor Sudakov vas at
Mon Mar 19 02:59:24 UTC 2018

On 2018-01-31 08:27, Victor Sudakov wrote:
> > My pool works successfully in a bhyve environment, but in VirtualBox 
> > 5.0.14
> > (to test the real boot sequence) I get this message from zfsboot:
> > 
> > zfsboot: No ZFS pools located, can't boot
> > 
> > However, if I boot from LiveCD, the pool is there, it's healthy and
> > can be imported.

Finally, and thanks to Eugene Grossbein, the problem is solved.

The gist of the problem was the presence of a BSD label in the slice
where the bootable zfs pool was located. It turns out that zfsboot
ignores the slice if it finds a BSD label therein. The bootable zpool
should be directly on the slice (like on da1s1, and not da1s1a).

This means that both zfsboot(8) and the articles in the FreeBSD wiki
are erroneous because they all suggest "gpart create -s BSD ada0s1" -
in fact, it's fatal.

Below is the final working example:


sysctl kern.geom.debugflags=0x10


partition() {
	gpart create -s mbr ${DISK}
	gpart add -t fat32 -s 1G ${DISK}
	gpart add -t freebsd -s 2G -i ${SLICE} ${DISK}
	gpart set -a active -i ${SLICE} ${DISK}

bootcode() {
	gpart bootcode -b /boot/boot0 ${DISK}
	dd if=/boot/zfsboot of=/dev/${DISK}s${SLICE} count=1
	dd if=/boot/zfsboot of=/dev/${DISK}s${SLICE} iseek=1 oseek=1024


zfscreate() {
	zpool create -m none -R /${NEWSYSTEM} ${POOL} ${DISK}s${SLICE}

	zfs create -o mountpoint=none ${POOL}/ROOT
	zfs create -o mountpoint=/ ${POOL}/ROOT/default

	zfs create -o mountpoint=/usr -o canmount=off ${POOL}/usr
	zfs create -o mountpoint=/var -o canmount=off ${POOL}/var

	zfs create -o mountpoint=/tmp ${POOL}/tmp
	zfs create -o mountpoint=/usr/home ${POOL}/usr/home
	zfs create -o mountpoint=/var/audit ${POOL}/var/audit
	zfs create -o mountpoint=/var/crash ${POOL}/var/crash
	zfs create -o mountpoint=/var/log ${POOL}/var/log
	zfs create -o mountpoint=/var/mail ${POOL}/var/mail
	zfs create -o mountpoint=/var/tmp ${POOL}/var/tmp

	zfs create -V 1G -o org.freebsd:swap=on ${POOL}/swap

	zpool set bootfs=${POOL}/ROOT/default ${POOL}

clone() {
	cd /${NEWSYSTEM} || exit 3
	#sleep 10
	dump -0af - / | restore -ryf - || exit 3 
	mv etc/fstab etc/fstab.bak
	echo '# empty' > etc/fstab
	echo 'zfs_enable="YES"' >> etc/rc.conf.local 
	echo 'zfs_load="YES"' >> boot/loader.conf 
	cd /root

zfsexport() {
	zpool export ${POOL}


Victor Sudakov,  VAS4-RIPE, VAS47-RIPN

More information about the freebsd-questions mailing list