Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 05 May 2012 08:19:11 +0200
From:      vermaden <vermaden@interia.pl>
To:        "Randal L. Schwartz" <merlyn@stonehenge.com>
Cc:        freebsd-fs@FreeBSD.org, freebsd-questions@freebsd.org
Subject:   Re: HOWTO: FreeBSD ZFS Madness (Boot Environments)
Message-ID:  <mvldhyocegbxysykainf@hamg>
In-Reply-To: <86y5p7y478.fsf@red.stonehenge.com>
References:  <pfwjphodwzuumbfqsxjn@xcww> <86ipgbg2p6.fsf@red.stonehenge.com> <ijlvdasdjkuxpbatycve@qzwb> <86d36jzk16.fsf@red.stonehenge.com> <867gwrzjwc.fsf@red.stonehenge.com> <86397fzjgi.fsf@red.stonehenge.com> <86y5p7y478.fsf@red.stonehenge.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> And no difference on 8.3 :(
>=20
> 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=3D${TMPMNT} ${POOL}/ROOT/${2}
          zfs mount ${POOL}/ROOT/${2}
        } || {
          TMPMNT=3D${MOUNT}
        }

snippet 2:

        if [ ${MOUNT} -eq 0 ]; then
          zfs set mountpoint=3D${TMPMNT} ${POOL}/ROOT/${2}
          zfs mount ${POOL}/ROOT/${2}
        else
          TMPMNT=3D${MOUNT}
        fi

But unfortunately, it comes out that its not the same ...

        [ ${MOUNT} -eq 0 ] && {
          zfs set mountpoint=3D${TMPMNT} ${POOL}/ROOT/${2}
          zfs mount ${POOL}/ROOT/${2}
          # IF THIS LINE ABOVE FAILS (NOT RETURN 0) THEN
          # TMPMNT=3D${MOUNT} BELOW WILL BE EXECUTED
        } || {
          TMPMNT=3D${MOUNT}
        }

The sollution can be put command that will always
work (return 0 on exit) like that:

        [ ${MOUNT} -eq 0 ] && {
          zfs set mountpoint=3D${TMPMNT} ${POOL}/ROOT/${2}
          zfs mount ${POOL}/ROOT/${2}
          echo 1> /dev/null 2> /dev/null
        } || {
          TMPMNT=3D${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@be
# zfs set mountpoint=3D/mnt zroot
[ set vfs.root.mountfrom=3D"zfs:zroot" in /mnt/boot/loader.conf ]
# zpool set bootfs=3Dzroot zroot
# zfs set mountpoint=3Dnone 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=3Dnone zroot/ROOT
# zfs send zpool@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
--=20








































...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?mvldhyocegbxysykainf>