Lxc containers on another partition

I created two containers (e.g. TestOneContainer and TestTwoContainer) on the ubuntu server using LXC. Now the lxc file system is located in the / home folder, and two containers also use the / home folder. I created two partitions (100 GB for TestOneContainer and 200 GB for TestTwoContainer) for these two containers when installing the Ubuntu OS server. I want to install TestOneContainer on 100 GB of space and TestTwoContainer on 200 GB of space. How can i do this?

I tried these commands from this

create and symbolize two directories:

sudo mkdir /srv/lxclib /srv/lxccache
sudo rm -rf /var/lib/lxc /var/cache/lxc
sudo ln -s /srv/lxclib /var/lib/lxc
sudo ln -s /srv/lxccache /var/cache/lxc

or using bindings:

sudo mkdir /srv/lxclib /srv/lxccache
sudo sed -i '$a \
/srv/lxclib /var/lib/lxc    none defaults,bind 0 0 \
/srv/lxccache /var/cache/lxc none defaults,bind 0 0' /etc/fstab
sudo mount -a

But these commands should mount lxc on a different file system, not TestOneContainer or TestTwoContainer.

+4
2

, 100 /mnt/sd 1, 200GB /mnt/sd 2, / , :

#create mount point from host
sudo mkdir /var/lib/lxc/TestOneContainer/rootfs/work
sudo mkdir /var/lib/lxc/TestTwoContainer/rootfs/work

#mount them from host
sudo mount --bind /mnt/sd1/ /var/lib/lxc/TestOneContainer/rootfs/work
sudo mount --bind /mnt/sd2/ /var/lib/lxc/TestTwoContainer/rootfs/work

, /

df -h
+1

LXC,

→    .

.

+1

All Articles