Lxd: LXD support on Centos

Created on 1 Mar 2017  Â·  17Comments  Â·  Source: lxc/lxd

Hello,

it s not really an issue. I need to set up lxd on centos server. This package is not on the standard repository. So , my question is : does LXD support on Centos. If yes, i want to know how setting up ?

Best regards

Most helpful comment

Any chance of LXD supporting CentOs better? I ask because CentOs is the defacto install for so many Enterprise environments. I don't mind there being more packages to install or something. Just a cleaner install with all the features working would be nice. The one that I see is a hack....

I tried following the guide and I wasn't able to spin up a node ... I left my comments in that page.

All 17 comments

I'm not sure how interoperable Fedora and CentOS are but @ganto has a Fedora repo (https://github.com/ganto) and he might also now more.

ping @stgraber, you recently had a list of distros that have a package.

Ok , i m gonna look it.
My purpose :
i want a centralized server which backup LXD containers ( containers to tarball). To do it, i need LXD dameon and commands ( lxc snapshot, publish and export). I got a server under centos and i don't want to change distro.

If you are using Fedora, you can install LXD from my ganto/lxd COPR repository.

Originally I intended to also build the packages for CentOS 7. But unfortunately CentOS is missing a lot more golang package dependencies of LXD. And since I don't intend to use LXD on CentOS, I wasn't happy about the additional effort and therefore dropped the idea again. Also I wouldn't feel comfortable offering packages that I don't personally use and care.

As the LXD binaries (/usr/bin/lxd, /usr/bin/lxc) are technically statically linked executables, it might be possible to use the RPM from Fedora. lxcfs might already (or with minimal changes) build for CentOS 7 with the spec file from my repository.

I've helped someone sort out LXD on Centos 7 before and the following kinda worked:

yum install wget rsync libseccomp golang sqlite-devel git dnsmasq squashfs-tools
wget https://kojipkgs.fedoraproject.org//packages/lxc/2.0.7/1.fc24/x86_64/lxc-libs-2.0.7-1.fc24.x86_64.rpm
wget https://kojipkgs.fedoraproject.org//packages/lxc/2.0.7/1.fc24/x86_64/lxc-devel-2.0.7-1.fc24.x86_64.rpm
rpm -ivh lxc-libs-2.0.7-1.fc24.x86_64.rpm
rpm -ivh lxc-devel-2.0.7-1.fc24.x86_64.rpm
export GOPATH=/root/go && export PATH=/root/go/bin/:$PATH
vi ~/.bash_profile (update with GOPATH & new PATH)
go get -v -x -tags libsqlite3 github.com/lxc/lxd/lxc
go get -v -x -tags libsqlite3 github.com/lxc/lxd/lxd
grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
reboot
lxd --debug (in a separate terminal)
lxd init

Note that this is obviously very hackish, but it did result in a working LXD.

Thanks four your answers. When i get time, i ll set LXD on my Centos.
I ll give you my feedback.

I've been working up some installation instructions that include installing LXD on Centos. You might find this useful as well: https://gist.github.com/AdamIsrael/e6b4a540233a7be6d28decd917b60c3d

@AdamIsrael
The gist on your link worked for me on CentOS 7, with the minor fix of the user and group missing.

Any chance of LXD supporting CentOs better? I ask because CentOs is the defacto install for so many Enterprise environments. I don't mind there being more packages to install or something. Just a cleaner install with all the features working would be nice. The one that I see is a hack....

I tried following the guide and I wasn't able to spin up a node ... I left my comments in that page.

I've made an script based on some online solutions. It worked for me. I hope it would be useful for you.

centosLXD.sh.txt

#!/bin/sh

#LXD on CENTOS 7
# Made by Jeovane : 29/09/2017
# jeovanevs at gmail
# Based on:
# https://www.hiroom2.com/2017/03/24/centos-7-run-containers-with-lxd-lxc/
# https://github.com/lxc/lxd/issues/2984
# https://gist.github.com/AdamIsrael/e6b4a540233a7be6d28decd917b60c3d

# find /lib/systemd/system -maxdepth 1 \
# -type f -exec sed -e 's/umount\.target//g' -i {} \;
# systemctl --system daemon-reload

