Lxd-4.4 build from tar ball does not even do any command w/o error

Cause I didn’t want to install snap on LM20 ulyana , I downloaded the latest, stable tarball lxd 4.4 and built it myself, following this description here: https://github.com/lxc/lxd/#installing-lxd-from-source

Everything compiled fine so far, until doing the last command:
sudo -E PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH $GOPATH/bin/lxd --group sudo

I got this warnings below, which i definitely don’t know exactly what they mean or if they are really significant:

WARN[08-03|18:25:36]  - Couldn't find the CGroup blkio.weight, I/O weight limits will be ignored
WARN[08-03|18:25:36]  - Couldn't find the CGroup memory swap accounting, swap limits will be ignored 
WARN[08-03|18:25:36] Firewall failed to detect any compatible driver, falling back to "xtables" (but some features may not work as expected due to: Backend command "ebtables" is an nftables shim) 

Also the command doesn’t get back to prompt. I have to Ctrl-C it.

The daemon (lxd) doesn’t run (ps axf | grep lxd) is empty and typing “lxc info” i.e. get’s me this error:
Error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connect: no such file or directory

Really appreciating any hints, cause I don’t know how to proceed.

Install nft on your system, that should sort that one out.

Can you provide the full start up logs for LXD, as although installing nft will likely fix the firewall error, the error itself shouldn’t be fatal, and it should fallback to using xtables. So none of those look like the root cause.

Note that the command will never return, it’s a daemon, so when it hangs, it means it’s running, use another shell to talk to it.

1 Like

sry, for my ignorance.

Yes, lxd is working that way now, as you mentioned it (lxc info from another shell).

What would be a proper place to have lxd started permanently (while booting)?

In other words: where to place this command:

sudo -E PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH $GOPATH/bin/lxd --group sudo

And how about the path vars:

export PATH="$PATH:$GOPATH/bin"
export LD_LIBRARY_PATH="${GOPATH}/deps/sqlite/.libs/:${GOPATH}/deps/dqlite/.libs/:${GOPATH}/deps/raft/.libs:${GOPATH}/deps/libco/:${LD_LIBRARY_PATH}" 

for the moment they reside in ~.bashrc
Should I locate them in /etc/bashrc (or profile), that lxd daemon binaries could be found on startup?

Should I add a new group (lxd) and make ‘newgrp lxd’ afterwards? And if so, would the command above to be changed to:

sudo -E PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH $GOPATH/bin/lxd --group lxd
?

Again, thanks in advance for your hints

Usually you’d write some systemd unit file for it so it’s managed by your init system.

Really, I have to do it?
Is there no “make install” for lxd?
I’ve looked at my other box, where LM19.0 is running, and luckily lxd was there still in the apt repositories, cause it relies on Ubuntu18.04.

If look there into lib/systemd/system there at least 3 of those unit files

  • lxd.service
  • lxd.socket
  • lxd-containers.service

and some of them link to different places of lxd’s in the system (/var/lib, /usr/lib/ ,…)
furtheron some add. scripts, etc.

Really, for sure I cannot do this now from the scratch w/o having a mess after booting.

Cannot understand, why there isn’t an install routine for that.
To me seems to be a blind lane, going the “compile-lxd-yourself-way”.
Sry.

The init scripts are distro dependents and so developed and maintained by the distro packager. That’s why you have them for the old deb packaging and why you would have them for the snap were you to use that.

If you do your own thing manually, then you are also responsible for doing that part to suit the location and behavior that you want.

So, in the end, if you don’t want to use snap AND you are on LM20 , you have lost the lxd-game?!

Boah.

You can build and install it by hand and write a systemd unit or someone could step up to maintain a PPA with up to date LXD and dependencies.

As I wrote: there are too much additional scripts etc, looking into all these lxd unit files.
It’s too much task for me.

Maybe I will give docker/kubernetes a chance - even if it will be kinda oversized for my needs.

But nevertheless: Your responses here are exemplary.

At it’s simplest all you need is a basic daemon unit with environment variables set properly.

I guess something like:

