I’m a big fan of Proxmox and have been using it for many years to manage containers (now LXC, formerly OpenVZ) as well as KVM machines.
On a recently provisioned build server, I had a situation where I wanted to share a directory between multiple containers. This is quite simple to do: you can either configure it via the web interface or edit the container’s configuration file under /etc/pve/lxc/:
What I did find a little less straight forward however, was partitioning.
On my Proxmox installation, the root partition, where the directory was situated was only 90GB. This is usually enough for templates and ISOs. Proxmox uses LVM2 by default, so I tried to simply lvextend the root partition, but this didn’t work. Since Proxmox 4.3, LVM thin provisioning is now used, which limits the number of extents available for expanding root. This has been done to allow more resources to be provisioned than available, which wasn’t possible under the old scheme.
One of the reasons why I wanted to ensure that files were visible on the host was so that our backup tool, Bacula, which performs file based backups could access the files. Recent versions of Proxmox no longer expose a container’s filesystem via /var/lib/vz which means that files created under containers were no longer being automatically backed up.
The solution is to create a new thin logical volume.
mkdir /path/on/host lvcreate -n newmount -V 200G pve/data mkfs.ext4 /dev/pve/newmount echo "/dev/pve/newmount /var/lib/vz ext4 defaults 0 0 " >> /etc/fstab mount -av
Now we are using extents for VMs and containers and leaving the root partiton as it was. Files can be shared between containers and the host and Bacula is able to access and backup the files.
To check real usage of the disk space, be sure to run
Written by Sam Nazarko, a 20s London chap who is an open source developer by night. Follow me on Twitter