Shrink ZFS disk

plokko

New Member
Jul 27, 2018
7
1
1
32
Hi.
I'm running on Proxmox VE 5.1 on a single node, the filesystem is on ZFS (ZRAID1) and all the VM disks are on local zfs pools.
When trying to expand the vm 100 disk from 80 to 160gb i wrote the dimension in Mb instead of Gb so now i have a 80Tb drive instead of a 160Gb ( on a 240gb drive...:eek: ).

I tried to edit the config file directly (/etc/pve/local/qemu-server/100.conf) and now it's correct on the VM options but on the actual VM or the storage section is still displayed 80tb.
Code:
virtio0: local-zfs:vm-100-disk-1,size=120G
How can i fix it?

Thanks.
 
Last edited:

plokko

New Member
Jul 27, 2018
7
1
1
32
Ok this command should have fixed it:
Code:
$zfs set volsize=120G rpool/data/vm-100-disk-1
 

plokko

New Member
Jul 27, 2018
7
1
1
32
Correction:
In proxmox now it shows 120Gb both in storage and VM options but the VM (Windows server) still see it at 81tb drive...

---UPDATE:---

Found an easy fix:
i edited the disk from the proxmox panel from "no cache" to "directsync" and now Windows is updated to the correct disk size;
i don't know if it's repeatable but it worked.
 
Last edited:

plokko

New Member
Jul 27, 2018
7
1
1
32
Basic guide (may need improvments and it's not failproof) to shrink zfs disks:

1. prepare your vm disk for shrinking and shut it down
2. in pve shell set new zfs pool size
Code:
$zfs set volsize=<new size>G rpool/data/vm-<vm id>-disk-<disk number>
3. edit vm config in /etc/pve/local/qemu-server/<vm id>.conf on line
Code:
virtio0: local-zfs:vm-<vm id>-disk-<disk number>,size=<new size>G
Obviusly the line may not be the same, just edit the disk size
4. in pve panel change the cache mode to something else and then revert back, this should update the config

Note: you may corrupt your partition table, to fix it in linux boot on a recovery live image like gparted and launch gdisk
Code:
$ gdisk /dev/vda
and then press v,x,e,w and y.
This should do the trick.
 
  • Like
Reactions: Amir

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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 your own in 60 seconds.

Buy now!