Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detach vmdk using vboxmanage cli

I have my sandbox created using vboxmanage cli tool which created vmdk file.

I converted it from .vmdk to .vdi, as i wanted to compress it. then i attached this newly created .vdi file.

Now i want to detach the vmdk file as i don't want it any more. Can you please suggest me what should be the command for the same?

List of my HDDs are:

$ vboxmanage list hdds
UUID:           f3b90783-abe7-4549-91aa-39aa6161f103
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       /home/ankit/VirtualBox VMs/asr-vm/asr-sandbox-3.5.0-lb1404x64-disk1.vmdk
Storage format: VMDK
Capacity:       65536 MBytes

UUID:           1b9a4eff-f1bd-4c4e-ae48-8f11b8003244
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       /home/ankit/VirtualBox VMs/asr-vm/asr-sandbox-3.5.0-lb1404x64-disk1.vdi
Storage format: VDI
Capacity:       65536 MBytes
like image 1000
UserASR Avatar asked Jan 04 '17 12:01

UserASR


People also ask

What is VBoxManage?

As briefly mentioned in Section 1.18, “Alternative Front-Ends”, VBoxManage is the command-line interface to Oracle VM VirtualBox. With it, you can completely control Oracle VM VirtualBox from the command line of your host operating system.

Where is VBoxManage?

VBoxManage.exe is a file in the root directory of the VirtualBox installation on Windows. You find it under C:\Program Files\Oracle\VirtualBox by default. Start by opening a new command prompt window and navigating to the VirtualBox folder.


2 Answers

the solution for this is to attach that medium with emptydrive or none. that means for that particular port and device you are attaching an emptydrive or none.

vboxmanage storageattach "asr-vm" --storagectl "SATA" --port 1 --medium none

or

vboxmanage storageattach "asr-vm" --storagectl "SATA" --port 1 --medium emptydrive

As per docs medium none is a better option.

like image 138
UserASR Avatar answered Nov 02 '22 04:11

UserASR


For anyone wondering why none is a better option than emptydrive for the --medium flag, the VboxManage docs have this to say:

--medium

Specifies what is to be attached. The following values are supported:

  • none: Any existing device should be removed from the given slot.
  • emptydrive: For a virtual DVD or floppy drive only, this makes the device slot behave like a removeable drive into which no media has been inserted.

So given we want to detach (or "remove" it), none seems like the correct option.

Source: https://www.virtualbox.org/manual/ch08.html#vboxmanage-storageattach

This is a reponse to Mehrdad Hedayati comment to the accepted answer.

like image 29
Scott Giminiani Avatar answered Nov 02 '22 03:11

Scott Giminiani