Talk:Proxmox Linux Container: Difference between revisions

From NixOS Wiki
imported>Vater
 
imported>Vater
Line 30: Line 30:
: https://hydra.nixos.org/job/nixos/release-21.05/nixos.containerTarball.x86_64-linux/latest/download-by-type/file/system-tarball
: https://hydra.nixos.org/job/nixos/release-21.05/nixos.containerTarball.x86_64-linux/latest/download-by-type/file/system-tarball
|-
|-
| download the template
| download the NixOS template
|  
|  
* (if you want to switch to the ''Storage View'' and) go to one of your nodes where you can (find and) store ''CT Templates''.
* (if you want to switch to the ''Storage View'' and) go to one of your nodes where you can (find and) store ''CT Templates''.
Line 36: Line 36:
** add the link for the NiixOS template file ''https://hydra.nixos.org/job/nixos/release-21.05/nixos.containerTarball.x86_64-linux/latest/download-by-type/file/system-tarball'' (to the text field of <tt>URL:</tt>)
** add the link for the NiixOS template file ''https://hydra.nixos.org/job/nixos/release-21.05/nixos.containerTarball.x86_64-linux/latest/download-by-type/file/system-tarball'' (to the text field of <tt>URL:</tt>)
** add a nice file name for the current downloadable build of the template (to the text field of <tt>File name:</tt>)
** add a nice file name for the current downloadable build of the template (to the text field of <tt>File name:</tt>)
**: for example ''nixos-21.05_2021-10-10.tar.xz'' (proxmox style: name of the linux operating system (''nixos''), release version (''21.05''), and enriched with the date of the day of the (download and) build
**: for example ''nixos-21.05_2021-10-10.tar.xz'' (Proxmox Virtual Environment style: name of the linux operating system (''nixos''), release version (''21.05''), and enriched with the date of the day of the (download and) build
|  
|  
going to the folder where all the templates for Promox Virtual Environment are stored
going to the folder where all the templates for Promox Virtual Environment are stored
Line 46: Line 46:
(optional you can) going back
(optional you can) going back
: <code>cd -</code>
: <code>cd -</code>
|-
| create a (first) new NixOS container with Proxmox Virtual Environment
|
|
: <code>pct create </code>…
<pre></pre>
: <s><code>pct create 1000 --arch amd64 --description nixos-template cephfs:vztmpl/nixos-21.05_2021-10-10.tar.xz --ostype unmanaged --net0 name=eth0 --storage storage --unprivileged 1</code></s>
----
(optional you can) check the (pve) lxc config file (and it should look like something like the following)
<code>less /etc/pve/lxc/1000.conf</code>
<pre>
arch: amd64
#cmode: shell
#cores: 1
#features: nesting=1
hostname: CT1000
memory: 1024
net0: name=eth0,bridge=vmbr1,hwaddr=E6:8B:60:E0:19:4C,ip=dhcp,type=veth
ostype: unmanaged
rootfs: storage:vm-1000-disk-0,size=4G
swap: 512
unprivileged: 1
</pre>
|-
| customize the individual Proxmox Virtual Environment container configuration for NixOS
|
|
<pre>
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
</pre>
----
editing the specific (pve) lxc config file (to a option for ''lxc.init.cmd'')
: <code>nano /etc/pve/lxc/1000.conf</code>
<pre></pre>
<pre>
lxc.init.cmd: /init
</pre>
|-
| (configure the available (virtual) network device for the Proxmox Virtual Environment container)
|
|
----
|-
| (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)
<code>less /etc/pve/lxc/1000.conf</code>
<pre>
arch: amd64
cores: 2
features: nesting=1
hostname: CT1000
memory: 1024
net0: name=eth0,bridge=vmbr1,hwaddr=E6:8B:60:E0:19:4C,ip=dhcp,type=veth
ostype: unmanaged
rootfs: storage:vm-1000-disk-0,size=4G
swap: 512
unprivileged: 1
</pre>
|-
| customize the (pve) lxc startup setup routine
|
|
<pre>
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
</pre>
----
<code>nano /usr/share/perl5/PVE/LXC/Setup.pm</code>
<pre>
sub unified_cgroupv2_support {
    my ($self) = @_;
</pre>
<pre>
    return if !$self->{plugin}; # unmanaged
</pre>
<pre>
    $self->protected_call(sub { $self->{plugin}->unified_cgroupv2_support() });
}
</pre>
----
<pre>
WARN: old systemd (< v232) detected, container won't run in a pure cgroupv2 environment! Please see documentation -> container -> cgroup version.
TASK WARNINGS: 1
</pre>
|
https://forum.proxmox.com/threads/92381/#post-402350
: <code>grep cgroup /proc/filesystems</code>
<pre>
nodev cgroup
nodev cgroup2
</pre>
|-
| start the NixOS container with Proxmox Virtual Environment
|
|
: <code>pct start </code>…
<pre></pre>
|-
| …
|
|
| https://github.com/NixOS/nixpkgs/issues/9735#issuecomment-783535726
|-
| …
|
|
|-
| …
|
|
|-
| …
|
|
|-
| …
|
|
|-
|-
| …
| …

Revision as of 02:34, 10 October 2021

NixOS container (LXC) on Proxmox Virtual Environment 7

GUI CLI
find the (a current) NixOS template

for example for 21.05

the link for the latest (daily) tarball for a container (of 21.05) is

https://hydra.nixos.org/job/nixos/release-21.05/nixos.containerTarball.x86_64-linux/latest/download-by-type/file/system-tarball
download the NixOS template
  • (if you want to switch to the Storage View and) go to one of your nodes where you can (find and) store CT Templates.
  • choose the Download from URL button

going to the folder where all the templates for Promox Virtual Environment are stored

cd /mnt/pve/cephfs/template/cache

downloading the NixOS template file

wget -c https://hydra.nixos.org/job/nixos/release-21.05/nixos.containerTarball.x86_64-linux/latest/download-by-type/file/system-tarball

(optional you should) move the downloaded NixOS template file to a nicer (more individual) file name

mv system-tarball nixos-21.05_2021-10-10.tar.xz

(optional you can) going back

cd -
create a (first) new NixOS container with Proxmox Virtual Environment
pct create

pct create 1000 --arch amd64 --description nixos-template cephfs:vztmpl/nixos-21.05_2021-10-10.tar.xz --ostype unmanaged --net0 name=eth0 --storage storage --unprivileged 1

(optional you can) check the (pve) lxc config file (and it should look like something like the following) less /etc/pve/lxc/1000.conf

arch: amd64
#cmode: shell
#cores: 1
#features: nesting=1
hostname: CT1000
memory: 1024
net0: name=eth0,bridge=vmbr1,hwaddr=E6:8B:60:E0:19:4C,ip=dhcp,type=veth
ostype: unmanaged
rootfs: storage:vm-1000-disk-0,size=4G
swap: 512
unprivileged: 1
customize the individual Proxmox Virtual Environment container configuration for NixOS
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)

nano /etc/pve/lxc/1000.conf

lxc.init.cmd: /init
(configure the available (virtual) network device for the Proxmox Virtual Environment container)
(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) less /etc/pve/lxc/1000.conf

arch: amd64
cores: 2
features: nesting=1
hostname: CT1000
memory: 1024
net0: name=eth0,bridge=vmbr1,hwaddr=E6:8B:60:E0:19:4C,ip=dhcp,type=veth
ostype: unmanaged
rootfs: storage:vm-1000-disk-0,size=4G
swap: 512
unprivileged: 1
customize the (pve) lxc startup setup routine
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

nano /usr/share/perl5/PVE/LXC/Setup.pm

sub unified_cgroupv2_support {
    my ($self) = @_;

    return if !$self->{plugin}; # unmanaged
    $self->protected_call(sub { $self->{plugin}->unified_cgroupv2_support() });
}

WARN: old systemd (< v232) detected, container won't run in a pure cgroupv2 environment! Please see documentation -> container -> cgroup version.
TASK WARNINGS: 1

https://forum.proxmox.com/threads/92381/#post-402350

grep cgroup /proc/filesystems
nodev	cgroup
nodev	cgroup2
start the NixOS container with Proxmox Virtual Environment
pct start

https://github.com/NixOS/nixpkgs/issues/9735#issuecomment-783535726