Resetting root password on FreeBSD when using ZFS root
If you have lost, forgotten or for some reason, simply just want to reset your FreeBSD root account password, you can do this quite easily if you have physical access to the box.
There are many articles out there which explain how to do it, but all of them are geared towards people who use a standard partition layout which means it won’t work if you have root on ZFS.
Resetting root password in a single-user mode
A standard way to reset a forgotten root password is to boot into a single-user
mode, mount all of your partitions and change the password using the standard
passwd command.
If you have ZFS on a root partition, the process is pretty much the same, the
only difference is that you need to run zfs mount -a command to mount all
ZFS filesystems instead of the usual mount -a command.
 FreeBSD bootloader menu.
    FreeBSD bootloader menu.
Keep in mind that this approach won’t work if you have marked console as
insecure in /etc/ttys file.
The whole sequence of steps you need to take is listed bellow:
- Reboot the system
- When a bootloader menu shows up, select Boot FreeBSD in single user modeoption
- When an emergency shell loads, type the commands bellow and select a new password
zfs mount -a
passwd
zfs umount -a
reboot