$ apt-get install debootstrap lxc lxc-templates lxctl cgroup-lite rsync
$ nano /etc/init/lxc-net.conf USE_LXC_BRIDGE="true"
LXC_AUTO="true"
$ nano /etc/init/lxc.conf
$ nano /etc/default/lxc
$ lxcRoot="/lxc"
$ mkdir -p ${lxcRoot}
$ mkdir /${lxcRoot}/lxclib /${lxcRoot}/lxccache
$ rm -rf /var/lib/lxc /var/cache/lxc
$ ln -s /${lxcRoot}/lxclib /var/lib/lxc $ ln -s /${lxcRoot}/lxccache /var/cache/lxc
$ lxc-create -t ubuntu -n hName -r trusty
$ cd /lxc/lxclib/hName/rootfs
$ mkdir common
$ mv bin lib lib64 sbin usr common/
$ ln -s common/bin $ ln -s common/sbin $ ln -s common/lib $ ln -s common/lib64 $ ln -s common/usr
$ mkdir -p /lxc/lxclib/Node1/rootfs
$ cd /lxc/lxclib/Node1/rootfs
$ rsync --exclude=/dev/* --exclude=/common/* -avz /lxc/lxclib/hName/rootfs/* ./
$ mkdir /lxc/lxclib/Node1/rootfs/common $ mkdir /lxc/lxclib/Node1/rootfs/dev
$ mount --bind /lxc/lxclib/hName/rootfs/dev /lxc/lxclib/Node1/rootfs/dev $ mount --bind /lxc/lxclib/hName/rootfs/common /lxc/lxclib/Node1/rootfs/common $ mount -o remount,ro /lxc/lxclib/Node1/rootfs/common
$ cp /lxc/lxclib/hName/config /lxc/lxclib/Node1/ $ cp /lxc/lxclib/hName/fstab /lxc/lxclib/Node1/
$ nano /lxc/lxclib/Node1/config
#!/bin/bash echo " : " read Container cp -a /lxc/lxclib/Node1 /lxc/lxclib/${Container} mount --bind /lxc/lxclib/hName/rootfs/dev /lxc/lxclib/${Container}/rootfs/dev mount --bind /lxc/lxclib/hName/rootfs/common /lxc/lxclib/${Container}/rootfs/common mount -o remount,ro /lxc/lxclib/${Container}/rootfs/common sed -i 's/Node1/'$Container'/g' /lxc/lxclib/${Container}/config echo " " $Container ""
$ du –skh /lxc/lxclib/_
Source: https://habr.com/ru/post/227599/
All Articles