Subject: Fail to clone guest
From: Stephen Liu <satimis@yahoo.com>
Date: Sat, 30 Aug 2008 20:11:42 +0800 (CST)

Hi folks,


Tried to clone guest without success.


According to;
Building guests using the clone build method
http://linux-vserver.org/Building_Guest_Systems#Building_guests_using_the_clone_build_method


# vserver vserver3 build -m clone --hostname vserver3.satimis.com
--interface eth0:192.168.0.113/24 -- --source /vservers/vserver2
Unknown build-method 'clone'


According to following script;
http://svn.linux-vserver.org/projects/util-vserver/browser/trunk/scripts/vserver-build


On Host
I added clone method to the script /usr/lib/util-vserver/vserver-build

copy follows;
clone       ... -- [-d <distribution>] --source <source>
[--exclude-from <exclude-list>]
                ...  clones a guest by linking unified files and
copying the rest

under;
rsync


adding xclone after xrsync as follow;
   
(xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum|xrpm|xtemplate|xfai|xrsync|xclone)


$ cat /usr/lib/util-vserver/vserver-build
#! /bin/bash
# $Id: vserver-build 2398 2006-11-24 15:20:09Z dhozac $

: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
test -e "$UTIL_VSERVER_VARS" || {
    echo $"Can not find util-vserver installation (the file
'$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
    exit 1
}
. "$UTIL_VSERVER_VARS"
. "$_LIB_FUNCTIONS"
. "$_LIB_VSERVER_SETUP_FUNCTIONS"
. "$_LIB_VSERVER_BUILD_FUNCTIONS"

### Some local functions

function showHelp()
{
    echo \
$"Usage: $(basename $0) -m <method> -n <name> --force <cfg-options>*
    --rootdir <dir> --pkgbase <dir> [--] <method-args>*

Options:
    --force     ...  remove/rename already existing vservers with the
same
                     name
    --keep      ...  do not delete generated files and directories when
                     build of vserver failed.
    -m <method> ...  use method <method>; see below for possible values
    --rootdir <dir>
                ...  [default: $__DEFAULT_VSERVERDIR]
    --pkgbase <dir>
                ...  [default: $__DEFAULT_VSERVERPKGDIR]

cfg-options are: $SETUP_HELPMSG

Possible methods are:
    legacy      ...  the \"old\" copy-all-from-host method, which
requires the
                     old legacy  vserver-legacy script;  with  this
method the
                     cfg-options will be ignored
    apt-rpm     ... -- -d <distribution>
                ...  installs the base-packages of the given
distribution with
                     help of 'vapt-get'
    yum         ... -- -d <distribution>
                ...  installs the base-packages of the given
distribution with
                     help of 'vyum'
    rpm         ... -- [-d <distribution>] --empty|([--force]
[--nodeps] <manifest>)+
                ...  installs lists of rpm-packages
    skeleton    ... -- [<cmd> <args>*]
                ...  installs a minimal skeleton filesystem, creates
the
                     configuration file and calls an optional command
then
    debootstrap ... -- -d <distribution> [-m <mirror>] [-s <script> ]
[-- <debootstrap-options>*]
                ...  bootstraps the vserver with Debian's 'debootstrap'
package
    template    ... -- (-t <tarball>)+ [-d <distribution>]
                ...  installs a guest using tarball(s)
    fai         ... -- [ -f <fai_vserver> ] [-n <nfsroot>] [-d
<fai_dir> ] [ -a ]
                     bootstraps the vserver with Debian Fully Automatic
Installation
                     -f means use the nfsroot and profile in the
vserver <fai_vserver>
                     -n <nfsroot> specifies the 'NFS' root explicitly
                     -d <fai_dir> specifies the location of the FAI
profile
                     the -f option implies -n and -d are relative to
the <fai_vserver>
    rsync       ... -- [-d <distribution>] --source <source> [-o <rsync
option>]*
                ...  installs a guest by rsyncing from <source> to the
guest root
    clone       ... -- [-d <distribution>] --source <source>
[--exclude-from <exclude-list>]
                ...  clones a guest by linking unified files and
copying the rest

Please report bugs to $PACKAGE_BUGREPORT"
    exit 0
}

function showVersion()
{
    echo \
$"vserver-build $PACKAGE_VERSION -- initializes a vserver
This program is part of $PACKAGE_STRING

Copyright (C) 2003,2004,2005 Enrico Scholz
This program is free software; you may redistribute it under the terms
of
the GNU General Public License.  This program has absolutely no
warranty."
    exit 0
}

### main starts here

set -e

declare -a default_opts=()
test -n "$NO_DEFAULT_OPTS" || getFileArray default_opts
"$__CONFDIR/.defaults/apps/build/options" || :

