lxc-clone.sgml.in revision 250b1eec71b074acdff1c5f6b5a1f0d7d2c20b77
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynlxc: linux Container library
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn(C) Copyright IBM Corp. 2007, 2008
9afe19d634946d50eab30e3b90cb5cebcde39eeaDaniel LezcanoDaniel Lezcano <daniel.lezcano at free.fr>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynSerge Hallyn <serge.hallyn at ubuntu.com>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynThis library is free software; you can redistribute it and/or
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynmodify it under the terms of the GNU Lesser General Public
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynLicense as published by the Free Software Foundation; either
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynversion 2.1 of the License, or (at your option) any later version.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynThis library is distributed in the hope that it will be useful,
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynbut WITHOUT ANY WARRANTY; without even the implied warranty of
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynLesser General Public License for more details.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynYou should have received a copy of the GNU Lesser General Public
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynLicense along with this library; if not, write to the Free Software
250b1eec71b074acdff1c5f6b5a1f0d7d2c20b77Stéphane GraberFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <refnamediv>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <refpurpose>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn clone a new container from an existing one.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </refpurpose>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </refnamediv>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <refsynopsisdiv>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <cmdsynopsis>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <arg choice="req">-o <replaceable>orig</replaceable></arg>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <arg choice="req">-n <replaceable>new</replaceable></arg>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn </cmdsynopsis>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <cmdsynopsis>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </cmdsynopsis>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </refsynopsisdiv>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <command>lxc-clone</command> Creates a new container as a clone of an existing
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn container. Two types of clones are supported: copy and snapshot. A copy
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn clone copies the root filessytem from the original container to the new. A
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn snapshot filesystem uses the backing store's snapshot functionality to create
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn a very small copy-on-write snapshot of the original container. Snapshot
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn clones require the new container backing store to support snapshotting. Currently
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn this includes only btrfs, lvm, overlayfs and zfs. LVM devices do not support
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn snapshots fo snapshots.
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn The backing store of the new container will be the same type as the
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn original container,
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn with one exception: overlayfs snapshots can be created of directory backed
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn containers. This can be requested by using the <replaceable>-B overlayfs</replaceable>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn The names of the original and new container can be given (in that order)
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn after all options, or can be specified with the
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <replaceable>-o</replaceable> and <replaceable>-n</replaceable> options,
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn respectively.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <variablelist>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn The new container's rootfs should be a LVM or btrfs snapshot of the original.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn Do not change the hostname of the container (in the root
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn filesystem).
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn Use the same MAC address as the original container, rather tahn
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn generating a new random one.
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn </varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn Copy all mount hooks into the new container's directory, and
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn update any lxcpaths and container names as needed.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <option>-L, --fssize <replaceable>fssize</replaceable></option>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn In the case of a block device backed container, a size for the new
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn block device. By default, the new device will be made the
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn same size as the original.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <option>-p, --lxcpath <replaceable>fssize</replaceable></option>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn The lxcpath of the original container. By default, the system
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn wide configured lxcpath will be used.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <option>-P, --newpath <replaceable>fssize</replaceable></option>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn The lxcpath for the new container. By default the same lxcpath
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn as the original will be used. Note that with btrfs snapshots,
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn changing lxcpaths may not be possible, as subvolume snapshots
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn must be in the same btrfs filesystem.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <option>-B, --backingstore <replaceable>fssize</replaceable></option>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn Select a different backing store for the new container. By
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn default the same as the original container's is used. Note that
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn currently changing the backingstore is only supported for
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn overlayfs snapshots of directory backed containers. Valid
eddaaafd1a9b02ba39e5b6b13d40b4a5d37a04e1Serge Hallyn backing stores include dir (directory), btrfs, lvm, zfs, loop
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn and overlayfs.
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn </varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <option>-o, --orig <replaceable>orig</replaceable></option>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn The name of the original container to clone.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <varlistentry>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn <option>-n, --new <replaceable>new</replaceable></option>
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn The name of the new container to create.
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn </varlistentry>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn </variablelist>
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn If the container being cloned has one or more <filename>lxc.hook.clone</filename>
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn specified, then the specified hooks will be called for the new container. The
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn first 3 arguments passed to the clone hook will be the container name, a section
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn ('lxc'), and the hook type ('clone'). Extra arguments passed
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn <command>lxc-clone</command> will be passed to the hook program starting at
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn argument 4. The <filename>LXC_ROOTFS_MOUNT</filename> environment variable gives
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn the path under which the container's root filesystem is mounted. The
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn configuration file pathname is stored in <filename>LXC_CONFIG_FILE</filename>, the
1143ed392d2760e8f7aeee88d570bb0ba151885fDwight Engen new container name in <filename>LXC_NAME</filename>, the old container name in
1143ed392d2760e8f7aeee88d570bb0ba151885fDwight Engen <filename>LXC_SRC_NAME</filename>, and the path or device on which
dc92f6c7eec81dc104b3f7873ffd74ec56a1dae1Serge Hallyn the rootfs is located is in <filename>LXC_ROOTFS_PATH</filename>.
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn <para>Serge Hallyn <email>serge.hallyn@ubuntu.com</email></para>
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallyn<!-- Keep this comment at the end of the file
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge HallynLocal variables:
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-omittag:t
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-shorttag:t
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-minimize-attributes:nil
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-always-quote-attributes:t
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-indent-step:2
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-indent-data:t
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-parent-document:nil
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-default-dtd-file:nil
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-exposed-tags:nil
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-local-catalogs:nil
11cddd70eb8c285287b73562ba4208d74e1b9fdeSerge Hallynsgml-local-ecat-files:nil