Shrink vm size

Bookmaster

Member
May 25, 2022
16
0
6
Hello,

I have Proxmox 7.2
Under it, I have Windows server 2019.
Somehow I accidentally made my first partition to 32Gb but in fact, it is only 549Mb (first attachment: DiskManagement2019). I want to shrink that hard drive to 549 MB and release 31,46Gb.
Here is my Proxmox hardware (attachment 2) and Hard disk specs (attachment 3).

How can I shrink the size of my disk, please?

Best regards

BM
 

Attachments

  • DiskManagement2019.jpg
    DiskManagement2019.jpg
    148.9 KB · Views: 70
  • ProxmoxHardware.jpg
    ProxmoxHardware.jpg
    61.2 KB · Views: 67
  • HardDisk.jpg
    HardDisk.jpg
    41.5 KB · Views: 64
Thanks for reply noel

I saw both links before I started my thread. I have a windows server 2019 as VM in Proxmox and I am not sure how to do either of those two options. That is reason why I post thread.

IF you can help me it would be great.

Best regards

BM
 
First of all: MAKE BACKUPS BEFORE DOING ANY OF THIS
You could also clone your windows vm for testing this stuff out.

cloning: make a new, smaller disk in the web interface. Attach a gparted [1] iso and boot into it. in Gparted you can copy the partition you want onto your new, smaller disk. Reboot, detach old disk in web interface, set the boot options to boot from the new disk and try. (I tried this before and i bluescreened, not quite sure why. But in theory I think it should work, unless I am overlooking something.)

shrinking: in your windows vm in in Disk management, rightclick on "Disk 0" -> properties -> volumes. if partition style is MBR, easy peasy, if the partition style is gpt, you will have to resize your partition table: boot into GParted (or any other live linux environment) and use gdisk [2][3]. This is because gpt writes table info to the end of the disk and just cutting it off during shrinking will ruin the table. After that you can shrink your disk from the host with lvmreduce and lvmrescan like in the linked post [4].

[1]: https://gparted.org/livecd.php
[2]: https://www.rodsbooks.com/gdisk/walkthrough.html
[3]: https://unix.stackexchange.com/questions/311265/resize-partition-table-using-gdisk
[4]: https://forum.proxmox.com/threads/decrease-a-vm-disk-size.122430/
 
Hello Noel,

Thanks again for your reply.
In my Windows VM in Disk Management, I checked volumes and it is MBR. So for Disk 0 I have:

- 549Mb System reserved and
- 31,46Gb Unallocated.

I want to delete that 31,46Gb that is unallocated.

I didn't like part when you get blue screen and that should work... I hoped that somebody actually did it without a blue screen. I will try to do it with gparted and let you know how it went.

regards

BM
 
First of all: MAKE BACKUPS BEFORE DOING ANY OF THIS
You could also clone your windows vm for testing this stuff out.

cloning: make a new, smaller disk in the web interface. Attach a gparted [1] iso and boot into it. in Gparted you can copy the partition you want onto your new, smaller disk...
You have to create partition. In options that Gparted offers there are no MBR :(.

regards

BM
 
Since the disk is MBR it should be easy to shrink since table information are only written at the beginning of the disk. First of all, make a backup.

Then all you should need to do is run these commands from your host:
Code:
lvm lvreduce -L -31g pve/vm-150-disk-0
to shrink the disk
and
Code:
qm rescan
to correct the size in the vm.
 

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!