Decrement of the extra drive of a VM

ieronymous

Active Member
Apr 1, 2019
251
18
38
44
After having seen some similar yet not identical articles and having read this https://pve.proxmox.com/wiki/Resize_disks, still don't think any of what I 've read is applicable to my case.

Introduction to how the system is build
4x1.2Tb drives in raid 10 (zfs) for VMs (no problems there)
4x4tb drives in raid 10 (zfs) for extra disks used as backup data of the VM's ... and here lies the question

So after Vm creation I 've attached an extra storage to it as scsi1 drive with the known procedure
-> Hardware ->Add Hard Disk SCSI / Cache: Write back / Storage: HHproxData / Disk size(GiB) 1500

After testing the data backup of that VM noticed a lot of wasted space (I know ... that's why you begin with less GBs and increase afterwards which is easier)
So I need to resize that space to less GBs and I need help doing that,

Above link clearly states you cant do it by gui (noticed that also since the only actions on the drive is to edit it->pointless or resize it which lets you only increment->not my case here) and needs manual cli intervention. Since the drive I need to shrink doesn't contain the OS, yet it
has data, but not even 1/20 of the storage (and probably data have been written at the start of of the drive) which is the proper way to do it if anyway available of course

PS The Vm is WinServ and the file system as you probably guessed is NTFS inside Vm and outside if I correct is raw disk based on zfs ??.
Seen others drying different methods but they had lvm or qcow2, my situation I think is if not completely at least different.

If all this is accomplished do I need any command in order for zfs to claim again the free space? Also way to check that free storage gain?
 
I advise GParted Live for resizing (physical and) virtual disks. The safest way might be to add another (smaller) virtual disk to the VM, boot from GParted ISO, and copy/resize the Windows partitions? Resizing a partition should not break anything as long a you do not stop the VM during the process (or have a power issue). Otherwise, you need to resize partitions and move them to the beginning of the virtual drive and then resize the zvol from the command line using something like zfs set volsize=...G ...pool.../vm-...-disk-.... This last step can break everything if you did not move everything back to the start of the drive enough, so make a backup beforehand. I don't have any real experience with modern Windows disk layouts, so I don't know what kind of partitions it creates but you probably only want to resize the largest one (and move the others).
 
copy/resize the Windows partitions?
Thank you for the answer. You noticed the part that the disk I want to shrink isnt the one where the OS resides, I need the extra disk to be shrined. If I resize it, there will be at the end just unpartitioned or unallocated space which afterwards needs to be removed/deleted in order for proxmox to see it as free space of its own again

I probably need way more informative way doing that since it is on a production machine and I cant do experiments on it.
 
Thank you for the answer. You noticed the part that the disk I want to shrink isnt the one where the OS resides, I need the extra disk to be shrined. If I resize it, there will be at the end just unpartitioned or unallocated space which afterwards needs to be removed/deleted in order for proxmox to see it as free space of its own again
Ah right, yes if the OS is not on it, it is much easier. Indeed just use Windows Disk Management to shrink the partition(s) on that drive (and leave a little more unallocated space then you want to remove), then resize the zvol on the command line, then regrow the partition within WIndows to match the actual virtual disk space.
The size of the virtual disk shown in the Proxmox web GUI might not change accordingly automatically, but there is also a command using qm that will fix this.
 
Ah right, yes if the OS is not on it, it is much easier. Indeed just use Windows Disk Management to shrink the partition(s) on that drive (and leave a little more unallocated space then you want to remove), then resize the zvol on the command line, then regrow the partition within WIndows to match the actual virtual disk space.
The size of the virtual disk shown in the Proxmox web GUI might not change accordingly automatically, but there is also a command using qm that will fix this.
I use Paragonfor years (ok matter of personal preference) but dont get the part to leave a little extra of unallocated space than the space i need to remove, Unallocated space at the end will be a continuous space not jus t2 extra partitions of unallocation space at the end from who i can remove the one and let the other in order to regrow the partition afterwards, Sorry but in my head doesn make sense and cant understand what you mean at the same time
 
I use Paragonfor years (ok matter of personal preference) but dont get the part to leave a little extra of unallocated space than the space i need to remove, Unallocated space at the end will be a continuous space not jus t2 extra partitions of unallocation space at the end from who i can remove the one and let the other in order to regrow the partition afterwards, Sorry but in my head doesn make sense and cant understand what you mean at the same time
Sorry for being overly cautious and becoming unclear. You want to shrink the underlying virtual drive: first you must shrink the contents/partition of that drive, then shrink the virtual drive.
Because not every operating system, disk tool, etc. always use the exact same units (GB versus GiB for example), this can cause data to get cut off and things break. Please make sure you shrink the contents of the drive enough, so that shrinking the virtual drive won't cause this problem.
(Usually I shink the contents about 1GiB more than than I want to shink the virtual drive, just be to be sure. Afterwards I resize the contents to match the new size of the virtual drive.)
 
(Usually I shink the contents about 1GiB more than than I want to shink the virtual drive, just be to be sure.
oh..that you meant.... after that shrinkage you have the option to delete that unallocated space created from the shrink, Do you delete it from disk management too?
 
Last edited:

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!