terraform-provider-vsphere
terraform-provider-vsphere copied to clipboard
Add support to resize `r/vsphere_virtual_disk`
Right now the vsphere_virtual_disk resource does not permit any changes, but we need to increase disk size on occasion. It is unreasonable to expect us to find a manual workaround to copy data from an old disk to a new larger disk. I would understand requiring a new disk when decreasing the size since that is generally not possible on most systems. During our tests we found the 'eagerZeroedThick' type does not allow resizing by vSphere but 'lazy' should permit increases in size.
NOTE: All fields in the vsphere_virtual_disk resource are currently immutable and force a new resource if changed.
Terraform Version
0.12.x
vSphere Provider Version
1.12.0
Affected Resource(s)
Please list the resources as a list, for example:
-
vsphere_virtual_disk
Expected Behavior
We expect to be able to increase the size of a type='lazy' vsphere_virtual_disk.
Actual Behavior
Disk wants to be recreated and we will lose all data.
@jsmilani this appears to be a duplicate of #150
#150 mentions resizing 10 comments deep, but it is phrased as a question. I don't think it qualifies as a duplicate since the original message itself doesn't address resizing nor does its proposed solution. I believe resizing doesn't necessarily require stopping the VM, but I have not figured out how to do that in the vcenter UI yet.
I just wanted to clarify that it doesn't need to be 'lazy' to resize, both 'lazy' and 'eagerZeroedThick' are confirmed resizable but I have not tested 'thin'. Resizing works while it is mounted to a running vsphere_virtual_machine, but the volume still needs to be manually expanded (this is normal and expected). It doesn't seem to work at all when it is mounted to a vsphere_virtual_machine with the disk_sharing='sharingMultiWriter' option.
This issue has been open 180 days with no activity. If this issue is reproducible with the latest version of the provider and with Terraform 0.12, please comment. Otherwise this issue will be closed in 30 days.
Adding comment to keep this alive. It is very much an issue still.
Issue is happening in 0.12.23
Hello Colleagues, we are still facing this issue as mentioned in below comment can this be done to help us to resize the disk provisioned by vsphere_virtual_disk resource. https://github.com/hashicorp/terraform-provider-vsphere/issues/150#issuecomment-528105175
We need to use the disk for logsearch and cassandra for which resizing will be regularly required..
@bill-rich: Could you please help in taking forward this enhancement request
I notice there's no resourceVSphereVirtualDiskUpdate
function in the vsphere/resource_vsphere_virtual_disk.go
file. To accomplish this, would it just require someone to implement the ability to diff the configuration in the file via a couple of conditionals?
Also interested in having the ability to resize vsphere_virtual_disks. We have virtual machines with "external" created disks as data disks and sometimes we need to resize them and have to do some dirty hacks with manipulating the terraform state.
@dcardellino, please +1 the first comment in this issue so your request reaches hashicorp's analytics (or whatever they're doing).
@dcardellino very much a issue we need addressing as well. Any timeline for this ? Thanks
+1 here
Any Update here?
Any update ?
Any Update
Struggling to find a way to resize disk partition with terraform for VM created from packer template.
@rihenperry, you can script the govc client using the vm.disk.change parameter until you or someone else submits a PR to get the implementation of this feature jumpstarted.
any updates on resizing disks, we really want need this feature.
Has anyone got any suggestions, we clone from a template VM with a 30GB didk to a 50GB disk, the VM shows as having a 50 GB disk but cant see the free space anywhere in the rhel VM to extend logical volumes ?
+1
+1
Ugh. As a reminder, please do not put "+1" as an additional comment. nobody will _ever_ see that shit unless they're already part of the issue in question... you need to +1 the original post.
Please be mindful of language and the code of conduct.
Isnt this always a problem to be solved by a provisioner with access to the os running/using the disks ?
In linux you would rescan the scsi bus and resize the disks via something like
echo 1 > /sys/class/scsi_disk/2\:0\:0\:0/device/rescan # adjust device number
growpart /dev/sda 2
# then for lvm
pvresize /dev/sda2
lvextend -l+100%FREE /dev/srv-git-vg/root
resize2fs /dev/mapper/srv--git--vg-root
# or for normal partitions
resize2fs /dev/sda2
I think you can even do this via cloud-init on boot ?
In Windows this can be done by powershell as well if i remember correctly...
TLDR I think there are two issues mixed up here...
- Resizing exitings vm disks
- Resising filesystems in a vm
- Resizing different types of vm disks
The first is working with terraform at least with thin prov disks for me. I second is outside the scope of the vsphere-provider as it require different commands/tools depending on the used disk layouts and filesystems
If this issue is only about the third variant, the subject of the issue should be adjusted to reflect that
The OS maps the device to a physical volume and then to a logical volume so it is true that it must get involved to make the actual volume increase in size, but the prerequisite is the device has been resized first and that is done by VSphere by modifying the virtual disk. We are not asking to solve the OS side of the problem, but we want to be able to increase the virtual disk size via terraform. Right now the workaround is to manually increase the disk size in the VCenter UI then update the terraform resource to match the manual change. We want to just be able to update the terraform resource to increase disk (not decrease). Decreasing size is outside of scope since it would destroy the volume if the OS had already claimed the new space.
@jsmilani Yeah, i misread something here... my bad, sorry...
can i downvote my own comment ? :)
Votes are only counted on the original description issue
Somewhat related, when doing a terraform destroy after updating a template that has a different sized vmdk, terraform fails with error. Is it possible to have the delete action ignore this specific error?
Error: disk.0: virtual disk "disk0": virtual disks cannot be shrunk (old: 150 new: 78) with vsphere_virtual_machine.vm[0], on main.tf line 78, in resource "vsphere_virtual_machine" "vm":
It’s been 3 years now. 28 votes so far. How many does it need to get this going? I know this is voluntarily work and I wish I could PR this (don’t get it to work) … But we still have to use a workarounds while it works perfectly with defined disks in r/vsphere_virtual_machine already. Which is also not about the OS side!