ZFS mounting failed with error 2

David Demelier demelier.david at gmail.com
Mon Apr 15 09:28:39 UTC 2013

I've successfully made booting one virtual machine, I tried again and
it failed again. There's one thing I'm not sure about is that some
people create a dataset root but that actually mounts at / (and not
/root) and some just create others mount points directly on the zpool

I've tested the second one so I did the following :

zpool create -o altroot=/mnt tank /dev/gpt/disk0
zfs create tank/usr

And then I've done all the other and I'm still unable to boot, this is
the exact list (and order) I've used :

gpart create -s GPT ada0
gpart add -t freebsd-boot -s 64k -l boot0 ada0
gpart add -t freebsd-swap -s 4G -l swap0 ada0
gpart add -t freebsd-zfs -l disk0 ada0

gpart bootcode -b /boot/pmbr ada0
gpart bootcode -p /boot/gptzfsboot -i 1 ada0

zpool create -o altroot=/mnt tank /dev/gpt/zfs0
zpool set bootfs=tank tank
zfs set checksum=fletcher4 tank

zfs create -o setuid=off                    tank/home
zfs create -o setuid=off                    tank/tmp

# /usr
zfs create                            tank/usr
zfs create                            tank/usr/local
zfs create -o setuid=off -o compression=lzjb            tank/usr/src
zfs create -o setuid=off -o compression=lzjb            tank/usr/ports

# /var
zfs create                            tank/var
zfs create -o setuid=off -o compression=lzjb -o exec=off    tank/var/crash
zfs create -o setuid=off -o compression=lzjb -o exec=off    tank/var/log
zfs create -o setuid=off -o exec=off                tank/var/run
zfs create -o setuid=off                    tank/var/tmp

chmod 1777 /mnt/tmp /mnt/var/tmp


echo "/dev/label/swap0 none swap sw 0 0"    >> /mnt/etc/fstab
echo "zfs_enable=YES"                >> /mnt/etc/rc.conf
echo "zfs_load=YES"                >> /mnt/boot/loader.conf
echo "vfs.root.mountfrom=zfs:tank"        >> /mnt/boot/loader.conf

# zpool.cache (unable to boot without)
zpool export tank
zpool import -o cachefile=/tmp/zpool.cache -o altroot=/mnt tank
cp /tmp/zpool.cache /mnt/boot/zfs
zpool export tank

# Finished
shutdown -r now


Demelier David

More information about the freebsd-questions mailing list