Fixing “No active dataset” on zone attach

October 31st, 2011

When moving zones between OpenIndiana (and OpenSolaris) hosts, you can often end up with the following dreaded error:

# zoneadm -z zonename attach -U
Log File: /var/tmp/zonename.attach_log.B8aWed
ERROR: no active dataset.
                    Result: Attach Failed.

This can happen for a variety of reasons, such as not detaching the zone before moving it, and not transferring the ZFS properties with the zone. But personally I blame the half-arsed zone attach scripts that could do with some work.

To get around it, here is a super-quick/dirty script that should allow the zone to attach:

#!/bin/bash

zfsfs=$1
root=${zfsfs}/ROOT
zbe=${root}/zbe

for i in $zbe $root $zfsfs ; do
  for j in zoned mountpoint ; do
    zfs inherit $j $i
  done
done

zfs set mountpoint=legacy $root
zfs set zoned=on $root
zfs set canmount=noauto $zbe
zfs set org.opensolaris.libbe:active=on $zbe

rbe=`zfs list -H -o name /`
uuid=`zfs get -H -o value org.opensolaris.libbe:uuid $rbe`

zfs set org.opensolaris.libbe:parentbe=$uuid $zbe

The script takes one argument, the zfs filesystem the zone lives in (the parent of “ROOT” for the zone). Ignore any errors about "dataset is used in a non-global zone", and once it has run, manually mount the dataset and attach it with:

mount -F zfs dataset/ROOT/zbe /zones/zonename/root
zoneadm -z zonename attach

This guide is pretty rough but should hopefully set people in roughly the right direction.

Entry Filed under: General

4 Comments Add your own

  • 1. Jens  |  November 7th, 2011 at 3:48 pm

    Thank you very much! This saved my day

  • 2. estibi  |  March 29th, 2012 at 2:52 pm

    In my case this one was missing:

    # zfs set org.opensolaris.libbe:active=on ${ZONE_BE_ZFS}

  • 3. Ron  |  May 25th, 2012 at 2:43 pm

    Thanks Alasdair. You just saved my butt. I copied a zone from my home machine to my work machine this morning. Got into the office and couldn’t attach it.

  • 4. Richard  |  July 17th, 2012 at 2:26 pm

    Hi

    you saved my life !!!
    this is a great script.
    Better in depth knowledge than I and our supporter could find on Oracles pages.

    This is such a simple but EFFECTIVE Script.

    Thank you !!!

    Richard G.

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed