HOWTO: FreeBSD ZFS Madness (Boot Environments)
vermaden
vermaden at interia.pl
Sat May 5 06:19:20 UTC 2012
> And no difference on 8.3 :(
>
> Should there have been a "promote" in there somewhere? It looks like
> the boot env is still dependent on the very old zroot.
Hi,
I have just recreated from scratch Your zroot root
setup under VirtualBox and tested it deeply.
There was an interesting BUG in the *beadm* utility,
or maybe it is a BUG in sh(1), I do not have that
good knowledge of POSIX/sh(1) standards.
To the point, check these two code snippets, they should
do EXACLY the same, logic is the same, the differece is
only the syntax.
snippet 1:
[ ${MOUNT} -eq 0 ] && {
zfs set mountpoint=${TMPMNT} ${POOL}/ROOT/${2}
zfs mount ${POOL}/ROOT/${2}
} || {
TMPMNT=${MOUNT}
}
snippet 2:
if [ ${MOUNT} -eq 0 ]; then
zfs set mountpoint=${TMPMNT} ${POOL}/ROOT/${2}
zfs mount ${POOL}/ROOT/${2}
else
TMPMNT=${MOUNT}
fi
But unfortunately, it comes out that its not the same ...
[ ${MOUNT} -eq 0 ] && {
zfs set mountpoint=${TMPMNT} ${POOL}/ROOT/${2}
zfs mount ${POOL}/ROOT/${2}
# IF THIS LINE ABOVE FAILS (NOT RETURN 0) THEN
# TMPMNT=${MOUNT} BELOW WILL BE EXECUTED
} || {
TMPMNT=${MOUNT}
}
The sollution can be put command that will always
work (return 0 on exit) like that:
[ ${MOUNT} -eq 0 ] && {
zfs set mountpoint=${TMPMNT} ${POOL}/ROOT/${2}
zfs mount ${POOL}/ROOT/${2}
echo 1> /dev/null 2> /dev/null
} || {
TMPMNT=${MOUNT}
}
... or to rewrite it under if/then/else which I did for the whole
*beadm* utility and I no longer use || and && syntax, anywhere.
As for Your problems, this worked for me on this VirtualBox test
environment.
# zfs promote zroot
# zfs rollback zpool at be
# zfs set mountpoint=/mnt zroot
[ set vfs.root.mountfrom="zfs:zroot" in /mnt/boot/loader.conf ]
# zpool set bootfs=zroot zroot
# zfs set mountpoint=none zroot
# reboot
These above should bring back to the start point before
You entered my instructions to try *beadm* and BEs.
After reboot ...
# zfs destroy -R zroot/ROOT
# zfs create -o mountpoint=none zroot/ROOT
# zfs send zpool at be | zfs recv zroot/ROOT/be
# fetch https://raw.github.com/vermaden/beadm/master/beadm
# chmod +x beadm
# ./beadm list
# ./beadm activate be
# reboot
Now You should have a working system with boot environments.
Both GitHub and SourceForce have the latest fixed *beadm* version.
Regards,
vermaden
--
...
More information about the freebsd-questions
mailing list