Windows Script to Automatically Resize Disk #63
ericwang401
started this conversation in
Resources
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a repost and wasn't made by me.
https://techglimpse.com/automatically-extend-windows-storage-disk-size-openstack/
In case the link above becomes dead in the future...
How to automatically extend windows virtual disk size [Openstack]
Thanks to this article – how to create a Windows Image for OpenStack Glance repository. After uploading the image, I created a separate flavor for Windows VMs with 2 vCPUs, 4GB RAM, and 40GB disk. However, when the Windows VM is booted, I noticed the hard disk space of 20GB, instead of 40GB! Also, the Disk Management showed 20GB as unallocated. Your tutorial on how to Increase the virtual disk size of a Windows 10 VM on QEMU-KVM solves the issue. But can this be automated? So whenever the flavor is selected, it should automatically extend Windows virtual disk size to fit the disk size of the flavor. – Sahana.
Automatically extend Windows virtual disk size
As explained in my earlier articles, we use Cloudbase Solution’s Cloudbase-Init to configure the system for use in a cloud environment. Cloudbase-Init has the ability to execute user-provided scripts, usually found in the default path C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\LocalScripts, through a specific plugin for doing it. Depending on the platform used, the files should be valid PowerShell, Python, Batch, or Bash scripts.
Extend a volume by using PowerShell
After the VM is prepared the last thing to be done is to create PowerShell scripts and place them in the Cloudbase-init default path for executing LocalScripts. These scripts run at every boot. So in case if you resize the VM, it should automatically consider extending the disk size.
Step 1
Open the notepad with the administrator privilege. Copy and paste the below script into it.
Save the file as
volumeExtend.ps1
into the path:C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\LocalScripts
Step 2
You can follow the guide Increase the virtual disk size of the Windows 10 VM on QEMU-KVM to delete the Windows Recovery Partition.
Step 3
Gracefully shut down the VM and copy it to your OpenStack cloud.
Step 4
Boot your Windows VM and check the disk size to see if it has taken the complete size of your flavor.
Beta Was this translation helpful? Give feedback.
All reactions