Script to delete and re-add disks to a VMware guest using the govc command line tool.
In my lab, I have a handful of VMware guests named bm[01:06]
.
I do not want to delete them because I have made a note of their MAC addresses for deploying OpenShift using the Agent Based Installer.
To redeploy an OS or ODF on a disk I need to wipe the disk completely, so why not just replace it.
$ disk-recycle bm03
About to nuke VM bm03. Are you sure?
Powering off VirtualMachine:vm-885... OK
found and removing the following virtual disks in VM bm03
[
{
"name": "disk-1000-0",
"type": "VirtualDisk",
"summary": "125,829,120 KB"
},
{
"name": "disk-1000-1",
"type": "VirtualDisk",
"summary": "104,857,600 KB"
}
]
removing old disk disk-1000-0 from vm bm03
adding new 120G disk disk-1000-0 to vm bm03
[25-11-24 11:21:56] Creating disk
removing old disk disk-1000-1 from vm bm03
adding new 120G disk disk-1000-1 to vm bm03
[25-11-24 11:21:57] Creating disk