UserASR
UserASR

Reputation: 2205

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

Upvotes: 11

Views: 12378

Answers (2)

UserASR
UserASR

Reputation: 2205

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.

Upvotes: 16

Scott G
Scott G

Reputation: 855

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.

Upvotes: 1

Related Questions