This should go without saying, but make sure you have a good backup of everything before you do any of this.. If in doubt, just backup the whole VirtualBox folder. You have been warned.
Get some info first
First get the snapshot in use by the VM:
VBoxManage showvminfo VM_NAME | grep '{[-a-z0-9].*}\.vdi'
Replace/Resize current disk/snapshot
Clone disk to new VDI with dynamic allocation and change uuid:
VBoxManage clonehd OLD.vdi NEW.vdi --variant Standard
VBoxManage internalcommands sethduuid NEW.vdi
Now you can expand it and reattach to VM:
VBoxManage modifyhd "NEW.vdi" --resize $(echo $((SIZE * 1024))) # size in GB
VBoxManage showvminfo VM_NAME | tee VM_NAME.info # save settings
VBoxManage storageattach VM_NAME \
--soragectl "SATA"
--device 0 \
--port 0 \
--type hdd \
--medium NEW.vdi
Cleanup
Once it's all working, optionally remove the old snapshots:
VBoxManage snapshot VM_NAME list \
| grep -o '[-0-9aa-z]\{36\}' \
| xargs -n1 -I{} VBoxManage snapshot VM_NAME delete {}
Resize guest partition
Look up how to do this for your particular guest OS
No comments :
Post a Comment