wtorek, 24 stycznia 2017

Resize vagrant disk storage (hard drive) with Virtual Box provider and Windows guest.

You need to know your VM name. It can be checked with:
> VBoxManage list vms
"YOUR_VM_NAME" {385e587a-ad47-4d36-a734-a126b9e04590}

Usually vagrant boxes comes with VMDK type storage which cannot be resized. 
You need to convert the format to resizeable VDI.
> VBoxManage  clonehd \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vmdk" \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vdi" \
--format vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'vdi'. UUID: 67985552-a3e5-4fad-aedd-82565ac963d4


packer-virtualbox-iso-1459796137-disk1.vmdk is a hdd disk file. Your file name can differ slightly. 
packer-virtualbox-iso-1459796137-disk1.vdi is new disk file that will be created in VDI format.
 
Now it's time to resize the disk image.
> VBoxManage modifymedium \
/root/VirtualBox\ VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vdi \
--resize 163840
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

163840 is new disk size in MB. Now you need to convert the disk image back to VMDK.
> VBoxManage  clonehd \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vdi" \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vmdk" \
--format vmdk
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'vmdk'. UUID: 9f433356-976c-422b-b7f1-2e1279cec993


Run the VM (for example: `vagrant up`). In our case it is a Windows machine. 
That's why you need to go to the guest system and increase disk size there.
Open Disk Management `diskmgmt.msc`. Right click on allocated partition and click Extend Volume.

3 komentarze:

  1. VBoxManage: error: Failed to lock media when compacting '/root/VirtualBox VMs/sql-play/packer-virtualbox-iso-1459796137-disk1.vmdk'
    VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MediumWrap, interface IMedium, callee nsISupports
    VBoxManage: error: Context: "Resize(cbResize, pProgress.asOutParam())" at line 701 of file VBoxManageDisk.cpp
    VBoxManage: error: Failed to resize medium!

    OdpowiedzUsuń
  2. 0%...
    Progress state: VBOX_E_NOT_SUPPORTED
    VBoxManage: error: Resize medium operation for this format is not implemented yet!

    OdpowiedzUsuń
  3. The King Casino - Atlantic City, NJ | Jancasino
    Come on in febcasino the https://jancasino.com/review/merit-casino/ King https://deccasino.com/review/merit-casino/ Casino for fun, no wagering requirements, delicious dining, and enjoyable casino gaming all at the heart jancasino.com of Atlantic City.

    OdpowiedzUsuń