2013-09-30 20:57:21 +02:00
|
|
|
== create ==
|
2013-09-29 23:08:39 +02:00
|
|
|
|
2013-09-30 18:23:33 +02:00
|
|
|
* mit lvm
|
2013-09-30 20:57:21 +02:00
|
|
|
*: <source lang="bash">lxc-create -n<container-name> -t <template> -B lvm --lvname <container-name> --vgname <volumen-gruppen-name> --fstype <filesystem-type> --fssize <filesystem-größe></source>
|
2013-09-29 23:08:39 +02:00
|
|
|
|
2013-09-30 18:23:33 +02:00
|
|
|
* ohne lvm
|
2013-09-30 20:57:21 +02:00
|
|
|
*: <source lang="bash">lxc-create -n<container-name> -t <template></source>
|
2013-09-30 18:23:33 +02:00
|
|
|
|
2013-09-30 20:57:21 +02:00
|
|
|
== start ==
|
2013-09-30 18:23:33 +02:00
|
|
|
|
|
|
|
* start
|
2013-09-30 20:57:21 +02:00
|
|
|
*: <source lang="bash">lxc-start -n<container-name> -f</path/to/config/file> -d</source>
|
|
|
|
|
|
|
|
== stop ==
|
2013-09-30 18:23:33 +02:00
|
|
|
|
|
|
|
* stop
|
2013-09-30 20:57:21 +02:00
|
|
|
*: <source lang="bash">lxc-stop -n<container-name></source>
|
2013-09-30 18:23:33 +02:00
|
|
|
|
2013-09-30 20:57:21 +02:00
|
|
|
== config ==
|
2013-09-30 18:23:33 +02:00
|
|
|
|
|
|
|
<pre>
|
|
|
|
## network
|
2013-10-01 02:42:25 +02:00
|
|
|
lxc.network.type = veth
|
|
|
|
lxc.network.link = br0
|
|
|
|
lxc.network.name = eth0
|
|
|
|
lxc.network.hwaddr = 00:00:c3:d2:00:23
|
|
|
|
lxc.network.veth.pair = br0_<container-name>
|
|
|
|
lxc.network.flags = up
|
|
|
|
|
|
|
|
lxc.network.type = veth
|
|
|
|
lxc.network.link = br1
|
|
|
|
lxc.network.name = eth1
|
|
|
|
lxc.network.hwaddr = 00:00:c3:d2:01:23
|
|
|
|
lxc.network.veth.pair = br1_<container-name>
|
|
|
|
lxc.network.flags = up
|
2013-09-30 18:23:33 +02:00
|
|
|
|
|
|
|
## Container
|
|
|
|
lxc.utsname = <container-name>
|
|
|
|
lxc.rootfs = /var/lib/lxc/<container-name>/rootfs
|
|
|
|
lxc.arch = x86_64
|
|
|
|
#lxc.console = /var/log/lxc/<container-name>.console
|
|
|
|
lxc.tty = 2
|
|
|
|
lxc.pts = 1024
|
|
|
|
|
|
|
|
## Capabilities
|
|
|
|
lxc.cap.drop = audit_control
|
|
|
|
lxc.cap.drop = audit_write
|
|
|
|
lxc.cap.drop = linux_immutable
|
|
|
|
lxc.cap.drop = mac_admin
|
|
|
|
lxc.cap.drop = mac_override
|
|
|
|
lxc.cap.drop = setpcap
|
|
|
|
lxc.cap.drop = sys_admin
|
|
|
|
lxc.cap.drop = sys_boot
|
|
|
|
lxc.cap.drop = sys_module
|
|
|
|
lxc.cap.drop = sys_pacct
|
|
|
|
lxc.cap.drop = sys_rawio
|
|
|
|
lxc.cap.drop = sys_time
|
|
|
|
|
|
|
|
## Devices
|
|
|
|
# Allow all devices
|
|
|
|
#lxc.cgroup.devices.allow = a
|
|
|
|
|
|
|
|
# Deny all devices
|
|
|
|
lxc.cgroup.devices.deny = a
|
|
|
|
|
|
|
|
# Allow to mknod all devices (but not using them)
|
|
|
|
lxc.cgroup.devices.allow = c *:* m
|
|
|
|
lxc.cgroup.devices.allow = b *:* m
|
|
|
|
|
|
|
|
# /dev/console
|
|
|
|
lxc.cgroup.devices.allow = c 5:1 rwm
|
|
|
|
# /dev/null
|
|
|
|
lxc.cgroup.devices.allow = c 1:3 rwm
|
|
|
|
# /dev/ptmx
|
|
|
|
lxc.cgroup.devices.allow = c 5:2 rwm
|
|
|
|
# /dev/pts/*
|
|
|
|
lxc.cgroup.devices.allow = c 136:* rwm
|
|
|
|
# /dev/random
|
|
|
|
lxc.cgroup.devices.allow = c 1:8 rwm
|
|
|
|
# /dev/rtc
|
|
|
|
lxc.cgroup.devices.allow = c 254:0 rwm
|
|
|
|
# /dev/tty
|
|
|
|
lxc.cgroup.devices.allow = c 5:0 rwm
|
|
|
|
# tty0
|
|
|
|
lxc.cgroup.devices.allow = c 4:0 rwm
|
|
|
|
# tty1
|
|
|
|
lxc.cgroup.devices.allow = c 4:1 rwm
|
|
|
|
# /dev/urandom
|
|
|
|
lxc.cgroup.devices.allow = c 1:9 rwm
|
|
|
|
# /dev/zero
|
|
|
|
lxc.cgroup.devices.allow = c 1:5 rwm
|
|
|
|
# tun
|
|
|
|
lxc.cgroup.devices.allow = c 10:200 rwm
|
|
|
|
|
|
|
|
## Limits
|
|
|
|
lxc.cgroup.cpu.shares = 1024
|
|
|
|
lxc.cgroup.cpuset.cpus = 0
|
|
|
|
lxc.cgroup.memory.limit_in_bytes = 256M
|
|
|
|
lxc.cgroup.memory.memsw.limit_in_bytes = 1G
|
|
|
|
|
|
|
|
## Filesystem
|
|
|
|
lxc.mount.entry = proc proc proc ro,nodev,noexec,nosuid 0 0
|
|
|
|
lxc.mount.entry = sysfs sys sysfs ro 0 0
|
|
|
|
</pre>
|
|
|
|
|
2013-09-30 20:57:21 +02:00
|
|
|
== console ==
|
2013-09-30 18:23:33 +02:00
|
|
|
|
2013-09-30 20:57:21 +02:00
|
|
|
=== <code>''</path/to/conatiner/rootfs>''/etc/inittab</code> ===
|
2013-09-30 18:23:33 +02:00
|
|
|
|
|
|
|
<pre>
|
|
|
|
# /sbin/getty invocations for the runlevels.
|
|
|
|
#
|
|
|
|
# The "id" field MUST be the same as the last
|
|
|
|
# characters of the device (after "tty").
|
|
|
|
#
|
|
|
|
# Format:
|
|
|
|
# <id>:<runlevels>:<action>:<process>
|
|
|
|
#
|
|
|
|
# Note that on most Debian systems tty7 is used by the X Window System,
|
|
|
|
# so if you want to add more getty's go ahead but skip tty7 if you run X.
|
|
|
|
#
|
|
|
|
c1:2345:respawn:/sbin/getty 38400 tty1
|
|
|
|
#1:2345:respawn:/sbin/getty 38400 tty1
|
|
|
|
#2:23:respawn:/sbin/getty 38400 tty2
|
|
|
|
#3:23:respawn:/sbin/getty 38400 tty3
|
|
|
|
#4:23:respawn:/sbin/getty 38400 tty4
|
|
|
|
#5:23:respawn:/sbin/getty 38400 tty5
|
|
|
|
#6:23:respawn:/sbin/getty 38400 tty6
|
|
|
|
|
|
|
|
# console
|
|
|
|
1:12345:respawn:/sbin/agetty --noclear 115200 console linux
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
===lxc-console===
|
|
|
|
* VMs auflisten:
|
2013-09-30 20:57:21 +02:00
|
|
|
*: <source lang="bash">lxc-list</source>
|
2013-09-30 18:23:33 +02:00
|
|
|
|
|
|
|
* an VM attachen:
|
2013-09-30 20:57:21 +02:00
|
|
|
*: <source lang="bash">lxc-console -n<container-name></source>
|
2013-09-30 18:23:33 +02:00
|
|
|
|
|
|
|
* Von Konsole detachen:
|
2013-09-30 20:57:21 +02:00
|
|
|
*: im screen:
|
|
|
|
*:: {{Taste|Ctrl}}+{{Taste|a}}{{Taste|a}}{{Taste|q}}
|
|
|
|
*: ohne screen:
|
|
|
|
*:: {{Taste|Ctrl}}+{{Taste|a}}{{Taste|q}}
|
2015-02-18 02:28:29 +01:00
|
|
|
|
|
|
|
== debian 8 (jessie/systemd lxc) ==
|
|
|
|
|
|
|
|
z.b wheezy container upgrade auf jessie
|
|
|
|
|
|
|
|
lxc - config
|
|
|
|
<source lang="bash">
|
|
|
|
lxc.autodev = 1
|
|
|
|
lxc.kmsg = 0
|
|
|
|
</source>
|
|
|
|
|
|
|
|
im rootfs container:
|
|
|
|
<source lang="bash">
|
|
|
|
apt-get install dbus (sofern vergessen)
|
|
|
|
|
|
|
|
# udev fuu deaktivieren:
|
|
|
|
ln -s /dev/null /etc/systemd/system/systemd-udevd.service
|
|
|
|
ln -s /dev/null /etc/systemd/system/systemd-udevd-control.socket
|
|
|
|
ln -s /dev/null /etc/systemd/system/systemd-udevd-kernel.socket
|
|
|
|
ln -s /dev/null /etc/systemd/system/proc-sys-fs-binfmt_misc.automount
|
|
|
|
|
|
|
|
# tty fuu deaktivieren: /var/lib/lxc/{container}/rootfs/lib/systemd/system/getty@.service
|
|
|
|
ConditionPathExists=/dev/tty0
|
2015-02-18 11:45:18 +01:00
|
|
|
|
|
|
|
# permission fuu
|
|
|
|
ln -s -f /bin/true /usr/bin/chfn
|
2015-02-18 11:37:06 +01:00
|
|
|
</source>
|
2015-02-18 02:28:29 +01:00
|
|
|
|
2015-02-18 11:37:06 +01:00
|
|
|
https://wiki.archlinux.org/index.php/Lxc-systemd
|
2015-02-18 11:45:18 +01:00
|
|
|
|
2015-02-18 11:37:06 +01:00
|
|
|
https://github.com/lxc/lxc/commit/a9bf60bab547013a9873a3fb9efe61155e8694b8
|
2015-02-18 02:28:29 +01:00
|
|
|
|
2015-02-18 11:37:06 +01:00
|
|
|
https://wiki.debian.org/LXC#Debian_8_.22Jessie.22.2Ftesting
|
2015-02-24 02:34:28 +01:00
|
|
|
|
|
|
|
=== frickeln ===
|
|
|
|
|
|
|
|
https://gist.github.com/peo3/1142202
|