tmp=$(getopt -o +m:n: --long
keep,force,debug,help,version,rootdir:,pkgbase:,$SETUP_OPTIONS -n
"$(basename $0)" -- \
        "${default_opts[@]}" "$@") || exit 1
eval set -- "$tmp"

VSERVER_NAME=
OPTION_FORCE=
OPTION_DEBUG=0
OPTION_KEEP=

while true; do
    case "$1" in
        (--help)    showHelp $0 ;;
        (--version) showVersion ;;
        (--force)   OPTION_FORCE=1;;
        (--keep)    OPTION_KEEP=1;;
        (--debug)   let ++OPTION_DEBUG;  set -x;;
        (--rootdir) ROOTDIR=$2;      shift;;
        (--pkgbase) PKGCFGBASE=$2;   shift;;
        (-m)        method=$2;       shift;;
        (-n)        VSERVER_NAME=$2; shift;;
        (--)        shift; break;;
        (*)
            { setup_setOption2 "$1" "$2" && shift; } || \
              panic $"vserver-build: internal error."
            ;;
    esac
    shift
done

test -n "$VSERVER_NAME" ||
    panic $"Name of vserver not specified"

setup_setDefaults "$VSERVER_NAME"

case x"$method" in
    (xlegacy)   exec $_VSERVER_LEGACY "$VSERVER_NAME" build "$@" ;;
   
(xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum|xrpm|xtemplate|xfai|xrsync|xclone)
                . $__PKGLIBDIR/vserver-build.$method
                ;;
    (x)         panic $"No build-method specified";;
    (*)         panic $"Unknown build-method '$method'";;
esac
* end *


I found vserver-build.clone script on;
http://svn.linux-vserver.org/projects/util-vserver/browser/trunk/scripts/vserver-build.clone


and put the vserver-build.clone script on
/usr/lib/util-vserver/vserver-build.clone


But can't work;

# vserver vserver3 build -m clone --hostname vserver3.satimis.com
--interface eth0 :192.168.0.113/24 -- --source /vservers/vserver2/
vserver-build.clone: valid --source argument required


Then I found another vserver-build.clone script on;
http://svn.linux-vserver.org/projects/util-vserver/browser/trunk/scripts/vserver-build.clone?rev=2494


and modify the 1st vserver-build.clone script as follow;

$ cat /usr/lib/util-vserver/vserver-build.clone
# $Id$  --*- sh -*--

tmp=$(getopt -o '+d:s:o:X:' --long debug,pkgmgmt,source:,exclude-from:
-n "$0" -- "$@") || exit 1
eval set -- "$tmp"

. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"

DISTRIBUTION=:
use_pkgmgmt=
SOURCE=
EXCLUDES=
while true; do
    case "$1" in
        -d)             DISTRIBUTION=$2; shift;;
        --debug)        set -x;;
        --pkgmgmt)      use_pkgmgmt=1;;
        -s|--source)    SOURCE=$2; shift;;
        -X|--exclude-from)
                                EXCLUDES=$2; shift;;
        --)             shift; break ;;
        *)              echo "vserver-build.clone: internal error:
unrecognized option '$1'" >&2
                        exit 1
                        ;;
    esac
    shift
done

if test -d "$SOURCE"; then
    :
elif test -d "$__CONFDIR/$SOURCE"; then
    SOURCE=`getPhysicalDir "$__CONFDIR/$SOURCE/vdir"`
elif test -d "$__DEFAULT_VSERVERDIR/$SOURCE"; then
    SOURCE=`getPhysicalDir "$__DEFAULT_VSERVERDIR/$SOURCE"`
else
    SOURCE=
fi

test -n "$SOURCE" || panic $"vserver-build.clone: valid --source
argument required"

getDistribution '' 1

base.init
test -z "$use_pkgmgmt" || pkgmgmt.initVariables

base.initFilesystem "$OPTION_FORCE"
test -z "$use_pkgmgmt" || pkgmgmt.initFilesystem "$OPTION_FORCE"


setup_writeOption "$VSERVER_NAME"
setup_writeInitialFstab

test -z "$BUILD_INITPRE"  || "$BUILD_INITPRE" "$SETUP_CONFDIR" 
"$UTIL_VSERVER_VARS"

#$_VCLONE "$SOURCE"/ "$VDIR"/

test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR"
"$UTIL_VSERVER_VARS"

base.setSuccess
* end *


But still fail.

# vserver vserver3 build -m clone --hostname vserver3.satimis.com
--interface eth0 :192.168.0.113/24 -- --source /vservers/vserver2/
vserver-build.clone: valid --source argument required


Please advise how to fix the problem.  TIA


B.R.
Stephen L

Send instant messages to your online friends http://uk.messenger.yahoo.com