removing locked vmdk file

we are trying to remove a file from the datastore.
it is no longer in use and not needed.

the error message for 'rm filename.vmdk' is:
rm: cannot remove 'filename.vmdk': Device or resource busy

anyway to determine the process holding this file?

thank you.

ESXi host ver is 4.0
rastafarayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wesly_chenCommented:
As root, run
fuser -k /path-to-filename.vmdk
  to kill the process that lock that vmdk file.

fuser -u /path-to-filename.vmdk
  show which user and pid access that vmdk file.
0
rastafarayAuthor Commented:
i dont think fuser is installed on ESXi
"-ash: fuser: not found"

any suggestions?
0
MysidiaCommented:
This is ESXi after all,  so no,  fuser does not work.   But a VMDK file should not be locked against a Virtual machine is actually running that has this file attached, either as a base disk, or a file referred by a base disk  or VMDK descriptor file.
In fact, the lock should timeout.

Anyways, you haven't shown enough information about the filename to determine if we're talking about a  VM's  descriptor file  (virtual machine name).vmdk,       a flat file with actual data   (vmname)-flat.vmdk,  or a delta file such as  (vmame)-1_1.vmdk

So my question is:   Is this SHARED storage or local storage?
If this is local storage,  matters should be pretty easy,  and you can use vmkfstools  to break the lock, potentially,  although you should try rebooting the host before resorting to such extreme measures.

There are some ways to potentially break the lock and manipulate the file anyways,
but they are quite dangerous, and may lead to an outage if you are actually in error
in your belief the file is unused..


If this is local storage...  I would suggest you go to each powered on virtual machine..
Click Edit settings
look at each hard disk, and verify your particular file is not referred, nor any filename like it.


Of course this is also not absolutely foolproof.
But chances are very good  the file you "think is not being used",  is actually being used.


Unless your VMFS volume has some damage to it as a result of unclean shutdowns...





0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

wesly_chenCommented:
What's the process name for ESXi?
Or can you temporarily stop ESXi software and remove that vmdk file?
0
rastafarayAuthor Commented:
hi Mysidia,

looks like i missed a lot of the details.

the file is named "(vmnameX)-flat.vmdk" in one datastore:
(vmnameX)/(vmnameX)-flat.vmdk

and the same exists in another datastore:
(vmnameX)/(vmnameX)-flat.vmdk
(vmnameX)/(vmnameX)_1-flat.vmdk

i have already deleted the VM (vmnameX), so vmnameX no longer exists in vCenter.  but the above mentioned files are still there.

so the options are to wait or to force delete these files using vmkfstools.  host reboot is not an option at this time due to production environment.

the storage is shared (i assume) on a SAN via iSCSI.

does this help?
0
smangognaCommented:
Try to restar managment services
0
smangognaCommented:
and than delete the locked file
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
try lsof and see if it is in use.
0
Naga Bhanu Kiran KotaCommented:
hi Ray,

did you try to restart the vmware management services on the ESXi machines, as there is a likely possibility that there might be a VI client task that might have locked the vmdks

"service mgmt-vmware restart " yeah i know this is a basic one, but still do this on both the ESXi servers.

Next :

did you verify if there is any linked clone or anything else.

confirm if there is any vmx file in both the folder locations and query if there is any active process for that vmx file on the esxi console.

refer to this vmware kb article.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1014165

regards
bhanu
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MysidiaCommented:
I would suggest following the steps in VMware KB 10051

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=10051

* SSH to the ESX(i) host.

* use the vmkfstools -D command to find which host is locking the file

vmkfstools -D /vmfs/volumes/<UUID>/<VMDIR>/filename.vmdk

You should get the MAC address of the machine locking the file

either displayed on screen, or you may need to tail  /var/log/vmkernel
or /var/log/messages
on versions of ESX before 4.1

* Identify which ESX host has the MAC address that is locking the file.

* SSH to that host

run  the command

lsof | grep  NAME-OF-LOCKED-FILE

to find the PID of the process   locking the file


* Attempt to find a world ID of the process
vm-support -x


* KILL the monitor/VM process for that world

vm-support -X (world id)



 







0
rastafarayAuthor Commented:
THANK YOU ALL
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VMware

From novice to tech pro — start learning today.