shrinking disks is not supported

nbanik

New Member
Apr 22, 2024
24
2
3
Hello Experts,
I've using terrform to provision.
Here is my config
provider.tf
Code:
terraform {

  required_providers {

    proxmox = {

      source = "bpg/proxmox"

    }

  }

}





provider "proxmox" {

  endpoint = "https://172.23.18.4:8006/"

  username = "root@pam"

  password = "admin123"

  insecure = true



  ssh {

    agent = true

  }

}

main.tf

Code:
resource "proxmox_virtual_environment_vm" "ol9_vm" {
  name      = "test-ol9"
  node_name = "pv1"

  initialization {
    user_account {
      username = "vagrant"
      password = "vagrant"
    }
  }

  disk {
    datastore_id = "local-lvm1"
    file_id      = proxmox_virtual_environment_download_file.ol9_cloud_image.id
    interface    = "virtio0"
    iothread     = true
    discard      = "on"
    size         = 20
  }
}

resource "proxmox_virtual_environment_download_file" "ol9_cloud_image" {
  content_type = "iso"
  datastore_id = "local-lvm1"
  node_name    = "pv1"
  url          = "https://yum.oracle.com/templates/OracleLinux/OL9/u3/x86_64/OL9U3_x86_64-kvm-b220.qcow2"
  file_name    = "ol9.img"
  upload_timeout = 4444
}
vagrant@JumpHost:~/terraform/proxmox-ol$ cat provider.tf
terraform {
  required_providers {
    proxmox = {
      source = "bpg/proxmox"
    }
  }
}


I get below error while creating VM:
error:

Code:
proxmox_virtual_environment_download_file.ol9_cloud_image: Still creating... [17m0s elapsed]
proxmox_virtual_environment_download_file.ol9_cloud_image: Creation complete after 17m4s [id=local-lvm1:iso/ol9.img]
proxmox_virtual_environment_vm.ol9_vm: Creating...
╷
│ Error: error waiting for VM disk resize: All attempts fail:
│ #1: task "UPID:pv1:003BEBD1:0968C8B9:663F9A21:resize:114:root@pam:" failed to complete with exit code: shrinking disks is not supported
│
│   with proxmox_virtual_environment_vm.ol9_vm,
│   on main.tf line 2, in resource "proxmox_virtual_environment_vm" "ol9_vm":
│    2: resource "proxmox_virtual_environment_vm" "ol9_vm" {
│

Please help.
 
Last edited:
Please help.
You are downloading a custom image. This image is clearly larger than the 20GB you are trying to restrict it to by your template:
size = 20
You can probably just remove the "size=" line and move on. Or, you can examine the image "qemu-img info [image]" and adjust the size as desired.

Good luck


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
You are downloading a custom image. This image is clearly larger than the 20GB you are trying to restrict it to by your template:

You can probably just remove the "size=" line and move on. Or, you can examine the image "qemu-img info [image]" and adjust the size as desired.

Good luck


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Yes, image virtual size is 37GiB.

Code:
root@pv1:/var/lib/vz/template/iso# qemu-img info OL9U3_x86_64-kvm-b220.img
image: OL9U3_x86_64-kvm-b220.img
file format: qcow2
virtual size: 37 GiB (39728447488 bytes)
disk size: 575 MiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false
Child node '/file':
    filename: OL9U3_x86_64-kvm-b220.img
    protocol type: file
    file length: 575 MiB (602800128 bytes)
    disk size: 575 MiB

But disk size is only 575MiB.

Thanks for your help.
 
But disk size is only 575MiB.
Well, you are not expanding the physical size, you are expanding the Virtual size...
You are instructing the system to change the Virtual Size of 37G to 20G. It's called "shrinking", and it is not allowed.
Most of the space is currently empty, so it was compressed down to 575 MB. But as far as virtualized OS is concerned - there is 37G available.


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

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!