Delete content library fails with error "Cannot delete file"
search cancel

Delete content library fails with error "Cannot delete file"

book

Article ID: 411332

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • Getting error in vSphere Client when deleting a content library:
    Cannot delete file [Datastore_name]/<Content_library_file_name>
  • Error observed while using rm command to delete files in the datastore directory:
    Device or resource busy

Environment

VMware vCenter Server

Cause

This issue occurs when the ISO file is being mounted and used by other VMs.

Resolution

This issue can be resolved by identifying the virtual machine that holds the ISO and unmounting it.

  • In the datastore directory, run following command to identify the virtual machine holding the ISO
    1. Use vim-cmd command
      • Command to identify the list of running VMs and its VMid
        vim-cmd vmsvc/getallvms
      • Command to identify if specific ISO being on identified VM using VMid
        vim-cmd vmsvc/device.getdevices <vmid> | grep -A 12 "<ISO_Image_file_name.iso" | grep "connected = true"
        Note: Replace <vmid> with the output from last command.
      •  Repeat for all VMid
    2. Use find command to identify the virtual machine
      find /vmfs/volumes/ -iname "*.vmx" -print0 | xargs -0 grep -ih iso
  • Procedure to unmount ISO from vCenter UI
    1. Log in to the vSphere Client
    2. Navigate to host and cluster > select the VM
    3. Right-click on a VM and select "Edit Settings".
    4. Under "CD/DVD Drive" tab and check the "Label" and "ISO Path" to see if a specific ISO is mounted.
    5. Deselect the radio button beside "Connected" to unmount the CD/DVD drive.
    6. Repeat for all the VMs.