Having trouble reducing VM HDD size using command line. Help Please!

Alpinehost.ch

New Member
Jul 14, 2023
5
0
1
Trying to reduce VM HDD size is proving harder than what I anticipated. I can successfully increase the HDD using command line but reducing the size is a problem.
Ok, so please bare with me, I am new to this.

qm resize 101 scsi0 +10G Increases the drive by 10G so,
qm resize 101 scsi0 -10G This should reduce by 10G, correct?

So i have run the command, qm resize 101 scsi0 -10G, and I get this response,

Unknown option: 10g

400 unable to parse option

qm resize <vmid> <disk> <size> [OPTIONS]
 
The best and first place to consult when you are having an issue with options is the "man page".
"man qm" gives us the following for "qm disk resize" (for which "qm resize" is an alias):
Code:
 qm disk resize <vmid> <disk> <size> [OPTIONS]

       Extend volume size.

       <vmid>: <integer> (1 - N)
           The (unique) ID of the VM.

       <disk>: <efidisk0 | ide0 | ide1 | ide2 | ide3 | sata0 | sata1 | sata2 | sata3 | sata4 | sata5 | scsi0 | scsi1 | scsi10 | scsi11 | scsi12 | scsi13 | scsi14 | scsi15 | scsi16 | scsi17 | scsi18 |
       scsi19 | scsi2 | scsi20 | scsi21 | scsi22 | scsi23 | scsi24 | scsi25 | scsi26 | scsi27 | scsi28 | scsi29 | scsi3 | scsi30 | scsi4 | scsi5 | scsi6 | scsi7 | scsi8 | scsi9 | tpmstate0 | virtio0 |
       virtio1 | virtio10 | virtio11 | virtio12 | virtio13 | virtio14 | virtio15 | virtio2 | virtio3 | virtio4 | virtio5 | virtio6 | virtio7 | virtio8 | virtio9>
           The disk you want to resize.

       <size>: \+?\d+(\.\d+)?[KMGT]?
           The new size. With the + sign the value is added to the actual size of the volume and without it, the value is taken as an absolute one. Shrinking disk size is not supported.

       --digest <string>
           Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.

       --skiplock <boolean>
           Ignore locks - only root is allowed to use this option.

as you can see it specifically calls out "Extend" and mentions nothing of reduce.
Disk reduction operation is generally much more complex than extension. It involves reducing file system allocation, partitions, etc. A lot has to be done as prep-work in the VM. In short - it cant be easily expressed in single command of a hypervisor. Too many things can go wrong.

A google search should give you many references to manual disk reduction, your VM OS and layout play a big role in this procedure, and sometimes it is simply not possible.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: Alpinehost.ch
It even explicitely tells: "Shrinking disk size is not supported."
If it would allow that and you didn't shrink the partitions, filesystems, VGs, LV and whatever on the guest level first, you would end up with a corrupted disk.
 
Last edited:
  • Like
Reactions: bbgeek17
The best and first place to consult when you are having an issue with options is the "man page".
"man qm" gives us the following for "qm disk resize" (for which "qm resize" is an alias):
Code:
 qm disk resize <vmid> <disk> <size> [OPTIONS]

       Extend volume size.

       <vmid>: <integer> (1 - N)
           The (unique) ID of the VM.

       <disk>: <efidisk0 | ide0 | ide1 | ide2 | ide3 | sata0 | sata1 | sata2 | sata3 | sata4 | sata5 | scsi0 | scsi1 | scsi10 | scsi11 | scsi12 | scsi13 | scsi14 | scsi15 | scsi16 | scsi17 | scsi18 |
       scsi19 | scsi2 | scsi20 | scsi21 | scsi22 | scsi23 | scsi24 | scsi25 | scsi26 | scsi27 | scsi28 | scsi29 | scsi3 | scsi30 | scsi4 | scsi5 | scsi6 | scsi7 | scsi8 | scsi9 | tpmstate0 | virtio0 |
       virtio1 | virtio10 | virtio11 | virtio12 | virtio13 | virtio14 | virtio15 | virtio2 | virtio3 | virtio4 | virtio5 | virtio6 | virtio7 | virtio8 | virtio9>
           The disk you want to resize.

       <size>: \+?\d+(\.\d+)?[KMGT]?
           The new size. With the + sign the value is added to the actual size of the volume and without it, the value is taken as an absolute one. Shrinking disk size is not supported.

       --digest <string>
           Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.

       --skiplock <boolean>
           Ignore locks - only root is allowed to use this option.

as you can see it specifically calls out "Extend" and mentions nothing of reduce.
Disk reduction operation is generally much more complex than extension. It involves reducing file system allocation, partitions, etc. A lot has to be done as prep-work in the VM. In short - it cant be easily expressed in single command of a hypervisor. Too many things can go wrong.

A google search should give you many references to manual disk reduction, your VM OS and layout play a big role in this procedure, and sometimes it is simply not possible.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thanks. Do you think maybe if I shrink the partition first on the VM and then try, would work?
 
Do you think maybe if I shrink the partition first on the VM and then try, would work?
It will not work. The "qm" does not implement reduce. You have to analyze your Storage/VM/OS/Disk/Partitions/Filesystems and then find a way to do it behind the scene, if its even possible. In many cases its not.

Create new disk and copy data there, ditch the old disk. There are many tools available to assist, ie clonezilla.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: Alpinehost.ch

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!