Talk:Proxmox Linux Container: Difference between revisions
imported>Vater mNo edit summary |
imported>Vater |
||
Line 82: | Line 82: | ||
*:* <s>(for the following we expect) (the text field of <tt>MAC address:</tt>) is emtpy (and so prefilled with ''auto'')</s> | *:* <s>(for the following we expect) (the text field of <tt>MAC address:</tt>) is emtpy (and so prefilled with ''auto'')</s> | ||
*:* (for the following we expect) the entry ''vmbr0'' is prefilled (at the drop down menu of <tt>Bridge:</tt>) | *:* (for the following we expect) the entry ''vmbr0'' is prefilled (at the drop down menu of <tt>Bridge:</tt>) | ||
*:*: we expect that you have a bridge ''vmbr0'' configured | |||
*:*:: otherwise? | |||
*:* <s>(for the following we expect) (the text field of <tt>VLAN Tag:</tt>) is emtpy (and so prefilled with ''no VLAN'')</s> | *:* <s>(for the following we expect) (the text field of <tt>VLAN Tag:</tt>) is emtpy (and so prefilled with ''no VLAN'')</s> | ||
*:* <s>(for the following we expect) (the text field of <tt>Rate limit (MB/s) Tag:</tt>) is emtpy (and so prefilled with ''unlimited'')</s> | *:* <s>(for the following we expect) (the text field of <tt>Rate limit (MB/s) Tag:</tt>) is emtpy (and so prefilled with ''unlimited'')</s> | ||
*:* <s>(for the following we expect) the checkbox <tt>Firewall:</tt> is preselected choosen</s> | *:* <s>(for the following we expect) the checkbox <tt>Firewall:</tt> is preselected choosen</s> | ||
*:* | *:* (for the following we expect) choose <tt>DHCP</tt> (at the ratio button menu of <tt>IPv4:</tt>) | ||
*:*: ?!? otherwise the container will have no network access for IPv4 (or you have fill out the text field of <tt>IPv4/CIDR:</tt> and the text field of <tt>Gateway (IPv4):</tt>) ?!? | |||
*:* (for the following we expect) the entry <tt>Static</tt> is prefilled (at the ratio button menu of <tt>IPv6:</tt>) and you have no network access for IPv6 avilibale | |||
*:*: ?!? if you have network for IPv6 and you want to have access to your network for IPv6 you have fill out the text field of <tt>IPv6/CIDR:</tt> and the text field of <tt>Gateway (IPv6):</tt>) ?!? | |||
*:* choose the ''Next'' button | |||
*: tab <tt>DNS</tt> | *: tab <tt>DNS</tt> | ||
*:* ?!? emty ?!? | |||
*:* … | *:* … | ||
*:* choose the ''Next'' button | |||
*: tab <tt>Confirm</tt> | *: tab <tt>Confirm</tt> | ||
*:* | *:: (optional) check the configuration (keys with values) | ||
*:* choose the ''Finish'' button | |||
<pre> | <pre> | ||
/dev/rbd0 | /dev/rbd0 | ||
Creating filesystem with 2097152 4k blocks and 524288 inodes | Creating filesystem with 2097152 4k blocks and 524288 inodes | ||
Filesystem UUID: | Filesystem UUID: 3f4cf224-8062-4cd3-918c-49f891af1aa1 | ||
Superblock backups stored on blocks: | Superblock backups stored on blocks: | ||
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 | ||
extracting archive '/mnt/pve/cephfs/template/cache/nixos-21.05_2021-10-10.tar.xz' | extracting archive '/mnt/pve/cephfs/template/cache/nixos-21.05_2021-10-10.tar.xz' | ||
Total bytes read: 836218880 (798MiB, | Total bytes read: 836218880 (798MiB, 21MiB/s) | ||
Architecture detection failed: open '/bin/sh' failed: No such file or directory | Architecture detection failed: open '/bin/sh' failed: No such file or directory | ||
Line 137: | Line 146: | ||
unprivileged: 1 | unprivileged: 1 | ||
</pre> | </pre> | ||
|- | |||
| (configure the available (virtual) network device for the Proxmox Virtual Environment container) | |||
| | |||
| | |||
---- | |||
|- | |- | ||
| customize the (pve) lxc startup setup routine (on every node where you want to start a NixOS container) | | customize the (pve) lxc startup setup routine (on every node where you want to start a NixOS container) | ||
Line 189: | Line 203: | ||
lxc.init.cmd: /init | lxc.init.cmd: /init | ||
</pre> | </pre> | ||
|- | |- | ||
| (activate ''nesting'' for NixOS in the Proxmox Virtual Environment container) | | (activate ''nesting'' for NixOS in the Proxmox Virtual Environment container) |
Revision as of 08:12, 11 October 2021
NixOS container (LXC) on Proxmox Virtual Environment 7
WUI | CLI | Reference | |
---|---|---|---|
find the (a current) NixOS template |
for example for 21.05
| ||
download the NixOS template |
|
going to the folder where all the templates for Promox Virtual Environment are stored
downloading the NixOS template file (optional you should) move the downloaded NixOS template file to a nicer (more individual) file name
(optional you can) going back
| |
create a (first) new NixOS container with Proxmox Virtual Environment |
/dev/rbd0 Creating filesystem with 2097152 4k blocks and 524288 inodes Filesystem UUID: 3f4cf224-8062-4cd3-918c-49f891af1aa1 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 extracting archive '/mnt/pve/cephfs/template/cache/nixos-21.05_2021-10-10.tar.xz' Total bytes read: 836218880 (798MiB, 21MiB/s) Architecture detection failed: open '/bin/sh' failed: No such file or directory Falling back to amd64. Use `pct set VMID --arch ARCH` to change. /etc/os-release file not found and autodetection failed, falling back to 'unmanaged' TASK OK (optional you can) check the (pve) lxc config file (and it should look like something like the following)
arch: amd64 cores: 1 features: nesting=1 hostname: CT1000 memory: 512 net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=F6:CA:DB:A2:BF:B6,type=veth ostype: unmanaged rootfs: storage:vm-1000-disk-0,size=8G swap: 512 unprivileged: 1 |
(optional you can) check the (pve) lxc config file (and it should look like something like the following)
arch: amd64 hostname: CT1000 memory: 1024 net0: name=eth0 ostype: unmanaged rootfs: storage:vm-1000-disk-0,size=4G swap: 512 unprivileged: 1 | |
(configure the available (virtual) network device for the Proxmox Virtual Environment container) |
| ||
customize the (pve) lxc startup setup routine (on every node where you want to start a NixOS container) |
run_buffer: 316 Script exited with status 1 lxc_init: 816 Failed to run lxc.hook.pre-start for container "1000" __lxc_start: 2007 Failed to initialize container "1000" TASK ERROR: startup for container '1000' failed
sub unified_cgroupv2_support { my ($self) = @_; return if !$self->{plugin}; # unmanaged $self->protected_call(sub { $self->{plugin}->unified_cgroupv2_support() }); } (after fixing all the other stuff) WARN: old systemd (< v232) detected, container won't run in a pure cgroupv2 environment! Please see documentation -> container -> cgroup version. TASK WARNINGS: 1 |
||
customize the individual Proxmox Virtual Environment container configuration for NixOS |
sync_wait: 36 An error occurred in another process (expected sequence number 7) TASK ERROR: startup for container '1000' failed |
sync_wait: 36 An error occurred in another process (expected sequence number 7) __lxc_start: 2073 Failed to spawn container "1000" TASK ERROR: startup for container '1000' failed editing the specific (pve) lxc config file (to a option for lxc.init.cmd)
lxc.init.cmd: /init | |
(activate nesting for NixOS in the Proxmox Virtual Environment container) |
(optional you can) check the (pve) lxc config file (and it should look like something like the following with nesting=1 on the line features:)
arch: amd64 cores: 2 features: nesting=1 hostname: CT1000 memory: 1024 net0: name=eth0,bridge=vmbr0,hwaddr=A1:B2:C3:D4:E5:F6,ip=dhcp,type=veth ostype: unmanaged rootfs: storage:vm-1000-disk-0,size=4G swap: 512 unprivileged: 1 | ||
start the NixOS container with Proxmox Virtual Environment |
| ||
login into the NixOS container |
<<< Welcome to NixOS 21.05.3740.ce7a1190a0f (x86_64) - pts/0 >>> Log in as "root" with an empty password. nixos login: nixos login: root [root@nixos:~]# |
sh-4.4# sh-4.4# . /etc/profile [root@nixos:/]# | |
(optional) test rebuild of NixOS |
(optional) check the default configuration file for NixOS
{ config, pkgs, ... }: { imports = [ <nixpkgs/nixos/modules/virtualisation/lxc-container.nix> ]; }
building Nix... building the system configuration... activating the configuration... setting up /etc... setting up tmpfiles warning: the following units failed: sys-kernel-debug.mount ● sys-kernel-debug.mount - Kernel Debug File System Loaded: loaded (/nix/store/n5j5fjn60nhck658j9ab84k8n9z24n1r-systemd-247.6/example/systemd/system/sys-kernel-debug.mount; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2021-10-11 06:48:30 UTC; 265ms ago Where: /sys/kernel/debug What: debugfs Docs: https://www.kernel.org/doc/Documentation/filesystems/debugfs.txt https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems IP: 0B in, 0B out CPU: 2ms Oct 11 06:48:30 nixos systemd[1]: Mounting Kernel Debug File System... Oct 11 06:48:30 nixos mount[17997]: mount: /sys/kernel/debug: permission denied. Oct 11 06:48:30 nixos systemd[1]: sys-kernel-debug.mount: Mount process exited, code=exited, status=32/n/a Oct 11 06:48:30 nixos systemd[1]: sys-kernel-debug.mount: Failed with result 'exit-code'. Oct 11 06:48:30 nixos systemd[1]: Failed to mount Kernel Debug File System. warning: error(s) occurred while switching to the new configuration | ||
fixing the configuration file for NixOS |
(optional) check the default configuration file for NixOS
{ config, pkgs, ... }: { imports = [ <nixpkgs/nixos/modules/virtualisation/lxc-container.nix> ]; }
{ imports = [ <nixpkgs/nixos/modules/virtualisation/lxc-container.nix> ]; systemd.suppressedSystemUnits = [ "sys-kernel-debug.mount" ]; } |
https://github.com/NixOS/nixpkgs/issues/9735#issuecomment-783535726 | |
update the channel for NixOS (needed?) |
| ||
… | |||
… | |||
… |
Is there a need for non unprivileged NixOS containers?
- Is there a scenario where you would like to have a privileged (
unprivileged = 0
) container? - I do not know.
Is there a cgroup2 only NixOS containers?
- Is there a configuration with cgroups versions 2 only - where cgroups version 1 is not needed - (so that is possible to rollback the manipulation of the pve lxc startup script (/usr/share/perl5/PVE/LXC/Setup.pm))? Or can we create such a (pre)build image (tar)?
- I do not know.
grep cgroup /proc/filesystems
nodev cgroup nodev cgroup2
- Notes
https://linuxcontainers.org/lxc/manpages//man5/lxc.container.conf.5.html
(pve) lxc configuration option lxc.cgroup2.devices.allow: a
(pve) lxc configuration option lxc.cgroup.devices.deny = a
https://wiki.debian.org/LXC/CGroupV2
https://search.nixos.org/options?channel=unstable&from=0&query=cgroup
documentation
proxmox
- https://pve.proxmox.com/pve-docs/
- https://pve.proxmox.com/wiki/Linux_Container
- https://pve.proxmox.com/wiki/Unprivileged_LXC_containers
lxc
- …
debian
- …
linux
- …