[lxc-users] lxc-clone and LVM backingstorage

Serge Hallyn serge.hallyn at ubuntu.com
Thu Feb 27 01:39:38 UTC 2014


Quoting Thomas Dalichow (info at thomasdalichow.de):
> Cheers guys,
> 
> I'm currently fooling around a little with LXC 1.0 on the latest Ubuntu
> (Desktop) 14.04 daily build (current).
> 
> I created a physical volume and a volume group on top of it named vg1
> and created a container as follows:
> 
>    $: lxc-create -t download -n 1 -B lvm --fssize 1G --vgname vg1
> --lvname lv-1 -- -d ubuntu -r trusty -a amd64
> 
> This worked...
> 
>    Logical volume "lv-1" created
>    Setting up the GPG keyring
>    Downloading the image index
>    Downloading the rootfs
>    Downloading the metadata
>    The image cache is now ready
>    Unpacking the rootfs
> 
>    ---
>    You just created an Ubuntu container (release=trusty, arch=amd64).
> 
> Now on trying to clone I got the error
> 
>    $: lxc-clone -o 1 -n 2
>      Volume group "vg2" not found
>    lxc_container: Error creating new lvm blockdev
>    lxc_container: failed getting pathnames for cloned
> storage: /dev/vg1/lv-1
>    lxc_container: Error copying storage
> 
> Renaming the volume group (vg1) to "lxc" and renaming the logical volume
> of the container (lv-1) and of course modifying the rootfs of container
> "1" did the trick:
> 
>    $: vgrename vg1 lxc
>      Volume group "vg1" successfully renamed to "lxc"
>    $: lvrename /dev/lxc/lv-1 1
>      Renamed "lv-1" to "1" in volume group "lxc"
>    $: lxc-clone -o 1 -n 2
>      Logical volume "2" created
>    Created container 2 as copy of 1
> 
> Now here's my question: is there any naming convention to adhere to in
> order for LXC (especially lxc-clone) to determine the correct name of
> the new LVM device and the underlying volume group?

Yeah.  Lxc-clone can't really know your naming convention *1, so
it searches for the old container name and replaces it with the
new.  So in /dev/vg1/lv-1, instead of making it /dev/vg1/lv-2,
it turned it into /dev/vg2/lv-1.  Just slightly longer names - like
c1 and c2 - and you should be fine  :)

-serge

*1 - for instance you need it changed after the last '/', but many
containers have /var/lib/lxc/$name/rootfs, and so we can't just say
use the last '/'


More information about the lxc-users mailing list