Search code examples
linuxlxcmount-pointlxd

LXC using separate HDD/VOLUME


Is there some method how can I define the major device (hdd, volume, ..) for LXC container?

I have separated disks for each service/project which I want run inside LXC container. But I couldn't find the way how can I specify storage for all files in the container. I mean whole container (/, /home, /var,...)

So finally I want to create this association 1 service/project == 1 container == 1 HDD

Is it possible?


Solution

  • You can create storage pools for each of your disks. Then, when you create a LXD container, you can specify on which storage pool to be created in.

    The commands to create the storage pools are:

    lxc storage create pool1 zfs source=/dev/sdb
    lxc storage create pool2 zfs source=/dev/sdc
    lxc storage create pool3 zfs source=/dev/sdd
    
    

    The commands to launch containers on specific storage pools are:

    lxc launch ubuntu:20.04 container1 --storage pool1
    lxc launch ubuntu:20.04 container2 --storage pool2
    lxc launch ubuntu:20.04 container3 --storage pool3
    

    Do note that such a setup may not be very optimal. See whether you can use either ZFS, LVM, or btrfs. With any of them, you can specify to use all those disks together in some form of RAID. More at https://linuxcontainers.org/lxd/docs/master/storage