Skip to content

[Bug] NBD Backend: pct resize multiplies target size by 1024 (GB becomes TB) #57

@JoaGamo

Description

@JoaGamo

Pardon my English for the title, I don't know how to explain it better. If you wanted to resize a container from 8GB to 12GB ( by adding 4GB ), the plugin instead converts the original "8GB" to "8TB" and our intended "+4G" is converted to "+4T". In the end, your container ends up with 8T + 4T = 12TB

Setup:

pve-version:

root@gamohosthp:~# pveversion -v
proxmox-ve: 9.1.0 (running kernel: 6.17.2-1-pve)
pve-manager: 9.1.1 (running version: 9.1.1/42db4a6cf33dac83)

Running plugin version pve-moosefs v0.1.11 (beta).

Issue

I'm copy-pasting the creation steps over from #52 , as the issue is related but occurs with the NBD backend

Create a Proxmox LXC with everything default settings. You can do this either through the Web GUI of Proxmox, or use CLI.
For visibility I'll show the command I used with CLI and console logs.

# This creates a Debian 13 LXC, with the rootfs being in a MooseFS mountpoint with size=8GB. 
root@gamohosthp:/# pct create 500 /mnt/pve/gamoblock/template/cache/debian-13-standard_13.1-2_amd64.tar.zst --rootfs GamoBlock:8
Plugin "PVE::Storage::Custom::MooseFSPlugin" is implementing an older storage API, an upgrade is recommended
Formatting '/mnt/pve/gamofs/images/500/vm-500-disk-0.raw', fmt=raw size=8589934592 preallocation=off
Creating filesystem with 2097152 4k blocks and 524288 inodes
Filesystem UUID: 3b5fae63-a641-4eb9-9e7d-55e9962e67d7
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
extracting archive '/mnt/pve/gamofs/template/cache/debian-13-standard_13.1-2_amd64.tar.zst'
Total bytes read: 551505920 (526MiB, 155MiB/s)
Detected container architecture: amd64
Creating SSH host key 'ssh_host_ed25519_key' - this may take some time ...
done: SHA256:NqMWvxhuZoJ+TwAbM1kz16RehL7f5EtV2z+5LV4f2fg root@localhost
Creating SSH host key 'ssh_host_ecdsa_key' - this may take some time ...
done: SHA256:YQThMJ7ZbIWVHwirv0fOR6LE3O1LaS5Grwf5MdGl2Xc root@localhost
Creating SSH host key 'ssh_host_rsa_key' - this may take some time ...
done: SHA256:cduMXNxXIASyNxDiyo4KjSh0RR2ns1z2xBGO5tJ+yjo root@localhost

End of copy-pasted stuff

Now, to reproduce the bug, execute a pct resize pct resize 500 rootfs +4G. We are increasing a container's rootfs partition from 8GB to 12GB

root@gamohosthp:~# pct resize 500 rootfs +4G
Plugin "PVE::Storage::Custom::MooseFSPlugin" is implementing an older storage API, an upgrade is recommended
stop block device: (/dev/mfs/mfsmaster.gamo_9421__images_500_vm-500-disk-0->/dev/nbd0 : MFS://images/500/vm-500-disk-0 : 8.000GiB)
started block device: (/dev/mfs/mfsmaster.gamo_9421__images_500_vm-500-disk-0->/dev/nbd0 : MFS://images/500/vm-500-disk-0 : 12288.000GiB)
e2fsck 1.47.2 (1-Jan-2025)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/nbd0: 21929/524288 files (0.2% non-contiguous), 202028/2097152 blocks
resize2fs 1.47.2 (1-Jan-2025)
Resizing the filesystem on /dev/nbd0 to 3221225472 (4k) blocks.
The filesystem on /dev/nbd0 is now 3221225472 (4k) blocks long.

This line shows
started block device: (/dev/mfs/mfsmaster.gamo_9421__images_500_vm-500-disk-0->/dev/nbd0 : MFS://images/500/vm-500-disk-0 : 12288.000GiB)
the volume is now internally 12TB long lol. Although the LXC configuration still shows size=12G, the internal volume size is incorrect. If I later move this volume using pct move-volume, the container config updates to reflect the real size (size=12T), allowing the container to use that massive amount of space lol.
pct move-volume 500 rootfs GamoFS: ("GamoFS" is my MooseFS FUSE mountpoint)

The issue seems related to this line, but I did not test further.

my $size_bytes = $size * 1024; # Convert KiB to bytes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions