[PATCH container] btrfs: mount subvol
Matthias Freund
matthias88freund at gmail.com
Wed Mar 30 10:57:46 CEST 2022
Signed-off-by: Matthias Freund <matthias88freund at gmail.com>
---
Dear all,
I am not very familiar with mail patches, I hope I have done it right.
Proxmox is a very cool project, it's great!
I know pbs is not fully featured at the moment and btrfs is a very very
new technology for pve, so it is totally normal that there are missing
features.
How to reproduce the bug:
1. Create a Container on a btrfs storage without quota.
# pct create 100 local-btrfs:vztmpl/debian-11-standard_11.0-1_amd64.tar.gz --rootfs local-btrfs:0 --password 12345 --ostype debian --net0 name=eth0,bridge=vmbr0,ip=dhcp --hostname container --cores 1
2. (I'm not sure if it is necessary to reproduce the bug) Create one or
more mountpoint volumes on a btrfs storage without quota.
# pvesm alloc data-btrfs 100 "" 0 --format subvol
and add the mountpoints to config /etc/pve/lxc/100.conf.
mp0: data-btrfs:100/subvol-100-disk-1.subvol,mp=/mnt,backup=1,size=0T
3. Backup the container to a pbs datastore (with GUI or CLI).
# vzdump 100 --remove 0 --mode snapshot --node pve --storage pbs-pve
Log output:
INFO: starting new backup job: vzdump 100 --remove 0 --mode snapshot --node pve --storage pbs-pve
INFO: Starting Backup of VM 100 (lxc)
INFO: Backup started at 2021-10-18 09:09:39
INFO: status = running
INFO: CT Name: lx-container
INFO: including mount point rootfs ('/') in backup
INFO: including mount point mp0 ('/mnt') in backup
INFO: backup mode: snapshot
INFO: ionice priority: 7
INFO: suspend vm to make snapshot
INFO: create storage snapshot 'vzdump'
umount: /mnt/vzsnap0/: not mounted.
command 'umount -l -d /mnt/vzsnap0/' failed: exit code 32
INFO: resume vm
INFO: guest is online again after 22 seconds
ERROR: Backup of VM 100 failed - cannot mount subvol snapshots for storage type 'btrfs'
INFO: Failed at 2021-10-18 09:10:01
INFO: Backup job finished with errors
TASK ERROR: job errors
AFIK btrfs directly mounts snapshots on some defined path, which is
/some/subvol at snapshot in pve (in the current implementation).
Therefore, the snapshot can be directly bind-mounted to the
/mnt/vzsnap0/ directory. To achieve this the easiest way is to simply
use the impementation in the else-branch, this can be done by extending
the if.
After applying the patch the container can be backed up by the CLI
command used above.
Best Regards
Matthias
src/PVE/LXC.pm | 3 +-
2 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index b08d986..8cd7a24 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1732,7 +1733,7 @@ sub __mountpoint_mount {
if ($format eq 'subvol') {
if ($mount_path) {
my (undef, $name) = PVE::Storage::parse_volname($storage_cfg, $volid);
- if (defined($snapname)) {
+ if (defined($snapname) && $scfg->{type} ne 'btrfs') {
$name .= "\@$snapname";
if ($scfg->{type} eq 'zfspool') {
PVE::Tools::run_command(['mount', '-o', 'ro', @extra_opts, '-t', 'zfs', "$scfg->{pool}/$name", $mount_path]);
--
3.33.1
More information about the pve-devel
mailing list