Skip to content

LXC V Server

matveynator edited this page Jun 7, 2023 · 6 revisions

LXC commands:

show running virtual machines:

lxc-ls -f

attach to running virtual machine:

lxc-attach --name lxc.name

start/stop virtual machine:

lxc-start name
lxc-stop name

V-Server commands:

show running virtual machines:

vserver-stat

attach to running virtual machine:

vserver name enter

start/stop virtual machine:

vserver start name
vserver stop name

lxc convert from vserver script Debian9 (lxc2.0):

curl -L "https://git.io/JMHwJ" > /usr/local/bin/lxc-convert-from-vserver; chmod +x /usr/local/bin/lxc-convert-from-vserver; /usr/local/bin/lxc-convert-from-vserver 

#disable systemd-networkd as it is A SHIT:

systemctl disable systemd-networkd

auto br0
iface br0 inet loopback
bridge_ports none
bridge_fd 0
bridge_hello 2
bridge_maxage 12
bridge_stp off

SELECTEL /etc/network/interfaces

source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback

auto eno1
iface eno1 inet manual

auto br0
iface br0 inet static
address 1.2.3.4
netmask 255.255.255.240
gateway 1.2.3.3
bridge_ports eno1
bridge_fd 0
bridge_hello 2
bridge_maxage 12
bridge_stp off
dns-nameservers 1.1.1.1 8.8.8.8
up ip route add 1.2.3.5/32 dev br0

unprivilegged

cat > /var/lib/lxc/${name}/config <<EOF
lxc.start.auto = 1
lxc.rootfs.path = /var/lib/lxc/${name}/rootfs
lxc.include = /usr/share/lxc/config/debian.common.conf
lxc.mount.fstab = /var/lib/lxc/${name}/fstab
lxc.uts.name = ${name}
lxc.arch = amd64
lxc.autodev = 1
lxc.cgroup.memory.limit_in_bytes = ${memory}
lxc.cgroup.cpuset.cpus = ${cpus}
lxc.mount.auto = cgroup-full:rw
lxc.apparmor.profile = unconfined
lxc.cgroup.devices.allow = a

lxc.net.0.type = veth
lxc.net.0.flags = up
lxc.net.0.name = eth0
lxc.net.0.link = br0
lxc.net.0.ipv4.address = ${eth0ipv4}/${eth0prefix}
lxc.net.0.ipv4.gateway = ${eth0gateway}
EOF
Clone this wiki locally