sudo yum install -y epel-release wget
###############################################################################
#                           LXC install methods:
# ####################################[1]######################################
# #[Install LXC 2.0 from fedora repo]
# #Download packages
# sudo yum install -y rpmdevtools rpm-build graphviz    
# F=https://dl.fedoraproject.org/pub/fedora/linux/releases/26
# L=${F}/Everything/source/tree/Packages/l
# RPM = lxc-2.0.8-2.fc26.src.rpm
# wget -q ${L}/${RPM}
# # Rebuild deps
# sudo yum-builddep -y ${RPM}
# rpmbuild --rebuild ${RPM}
# # Install package.
# # shellcheck disable=SC2046
# sudo yum localinstall -y $(find ~/rpmbuild/RPMS -type f -a ! -name "*debuginfo*")
#
# ####################################[2]######################################
# #[Install LXC 2.0 from fedora Koji server]     
# # Koji is the official package build server(s) for the Fedora Project. Every rpm 
# # package that ends up in the official Fedora repositories (3rd party rpms such as 
# # RPM Fusion excluded) is built on the koji build server. The only difference
# # between the packages on koji and those in the yum repositories are that the 
# # ones on koji have not been "signed" with the gpg key. Search packages in:  
# # https://koji.fedoraproject.org/koji/packageinfo?packageID=8889
#
# # download packages
# # base url
# B=https://kojipkgs.fedoraproject.org//packages/lxc/
# # lxc version
# V=2.0.8
# # Fedora releases x.fc, x=1 (alpha), x=2 (beta)
# R=2.fc27
# # Arch
# A=x86_64
# # download Lib and devel packages
# wget ${B}/${V}/${R}/${A}/lxc-libs-${V}-${R}.${A}.rpm
# wget ${B}/${V}/${R}/${A}/lxc-devel-${V}-${R}.${A}.rpm
# # Install packages.
# rpm -ivh lxc-libs-${V}-${R}.${A}.rpm
# rpm -ivh lxc-devel-${V}-${R}.${A}.rpm
#
####################################[3]########################################
#[Install LXC 2.0 from COPR repositories]
# Copr (Cool Other Package Repo) is a Fedora project to help make building and
# managing third party package repositories easy. The instance to be installed
# within Fedora Infrastructure provides Fedora maintainers with the ability to
# create repos of packages to build against and share with others. 
sudo yum -y install python-requests
# install copr plugin:
# https://copr.fedorainfracloud.org/coprs/alonid/yum-plugin-copr/
rpm --nodeps -i \
https://copr-be.cloud.fedoraproject.org/results/alonid/yum-plugin-copr/\
epel-7-x86_64/00110045-yum-plugin-copr/\
yum-plugin-copr-1.1.31-508.el7.centos.noarch.rpm
# enable thm/lxc2.0 repository: https://copr.fedorainfracloud.org/coprs/thm/lxc2.0/
sudo yum -y copr enable thm/lxc2.0
# Install packages.
sudo yum -y install lxc lxc-devel
###############################################################################

#[Install LXD methods: download packages or compile from source]
sudo yum install -y rsync libseccomp golang sqlite-devel git dnsmasq squashfs-tools golang-bin make libacl-devel
# make go packages dir
sudo mkdir /root/go
#Add to path
export GOPATH=/root/go && export PATH=${GOPATH}/bin/:$PATH

# # Method 1: [get LXD packages from github]
# go get -v -x -tags libsqlite3 github.com/lxc/lxd/lxc
# go get -v -x -tags libsqlite3 github.com/lxc/lxd/lxd

# Method 2: [Build LXD from source]
go get github.com/lxc/lxd
cd $GOPATH/src/github.com/lxc/lxd
make

