Skip to content

Instantly share code, notes, and snippets.

@jimklimov
Last active November 29, 2025 11:24
Show Gist options
  • Select an option

  • Save jimklimov/c4b0c4db752dd75fa4c0f8309dcba233 to your computer and use it in GitHub Desktop.

Select an option

Save jimklimov/c4b0c4db752dd75fa4c0f8309dcba233 to your computer and use it in GitHub Desktop.
Proxmox LXC in chroot filesystem

Specifying a zero size for filesystem lets LXC backend use the "subvol" directories rather than disk images. The latter were problematic for "pxvirt" 9.0.10-2 on Raspberry/trixie with ZFS (there raw ext4 images are okay for direct fsck/mount, until PVE mounts them and the system locks up with timed-out processes).

GUI may forbid specifying 0 as disk size, CLI to the rescue then.

Thanks to https://forum.proxmox.com/threads/proxmox-4-lxc-chroot-instead-of-raw-images.22881/ for CLI examples:

pct create 110 /var/lib/vz/template/cache/ubuntu-14.04-standard_14.04-1_amd64.tar.gz -hostname servername -password 'p@ssw0rd' -rootfs local:0

Comparing two setups:

  • With GUI-made container (mpX added manually to /etc/pve/lxc/100.conf to bind-mount host dirs):
# /etc/pve/lxc/100.conf
arch: arm64
cmode: console
cores: 4
features: nesting=1
hostname: nutci-rpiv-debian-12-arm64
memory: 512
mp0: /home/abuild,mp=/home/abuild
mp1: /home/abuild/.ccache,mp=/home/abuild/.ccache
mp2: /home/abuild/.gitcache-dynamatrix,mp=/home/abuild/.gitcache-dynamatrix
mp3: /home/abuild/jenkins-nutci-rpiv-debian-12-arm64,mp=/home/abuild/jenkins-nutci-rpiv-debian-12-arm64
net0: name=eth0,bridge=vmbr0,hwaddr=BC:24:11:88:45:A6,type=veth
onboot: 0
ostype: debian
rootfs: local:100/vm-100-disk-0.raw,mountoptions=lazytime,size=16G
swap: 512
unprivileged: 0
  • Container made with pct CLI and just the rootfs customized per above example so far:
# /etc/pve/lxc/112.conf
arch: arm64
hostname: nutci-rpiv-debian-12-arm64
memory: 512
ostype: debian
rootfs: local:112/subvol-112-disk-0.subvol,size=0T
swap: 512
unprivileged: 1

Apparently this container is by default unprivileged, note the FS object owners:

root@rpiv:~# ls -la /var/lib/vz/images/112/subvol-112-disk-0.subvol/
total 76
drwxr-xr-x 17 100000 100000 20 Nov 29 12:03 .
drwxr-----  3 root   root    3 Nov 29 12:02 ..
lrwxrwxrwx  1 100000 100000  7 Nov 24  2023 bin -> usr/bin
drwxr-xr-x  2 100000 100000  2 Sep 29  2023 boot
drwxr-xr-x  2 100000 100000  2 Nov 24  2023 dev
drwxr-xr-x 45 100000 100000 98 Nov 29 12:03 etc
drwxr-xr-x  2 100000 100000  2 Sep 29  2023 home
lrwxrwxrwx  1 100000 100000  7 Nov 24  2023 lib -> usr/lib
drwxr-xr-x  2 100000 100000  2 Nov 24  2023 media
drwxr-xr-x  2 100000 100000  2 Nov 24  2023 mnt
drwxr-xr-x  2 100000 100000  2 Nov 24  2023 opt
drwxr-xr-x  2 100000 100000  2 Sep 29  2023 proc
drwx------  3 100000 100000  5 Nov 24  2023 root
drwxr-xr-x  2 100000 100000  2 Nov 24  2023 run
lrwxrwxrwx  1 100000 100000  8 Nov 24  2023 sbin -> usr/sbin
drwxr-xr-x  2 100000 100000  2 Nov 24  2023 srv
drwxr-xr-x  2 100000 100000  2 Sep 29  2023 sys
drwxrwxrwt  8 100000 100000  8 Nov 29 12:03 tmp
drwxr-xr-x 11 100000 100000 11 Nov 24  2023 usr
drwxr-xr-x 11 100000 100000 13 Nov 24  2023 var

This is not per se integrated with ZFS on (Raspberry/pxvirt) host:

root@rpiv:~# df -k /var/lib/vz/images/112/subvol-112-disk-0.subvol/
Filesystem          1K-blocks   Used Available Use% Mounted on
rpool/PVE/vz/images 459933184 433152 459500032   1% /var/lib/vz/images

...but the sub-tree of datasets can be made. This is also not an issue with less complicated Raspberry hosts without NVMe and ZFS.

For comparison, on amd64 host I see the subvols (and dirs instead of raw images) used out of the box, apparently a ZFS-aware storage link was configured there:

root@pve:~# cat /etc/pve/lxc/100.conf
#mp4%3A /dev/hidraw3,mp=/dev/hidraw3
arch: amd64
cores: 12
features: nesting=1
hostname: nutci-debian-11-amd64
memory: 4096
mp0: /export/home/abuild,mp=/home/abuild
mp1: /export/home/abuild/.ccache,mp=/home/abuild/.ccache
mp2: /export/home/abuild/.gitcache-dynamatrix,mp=/home/abuild/.gitcache-dynamatrix
mp3: /export/home/abuild/jenkins-nutci-debian-11-amd64,mp=/home/abuild/jenkins-nutci-debian-11-amd64
net0: name=eth0,bridge=vmbr0,hwaddr=4E:34:ED:F0:D9:B3,type=veth
onboot: 1
ostype: debian
rootfs: local-zfs:subvol-100-disk-0,mountoptions=noatime,replicate=0,size=16G
swap: 512
unprivileged: 0

UPDATE: Go to "Folder view" (left column), select Datacenter itself, and Storage section there - "Add": type ZFS, path e.g. rpool/PVE/vz as the store for Containers and Disk Images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment