[SOLVED] Shrink disk on Ceph

comfreak

Member
May 20, 2020
46
12
13
34
Hi,

how do I shrink a disk on a Ceph-Cluster (the workflow to reduce the partition beforehand is clear)?

I tried

Code:
root@server:~# qm resize 111 scsi1 40G
shrinking disks is not supported

but failed.

Yes, the "qm" manual says that shrinking is not supported but here it sounds as it is supported. Or is "qm" the PVE API mentioned over there? So what would be the manual way instead?

If it is qemu-img, I probably have to mount the Ceph pool manually to access the disk? How is the mount done?

Thanks in advance for help!

Edit: As I unterstand "qm" is not the PVE API mentioned in the wiki as it stands for the "Qemu/KVM Virtual Machine Manager". The PVE API is probably the WebUI (which does not support a shrink, yes) or the REST API.
 
Last edited:
Ok, got it.

I can access the Ceph RBD directly through qemu-img. Great!

- Shrink partition inside the VM (Windows, gparted, etc.)
- Shutdown VM
- Resize the image: qemu-img resize -f raw --shrink rbd:<pool>/<disk-img> <size> (example: qemu-img resize -f raw --shrink rbd:VMs/vm-111-disk-1 55G)
- Scan the disk: qm rescan --vmid <vmid> (example: qm rescan --vmid 111)
- Start VM and hope that nothing got lost :)
 
I spent like 10 minutes trying to figure out why this didn't work before realizing I had a typo and put "rdb" instead of "rbd."
I feel dumb. lol
Thank you for posting this. Super helpful.
 
I cannot boot my VM (ubuntu-test) after shrink it, here is what I did

I test a shrink from 50 GiB -> 30 GiB

$ qemu-img info rbd:ceph-ssd/vm-110-disk-0
image: json:{"driver": "raw", "file": {"pool": "ceph-ssd", "image": "vm-110-disk-0", "driver": "rbd", "namespace": ""}}
file format: raw
virtual size: 50 GiB (53687091200 bytes)
disk size: unavailable
cluster_size: 4194304

Boot gparted and resize the partion /dev/sda1 to 28GB to have some puffer

Bildschirmfoto 2023-11-15 um 22.05.29.png

qemu-img resize --shrink -f raw rbd:ceph-ssd/vm-110-disk-0 30G
qm rescan --vmid 110

Reboot the VM and it stucks

Bildschirmfoto 2023-11-15 um 21.52.03.png
 

Attachments

  • Bildschirmfoto 2023-11-15 um 22.03.32.png
    Bildschirmfoto 2023-11-15 um 22.03.32.png
    392.3 KB · Views: 18

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!