Is there a simple way to create a container on a loop file


#1

Hello,

i want to use loop files on my hostnode to provide the rootfs for my lxd container. On classic lxc i can do this with a pre-mount script. There is the simplest way to do this with current lxd on centos 7.


#2

Hi!

When you run sudo lxd init, you are prompted for the following. By keeping the default (saying “no”), LXD creates a loop file for you.

Would you like to use an existing block device (yes/no) [default=no]? no

#3

Hello,

thank you for your help, but i want to create a loop file for every container with a specific size. I think this does not help me to do this.


#4

You can manually create a such a loop file with lxc storage. I am not sure how you can direct each container to the exact loopback file. I suppose there should be a way.

Having said that, it is possible with a big loopback file to add containers and get the to occupy up to a size of your choosing. That would obviously be more versatile as you can also resize.