LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-10-2019, 02:48 PM   #1
PRNG
LQ Newbie
 
Registered: Jul 2016
Distribution: Slackware
Posts: 22

Rep: Reputation: Disabled
LXC 3.0 and Slackware


I saw "new" release of LXC https://discuss.linuxcontainers.org/...-released/1449
Is it possible to upgrade LXC from LTS branch to version 3 on Slackware current? The cgmanager is removed and I don't know if it is possible to use containers without systemd or cgmanager.
 
Old 01-11-2019, 10:18 AM   #2
alex14641
Member
 
Registered: Feb 2016
Distribution: Slackware64_14.2, Slackware 15.0, Slackware64_current
Posts: 321

Rep: Reputation: Disabled
I've created unprivileged Ubuntu containers, with networking, with LXC 3 on -current. There's some system configuration necessary to make it work, though. I don't think LXC needs cgmanager. Strange thing: removing cgmanager breaks the power manager applet in XFCE.
 
Old 01-12-2019, 03:33 AM   #3
PRNG
LQ Newbie
 
Registered: Jul 2016
Distribution: Slackware
Posts: 22

Original Poster
Rep: Reputation: Disabled
Great! I will try LXC 3 ASAP.
If you can, write up what changes have you made in ored to make it work.
 
Old 01-13-2019, 05:51 PM   #4
alex14641
Member
 
Registered: Feb 2016
Distribution: Slackware64_14.2, Slackware 15.0, Slackware64_current
Posts: 321

Rep: Reputation: Disabled
Setting up LXC 3.x to run unprivileged containers.

As you:
1) Download the source for lxc-3.0.3.tar.gz and lxcfs-3.0.3.tar.gz.
2) Untar lxc-3.0.3 and lxcfs-3.0.3
3) cd lxc-3.0.3
4) ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64 --localstatedir=/var --mandir=/usr/man --docdir=/usr/doc/lxc-3.0.3 --infodir=/usr/info --infodir=/usr/info --with-global-conf=/etc/lxc/lxc.conf --with-rootfs-path=/var/lib/rootfs-lxc
5) make -j8
6) cd ../lxcfs-3.0.3
7) ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64 --localstatedir=/var --mandir=/usr/man --docdir=/usr/doc/lxcfs-3.0.3 --infodir=/usr/info --with-rootfs-path=/var/lib/rootfs-lxc
8) make -j8
9) Create the file $HOME/.config/lxc/default.conf with the following contents:
Code:
lxc.idmap = u 0 131072 65536
lxc.idmap = g 0 131072 65536
lxc.mount.auto = cgroup
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.name = eth0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
lxc.environment = PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
lxc.environment = HOME=/root
lxc.environment = USER=root
As root:
10) removepkg lxc-2.0.9
11) cd lxc-3.0.3
12) make install
13) cd ../lxcfs-3.0.3
14) make install
15) Create the file /etc/subuid with the following contents:
Code:
root:65536:65536
<your uid>:131072:65536
Replace <your uid> with your user ID.
16) Create the file /etc/subgid with the following contents:
Code:
root:65536:65536
<your gid>:131072:65536
Replace <your gid> with your group ID.
17) mount -t cgroup -o rw,noexec,nosuid,nodev,none,name=systemd systemd /sys/fs/cgroup/systemd
18) cgcreate -g name=systemd:lxc -g *:lxc -a <your uid>:<your gid> -t <your uid>:<your gid>
Replace <your uid> and <your gid> with your user ID and your group ID, respectively.
19) /usr/libexec/lxc/lxc-net start
20) lxcfs -s -o allow_other /var/lib/lxcfs/ &
21) modprobe autofs4

As you:
22) cgexec -g *:lxc bash
23) Create a Debian container:
lxc-create -t download -n debian -- -d debian -r stretch -a amd64
24) Start the container:
lxc-start debian
25) Attach to the container:
lxc-attach debian
You should now be able to run 'apt install' to install packages.

Last edited by alex14641; 01-20-2019 at 11:45 AM. Reason: Added systemd related cgroup to allow automatic starting of networking in the container
 
6 members found this post helpful.
Old 01-14-2019, 01:16 AM   #5
PRNG
LQ Newbie
 
Registered: Jul 2016
Distribution: Slackware
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thank you Alex!

I have fixed power manager applet in XFCE by recompiling ConsoleKit2 with
Code:
--enable-cgroups=no \
 
Old 01-14-2019, 04:08 AM   #6
franzen
Member
 
Registered: Nov 2012
Distribution: slackware
Posts: 535

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
Quote:
Originally Posted by alex14641 View Post
*) cd ../lxcfs-3.0.3
I didn't test, but it seems lxcfs has become optional even for systemd based containers/guests. From https://linuxcontainers.org/lxcfs/introduction/:
Quote:
The main driver for this[lxcfs] work was the need to run systemd based containers as a regular unprivileged user while still allowing systemd inside the container to interact with cgroups.
Now with the introduction of the cgroup namespace in the Linux kernel, that part is no longer necessary on recent kernels and focus is now on making containers feel more like a real independent system through the proc masking feature.
 
Old 01-14-2019, 06:17 AM   #7
alex14641
Member
 
Registered: Feb 2016
Distribution: Slackware64_14.2, Slackware 15.0, Slackware64_current
Posts: 321

Rep: Reputation: Disabled
Quote:
Originally Posted by franzen View Post
I didn't test, but it seems lxcfs has become optional even for systemd based containers/guests. From https://linuxcontainers.org/lxcfs/ introduction/:
Lxcfs is still needed for containers to have their own copies of /proc/uptime and some other /proc files. Without lxcfs, running the uptime command in the containers returns the uptime of the host.
 
Old 01-14-2019, 06:39 AM   #8
franzen
Member
 
Registered: Nov 2012
Distribution: slackware
Posts: 535

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
Quote:
Originally Posted by alex14641 View Post
Lxcfs is still needed for containers to have their own copies of /proc/uptime and some other /proc files. Without lxcfs, running the uptime command in the containers returns the uptime of the host.
So it may be useful, but it's not a hard dependency.
 
Old 01-14-2019, 05:09 PM   #9
alex14641
Member
 
Registered: Feb 2016
Distribution: Slackware64_14.2, Slackware 15.0, Slackware64_current
Posts: 321

Rep: Reputation: Disabled
Quote:
Originally Posted by franzen View Post
So it may be useful, but it's not a hard dependency.
Correct.
 
Old 01-20-2019, 08:25 AM   #10
alex14641
Member
 
Registered: Feb 2016
Distribution: Slackware64_14.2, Slackware 15.0, Slackware64_current
Posts: 321

Rep: Reputation: Disabled
I made some changes to the instructions to allow automatically starting the network when starting the container.

There is a Slackware LXC template, but currently it can only be run as a privileged container.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Slackware 14.2 lxc-slackware template missing libunistring mralk3 Slackware 5 09-13-2018 12:46 AM
[SOLVED] "lxc list" vs "lxc-ls" yknivag Linux - Virtualization and Cloud 1 03-09-2017 05:53 AM
[SOLVED] [LXC] Slackware 14.1 rc1 - Upgraded host & container Chuck56 Slackware 3 10-16-2013 05:58 AM
slackware lxc / iptables ccie15672 Linux - Virtualization and Cloud 0 02-26-2012 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration