Shrink ZFS-Pool VM disk-1

Tdreissi

Well-Known Member
May 21, 2019
40
3
48
47
Hi,

my goal is to shrink a second disk "disk-1" from a Linux VM - without losing data.
When creating at that time a "0" was too much - I would like to have the memory back.
The disc is in a ZFS pool.

Test with Windows VM:
Windows boot disk reduced from 300G to 150G.
So far everything has worked - only in Windows it still shows the "old" size.
Proxmox CLI and GUI show new size.

VM shutdown
zfs set volsize = 150G SSD/vm-200-disk-0
Then the "conf" edited
vim /etc/pve/local/qemu-server/200.conf
virtio0: SSD: vm-200-disk-0, cache = writeback, size = 150G

Test with Linux VM:
Linux boot disk reduced from 100G to 80G
Linux does not boot anymore ... but zfs snapshot rollback was successful.

zfs set volsize = 80G SSD/vm-300-disk-0
Then the "conf" edited
vim /etc/pve/local/qemu-server/300.conf
virtio0: SSD: vm-300-disk-0, size = 80G


Ideas how I can do it on the Prod system to get storage back?
 
The size in the config is just metadata and has no impact on the disk image underneath.

If you want to reduce the size of a disk, you first need to reduce the file system and partitions inside the VM.

Once that is done, you can then reduce the size of the disk image itself. How depends heavily on the actual storage type.
For ZFS it should be the 'volsize' property. You can change it with
Code:
zfs set volsize=151G SSD/vm-200-disk-0

Assuming the pool is calles SSD and the disk image datasets are directly underneath it. Check it with zfs list first.
Then check with zfs get all SSD/vm-200-disk-0 if the property has changed. A qm rescan will not only scan the storages for unreferenced disk images, but will also update the size in the VMs config to the current value.


Do make a backup before you attempt this! If anything goes wrong, or if you get the sizes wrong, you will most likely end up with a broken VM.
 
  • Like
Reactions: noko
Hi,

thx for help....
I solved it differently. I was too insecure.
- shutdown vm
- add new disk
- start vm
- add new disk
- rsync all files
- umount both disk
- mount new disk on old mountpoint
reboot - finish
 
  • Like
Reactions: aaron

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!