View previous topic :: View next topic |
Author |
Message |
lefsha Veteran
Joined: 30 Aug 2004 Posts: 1235 Location: Burgas, Bulgaria
|
Posted: Fri Nov 06, 2020 10:41 pm Post subject: How to run systemd based Ubuntu in LXC container |
|
|
Hi,
After playing with VirtualBox, then with KVM have decided to use LXC container
for running Caelinux, which is Ubuntu with systemd init bloatware.
It won't work straight away with openrc based Gentoo.
Here are the steps I did to run it.
1. Create a partition / dataset for containers. In my case:
Code: | zfs create <dataset>
zfs set mountpoint=/var/lib/lxc <dataset>
|
2. Create a container:
Code: | lxc-create -t download -n <container> |
answer questions.
3. Create cgroups for devices and systemd:
Code: | #!/bin/sh
cg_path=/sys/fs/cgroup
group=devices
gr_path=$cg_path/$group
if [ ! -d $gr_path ]; then
mount -o remount,rw $cg_path
mkdir -p $gr_path
mount -t cgroup -o $group $group $gr_path
mount -o remount,ro $cg_path
fi
group=systemd
gr_path=$cg_path/$group
if [ ! -d $gr_path ]; then
mount -o remount,rw $cg_path
mkdir -p $gr_path
mount -t cgroup -o none,name=$group $group $gr_path
mount -o remount,ro $cg_path
fi
|
I was trying to use the same syntax for mount, didn't work. Mount for systemd has been found
on that forum. Mount for devices somewhere else.
4. Start the container
Code: | lxc-start -n <container> |
5. Attach to console:
Code: | lxc-attach -n <container> |
6. Add root password or create a user - up to you:
7. Stop the container:
Code: | lxc-stop -n <container> |
8. Start the container with login to console:
Code: | lxc-start -n <container> -F |
Now you can update the system, Install openssh or do what ever you pleased to.
Cheers, _________________ Lefsha |
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3918
|
Posted: Fri Nov 06, 2020 11:22 pm Post subject: |
|
|
In my case it seems much simpler:
I use LXD
Code: |
mkdir -p /sys/fs/cgroup/systemd
mount -t cgroup -o none,name=systemd systemd /sys/fs/cgroup/systemd
|
in /etc/rc.conf
Code: |
rc_cgroup_mode="legacy"
|
And then
Code: |
lxc launch ubuntu:focal/amd64 myubuntu
|
And it is done.
Although I dont know if it will work with your particular flavor of ubuntu.
Running systemd container from openrc shouldnt be a problem.
I think running openrc container from openrc might pose some problems...... _________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|