[Unit]
Description=LXD

[Service]
Environment="LD_LIBRARY_PATH=/root/go/deps/sqlite/.libs/:/root/go/deps/raft/.libs/:/root/go/deps/dqlite/.libs/:/root/go/deps/libco/"
ExecStart=/root/go/bin/lxd --group sudo
Restart=on-failure
Type=simple

[Install]
WantedBy=multi-user.target

Changing /root/go for wherever the Go tree containing the LXD binary and deps is located on your system.

Dump the unit in /etc/systemd/system/, enable it with systemctl enable lxd and start it with systemctl start lxd.

That’s just off the top of my head so I may have missed something.

Thanks a l lot Stephan in helping me to get this stuff running.

I don’t think, that it will be that easy. I’ll show you, how the unit files look like on the LM19 box:

lxd.service:

[Unit]
Description=LXD - main daemon
After=network-online.target openvswitch-switch.service lxcfs.service lxd.socket
Requires=network-online.target lxcfs.service lxd.socket
Documentation=man:lxd(1)

[Service]
EnvironmentFile=-/etc/environment
ExecStartPre=/usr/lib/x86_64-linux-gnu/lxc/lxc-apparmor-load
ExecStart=/usr/bin/lxd --group lxd --logfile=/var/log/lxd/lxd.log
ExecStartPost=/usr/bin/lxd waitready --timeout=600
KillMode=process
TimeoutStartSec=600s
TimeoutStopSec=30s
Restart=on-failure
LimitNOFILE=1048576
LimitNPROC=infinity
TasksMax=infinity

[Install]
Also=lxd-containers.service lxd.socket

lxd.socket

[Unit]
Description=LXD - unix socket
Documentation=man:lxd(1)

[Socket]
ListenStream=/var/lib/lxd/unix.socket
SocketGroup=lxd
SocketMode=0660
Service=lxd.service

[Install]
WantedBy=sockets.target

lxd-containers.service

[Unit]
Description=LXD - container startup/shutdown
Documentation=man:lxd(1)
After=lxd.socket lxd.service
Requires=lxd.socket

[Service]
Type=oneshot
ExecStart=/usr/bin/lxd activateifneeded
ExecStop=/usr/lib/lxd/shutdown
TimeoutStartSec=600s
TimeoutStopSec=600s
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

wehre in /usr/lib/lxd/

all these files are:

-rw-r–r-- 1 root root 110600 Nov 23 2018 libdqlite.so.0
-rw-r–r-- 1 root root 110600 Nov 23 2018 libdqlite.so.0.0.1
-rw-r–r-- 1 root root 760256 Nov 23 2018 libsqlite3.so.0
-rw-r–r-- 1 root root 760256 Nov 23 2018 libsqlite3.so.0.8.6
-rwxr-xr-x 1 root root 18748376 Nov 23 2018 lxd*
-rwxr-xr-x 1 root root 99 Nov 23 2018 shutdown*
-rwxr-xr-x 1 root root 4957 Nov 23 2018 upgrade-bridge*

and shutdown looks like this:

#!/bin/sh

if ! systemctl -q is-active lxd.service; then
exit 0
fi

exec /usr/bin/lxd shutdown

and upgrade-bridge is too long to post it here.
And the files in /var/lib/lxd justs exists. So here it will be not necessary to add something, imo.
Btw: the name (lxd) in this cmd
systemctl enable lxd
will for sure depends on the unit file prefix name.
so how about lxd-containers.service ? this unit is not referred by the other units?

Sry, for that much text.

PS. sry, what I’ver forgot, that even /usr/bin/lxd is a script:

#!/bin/sh
# Needed for clustered sqlite3
export LD_LIBRARY_PATH=/usr/lib/lxd/
exec /usr/lib/lxd/lxd "$@"

You don’t need all of those. Yes they were included in the deb but that’s because we supported a lot more upgrade paths and also tried to only start LXD when strictly needed.

I know about all those units and scripts, I’m the one who wrote them :wink:
I’m telling you that you can get the same result with just a single unit in your case.