Link to home
Start Free TrialLog in
Avatar of Jasmin shahrzad
Jasmin shahrzad

asked on

installation lxd containers

how to install lxd container in non default directories on ubuntu 18.0.3 server?
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Agree with noci - your containers can be on any location you want, providing you create a symlink to /var/lib/lxd from that location.

To add to be above suggestion: if you already have containers running then stop your containers and LXD, then move your containers to the new location, create the symlink and start everything again.
Maybe describe what you're trying to achieve or some problem you're trying to resolve.

LXD != LXC, so changing directories may cause privilege problems.

With LXC (lxc-create) all containers run as privileged (root) containers.

LXD changes this so all containers run as unprivileged (non-root) containers.

If you try doing this, be sure you do the following.

#
 First remove all APT LXD packages as these are all out of date + will never be updated again
apt-get -y purge liblxc-common liblxc1 lxcfs lxd lxd-client

# Now install SNAP LXD, which is upgraded automagically whenever patches release
snap install lxd

# Now run lxd init to set your alternative storage device (do not muck about with this outside LXD)
lxd init --storage-backend=type --storage-create-device=some-alternative-device

Open in new window


If you muck about with LXD data structures outside LXD, then you'll first have to decode /var/snap/lxd/common/lxd/database/local.db + every time you much about with LXD outside LXD, you'll have to determine how to hack local.db to match your changes.

Tip: Unless you have lots of time on your hands, you'll prefer doing LXD things... the LXD way...

With LXC you could just move things around however you like. LXD will tends to crash if you do anything like LXC allowed.
Open a https://discuss.linuxcontainers.org discussion thread about any LXD hacking + one of the developers will let you know if what you're trying to do will work as you expect.
Avatar of Jasmin shahrzad
Jasmin shahrzad

ASKER

@noci,
first i do not have anything under my /var/lib/lxc.. this directory is empty.
what i want to do is i mount a 6tb disk and in my ubuntu and move one of containers (or create a new ubuntu 18 container) with 3tb disk .
when i search  after my container name (find . -depth -name "my-container*") i can see memory , cpu ,.. place also storage place
 /var/lib/lxcfs/cgroup/cpu,cpuacct/lxc.payload/
/var/lib/lxcfs/cgroup/memory/lxc.payload/
/var/snap/lxd/common/lxd/storage-pools/default/containers/
but this storage i also empty
all my containers has default size all says  (for df -h ) :
default/containers/"container_name 79G(size)  710M(Used) 78G(Avail) ...
where i and (when ) under create define disk place? and how to change it?