LXC container (virual server) on specific location?

Continuing the discussion from What about Documentation?:

The LXC documentation is rudimentary describing how to setup an LXC-container, however:

  • Can anyone explain how to place the container on a specific location (or point me to the right site where it is explained)?

I’m asking as I am planning to place them first on a mounted thumb/usb-drive and later migrate them to n internal mSATA-SSD inside the Omnia).

Well, by default all lxc containers are installed in /srv/lxc, so the easiest solution would be mount your thumb-drive either as /srv/lxc or more generally as /srv and later you can just stop them, copy stuff to mSATA and mount mSATA into correct location.

Aha! Thanks for the quick response @miska !!

What about storing each individual one on separate locations (so different mounts). Is that configurable somewhere (I realize these are fairly LXC-specific questions, but hey… I’m sure many Omnia backers are intereted!

If I find it out myself elsewhere I’ll post it here too ofc.!

ok - I haven’t played with lxc on arm device yet but if you check e.g. https://help.ubuntu.com/lts/serverguide/lxc.html then you see that you can specify lxcpath in lxc.system.com (see the Baking store section).

If you wanted to store each container in different folder / partition then you may try to create the folders in lxcpath as symbolic links to the destination folder where you want to store them. You can try and experiment with it.

1 Like

Actually each LXC container has a config where you specify lxc.rootfs which is by default /srv/lxc/container-name/rootfs and it should be possible to override to whatever you want after installation and moving the data.

1 Like

@radekpribyl - Thanks

That is worth a shot (once I get my Omnia :stuck_out_tongue:) isntead or even in combination with @miska’s first suggestion!

You guys rawk! So much to do once that little device hits my doormat (may try some stuff on an arbitrary computer before that though if I can find the time)!

Also; when creating the container using the -P flag targets another location, I think.

From the lxc-create man-page:

-P, --lxcpath=PATH               Use specified container path`
1 Like

Would you care to confirm wheather this worked and then write out the complete command you used? Thanks @woosting!

I would have, but I never tried the option. Sorry.

Instead; I simply mounted an external drive to /srv/lxc and create my containers there via the Luci interface (for now), as was proposed by Miska. This was/is the most straightforward really (I also used the Luci interface to mount the external drive).

The LXC version on the Omnia is pretty slimmed down (some dependencies even containing bugs), so I try to stay as close to the “Omnia way of working” (that command was copy/pasted from the man page of the regular/Debian LXC package), which until now has not yet disapointed me.

1 Like

Fair enough. May go that route as well. Seems to be the easiest way of doing it.

As i don’t want to dedicate whole partition/mount-point for /srv/lxc … i am using mount --bind <source_Folder> <destination_Folder> instead whole partition.

1 Like

symbolic links work just as well

mv /srv/lxc /srv/lxc.out
ln -sf /some/directory /srv/lxc

Works just fine, no worries about messing with config files.

3 Likes

cat /etc/lxc/lxc.conf

lxc.lxcpath = /mnt/backups/lxc

3 Likes