[Pkg] [OpenIndiana Distribution - Bug #1204] zoneadm cannot create clone of zone from snapshot

illumos project devnull at illumos.org
Wed Nov 13 01:36:27 UTC 2013


Issue #1204 has been updated by Jim Klimov.


This patch was made and tested in OI 151a8, works for both specified full snapshot names (dataset part loudly ignored) or just snapshot name.

--- /usr/lib/brand/ipkg/clone.orig      2011-09-12 15:01:44.000000000 +0400
+++ /usr/lib/brand/ipkg/clone   2013-11-13 05:31:27.756698164 +0400
@@ -45,9 +45,16 @@
 ROOT="rpool/ROOT"
 
 # Other brand clone options are invalid for this brand.
-while getopts "R:z:" opt; do
+while getopts "R:s:z:" opt; do
        case $opt in
                R)      ZONEPATH="$OPTARG" ;;
+               s)      case "$OPTARG" in
+                       *@*)    SNAPNAME="`echo "$OPTARG" | sed 's/^[^@]*@//'`"
+                               echo "WARNING: Ignoring dataset, using only snapshot name"
+                               ;;
+                       *)      SNAPNAME="$OPTARG" ;;
+                       esac
+                       ;;
                z)      ZONENAME="$OPTARG" ;;
                *)      fail_usage "";;
        esac
@@ -96,19 +103,21 @@
 /usr/sbin/zfs create -o mountpoint=legacy -o zoned=on $zpds/$zpname/ROOT
 
 # make snapshot
-SNAPNAME=${ZONENAME}_snap
-SNAPNUM=0
-while [ $SNAPNUM -lt 100 ]; do
-       /usr/sbin/zfs snapshot $ACTIVE_DS@$SNAPNAME
-        if [ $? = 0 ]; then
-                break
-       fi
-       SNAPNUM=`expr $SNAPNUM + 1`
-       SNAPNAME="${ZONENAME}_snap$SNAPNUM"
-done
+if [ x"$SNAPNAME" = x ]; then
+       SNAPNAME=${ZONENAME}_snap
+       SNAPNUM=0
+       while [ $SNAPNUM -lt 100 ]; do
+               /usr/sbin/zfs snapshot $ACTIVE_DS@$SNAPNAME
+               if [ $? = 0 ]; then
+                       break
+               fi
+               SNAPNUM=`expr $SNAPNUM + 1`
+               SNAPNAME="${ZONENAME}_snap$SNAPNUM"
+       done
 
-if [ $SNAPNUM -ge 100 ]; then
-       fail_fatal "$f_zfs_create"
+       if [ $SNAPNUM -ge 100 ]; then
+               fail_fatal "$f_zfs_create"
+       fi
 fi
 
 # do clone

----------------------------------------
Bug #1204:  zoneadm cannot create clone of zone from snapshot
https://www.illumos.org/issues/1204

Author: Alexander Eremin
Status: New
Priority: Normal
Assignee: OI PKG
Category: pkg (Image Packaging System)
Target version: 
Difficulty: Medium
Tags: clone


Bug from https://defect.opensolaris.org/bz/show_bug.cgi?id=5940 still exist, i.e.:

~# zoneadm -z test2 clone -s rpool/zones/test/ROOT/zbe-1 at test_snap
/usr/lib/brand/ipkg/clone: -s: unknown option

brand-specific usage: clone {sourcezone}
usage:	clone [-m method] [-s <ZFS snapshot>] [brand-specific args] zonename
	Clone the installation of another zone.  The -m option can be used to
	specify 'copy' which forces a copy of the source zone.  The -s option
	can be used to specify the name of a ZFS snapshot that was taken from
	a previous clone command.  The snapshot will be used as the source
	instead of creating a new ZFS snapshot.  All other arguments are passed
	to the brand clone function; see brands(5) for more information.



-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://www.illumos.org/my/account



More information about the Pkg-team mailing list