[SOLVED] BTRFS Filesystem in LXC/LXD Container

batonac

Renowned Member
Aug 2, 2015
15
5
68
York, PA, USA
avu.nu
Hi, on a fresh install of Proxmox with BTRFS, I noticed that the containers install by default with a loop device formatted as ext4, instead of using a BTRFS subvolume, even when the disk is configured using the BTRFS storage backend.

I'd like to use BTRFS directly, instead of using a loop device. Is this possible? Am I missing something?

Thanks
 
Full disclosure: I'm trying to build for the future here... Linux 6.0 is bringing "~3x Boost For Direct Read Performance" and Linux 6.1 Async Buffered Writes "2x Throughput Improvement" along with other 6.1 improvements bringing an "orders of magnitude speed boost" to BTRFS.

I feel it's high time to make BTRFS a first-class citizen in Proxmox as a direct contender to ZFS, with feature parity. It's disappointing if we're confined to using ext4 on a loop device on BTRFS when utilizing subvolumes would expose even more features and performance to the underlying containers. If I'm missing a tweak to make this possible, I'd love to know about it.
 
  • Like
Reactions: panchuz
Okay, thanks to this German thread, I was able to figure out the workaround, for now. What's needed at the moment is creating the container from the command line with no quota: i.e. --rootfs local-btrfs:0. There's also an issue that's resolved with chmod +rx on the subvol, as detailed in that thread.

An entire container creation command is something like the following:
Code:
pct create 100 local-btrfs:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst --rootfs local-btrfs:0 --password --ostype ubuntu --net0 name=eth0,bridge=vmbr0,ip=dhcp --hostname test
chmod +rx /var/lib/pve/local-btrfs/images/100/subvol-100-disk-0.subvol

Unfortunately, there doesn't seem to be any solution for this in the GUI, and there's a bug that prevents live backup from working.

Excited to see more BTRFS advancement in the future!
 
Last edited:
  • Like
Reactions: panchuz
thanks for you informations, even as nobody else was responding.
i am pretty new to proxmox but not to btrfs.
I am currently runnunf PVE 7.3 with btrfs and i got the Containers working with the CLI
What i am currently wondering is, if it would be possible to create for example some kind of template container with installed docker and then use the COW feature of btrfs to run multiple PCT which are starting with a copy or snapshot of the template subvolume and changing/adding files when needed, as a lot of the data should be similar..
So for example:
101 PCT with debian 11 and docker installed as template
102 PCT with debian 11 and docker running docker container x
103 PCT with debian 11 and docker running docker container y
...

so i could make a cp --reflink [or a rw snapshot to the new location) of the subvolume for the new container and would need to tell the container to use that subvolume for my container.

is there any way do actually do that like this?
 
  • Like
Reactions: batonac
That would be amazing. Especially if there was some way to apply Debian updates on the root image in a way that replicated to all containers without duplication. The closest that I've figured to this so far is using custom templates and de-duplication, but that's clearly not the same thing as you're referring to here.
 
Is it possible to create a VM in a similar way as the LXC Container, so that the VM is using a subvolume without a double file system?
 
I highly doubt it. A VM relies on a disk abstraction which is many layers away from a filesystem pass-through. LXC containers, by comparison, are "chroot on steroids", with the same underlying kernel and process tree, etc. Trying to concurrently share a filesystem between two kernels sounds like a nightmare.

BTRFS doesn't even have an equivalent to ZVOLs, where the filesystem can directly create and manage virtual block devices. This doesn't really bother me since I'm a strict container user, but it does put ZFS ahead of BTRFS (as I understand it anyway) when it comes to VMs.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!