#Add execs to /usr/bin (copy or link)
# sudo cp "${GOPATH}"/bin/* /usr/bin/
sudo ln -s $GOPATH/bin/* /usr/bin

# Running container needs user_namespace.enable=1.
# # method 1: need to reboot
# grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
# reboot

# method 2: install grub2-tools and update config
sudo yum install -y grub2-tools
. /etc/default/grub
V="$GRUB_CMDLINE_LINUX user_namespace.enable=1"
sudo sed -e "s;^GRUB_CMDLINE_LINUX=.*;GRUB_CMDLINE_LINUX=\"$V\";g" \
-i /etc/default/grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg

# Start LXD manually or create a service
# # manually
# lxd --debug #(in a separate terminal)


# Create systemd service and socket.

sudo su -c '
cat <<EOF > /usr/lib/systemd/system/lxd.service
[Unit]
Description=LXD Container Hypervisor- main daemon
After=network.target
Requires=network.target lxd.socket network.service
Documentation=man:lxd(1)

[Service]
EnvironmentFile=-/etc/environment
ExecStart=/usr/bin/lxd --group lxd --logfile=/var/log/lxd/lxd.log
ExecStartPost=/usr/bin/lxd waitready --timeout=600
KillMode=process
TimeoutStartSec=600
TimeoutStopSec=40
KillSignal=SIGPWR
Restart=on-failure
LimitNOFILE=infinity
LimitNPROC=infinity
#LimitNOFILE=-1
#LimitNPROC=-1

[Install]
WantedBy=multi-user.target
Also=lxd.socket
EOF
'
sudo su -c '
cat <<EOF > /usr/lib/systemd/system/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
EOF
'
#[Start LXD daemon]
#Once you've saved that file, enable, start, and set the service to start on boot:
sudo adduser --system lxd --home /var/lib/lxd/ --shell /bin/false
sudo groupadd --system lxd
sudo mkdir -p /var/log/lxd
sudo chown root:lxd /var/log/lxd
sudo systemctl --system daemon-reload
sudo systemctl enable lxd
sudo systemctl start lxd

# Run LXD for initialization.
cat <<EOF | sudo lxd init
yes
default
dir
no
yes
yes
lxdbr0
auto
auto
EOF

# Add user to lxd for running lxc command without privilege.
USER_ADDED_TO_LXD_GROUP="${USER}"
sudo gpasswd -a "${USER_ADDED_TO_LXD_GROUP}" lxd

# Reboot.
sudo reboot

# #[Testing LXD]
# lxc launch ubuntu:16.04
# lxc list

Only that solution worked for me:
https://github.com/aleph-zero/lxd-centos-7#running-a-container

enable the centosplus repo before install as well as epel and the script above works.

My European tone will make me sound rude.

Firstly, this is closed.

Secondly, I don't think LXD is supportd on modern cent7 kernels.

Lol. Not rude, fact. Just a comment on script above. I used it and it's
working....

On Tue, Jan 2, 2018, 8:14 AM ApertureSecurity notifications@github.com
wrote:

My European tone will make me sound rude.

Firstly, this is closed.

Secondly, I don't think LXD is supportd on modern cent7 kernels.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/lxc/lxd/issues/2984#issuecomment-354803211, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AI1CT0P0KAO2eMMLCX5qboBPsXkHeReVks5tGlXXgaJpZM4MPtHp
.

>

Brian Collins
[email protected]

Can you send me your uname -a ?

On Jan 2, 2018 17:14, "ApertureSecurity" notifications@github.com wrote:

My European tone will make me sound rude.

Firstly, this is closed.

Secondly, I don't think LXD is supportd on modern cent7 kernels.

Please take a look at
https://discuss.linuxcontainers.org/t/centos-7-kernel-514-693-cannot-start-any-nodes-after-update/641/16?u=brauner
whether that solves your issue.

Linux raistlin.core.skyscale.com 3.10.0-693.11.1.el7.x86_64 #1 SMP Mon Dec
4 23:52:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

On Tue, Jan 2, 2018 at 10:12 AM Christian Brauner notifications@github.com
wrote:

On Jan 2, 2018 17:14, "ApertureSecurity" notifications@github.com wrote:

My European tone will make me sound rude.

Firstly, this is closed.

Secondly, I don't think LXD is supportd on modern cent7 kernels.

Please take a look at

https://discuss.linuxcontainers.org/t/centos-7-kernel-514-693-cannot-start-any-nodes-after-update/641/16?u=brauner
whether that solves your issue.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/lxc/lxd/issues/2984#issuecomment-354835889, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AI1CT2ozI1NxQxe5bj79PsatTUHY3wQoks5tGnGAgaJpZM4MPtHp
.

--

Brian Collins
[email protected]

Please take a look at this thread and report back whether that solves your issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mlaradji picture mlaradji  Â·  4Comments

fwaggle picture fwaggle  Â·  4Comments

AndreiPashkin picture AndreiPashkin  Â·  5Comments

srkunze picture srkunze  Â·  3Comments

iteco picture iteco  Â·  3Comments