Unable to remove datastore

hongedit
hongedit used Ask the Experts™
on
ESXi 4.1 u1

I have a datastore I had created a while ago as a dedicated snapshot datastore.

Seems I have no real need for it, so I am trying to delete it to save some space.

It has 4 files in it:

1 x Server-2712244423.vswp
3 x Exchange-_xxx.vmdk

It wont let me delete these files? The last mod time on them was over 1 yeatr ago so I know they are safe.

"Cannot Delete file [Server- Server2712244423.vswp"

If I just try to remove the datastore I get:

The resource 'GUID' is in use.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
are you sure that your Server-Server is not using the datastore, a VSWP file belongs to a VM, which is Power-ed ON, hence why you cannot delete it.
Top Expert 2010

Commented:
Your VM's files are using this DS for its VMDK and you may have config'd your host to use this DS for the VM's swap file. If you pwr down the VM, the .vswp file goes away. You should also be able to move the VMDK to another DS while the VM is powered down as well.

~coolsport00

Author

Commented:
Thats the thing.

I cannot manually delete any of the 4 files left in this datastore, not just the vswp one.

I'll shut the VM down that it belongs to in a couple hours and see if it disappears. But WHY would it be in this datastore?
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
That's because it's in USE!

be very careful what you delete!
Top Expert 2010

Commented:
Your VMDK is prob assigned to your VM. You should be able to go into your VM settings and see it, yes? And, you should be able to see what datastore the VM's VMDKs are on.

And, if you redirected your VM's swapfile location...you won't need to delete that, it'll disappear once the VM is powered down.

Author

Commented:
Ok.

I downloaded the .vmx file and I found this line:

sched.swap.derivedName = "/vmfs/volumes/4dd54b7b-0c9419b8-767f-00259033dd4c/Server 2003-54224000.vswp"

This matches what is in the datastore I want to delete.

Question is,

A) How do I move this back to its default location (same dir the vmx/vmdk resides)
B) How did this happen? I dont remember manually putting this in...
Top Expert 2010
Commented:
Rt-click on VM -> Edit Settngs -> Options tab, then swapfile location (bottom option). Choose to store with VM.

VMswapLoc
Top Expert 2010

Commented:
To answer your "B" question. Not sure...only you can ;) This is a manual process so someone had to configure it...
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017
Commented:
It could have been a migration, storage vMotion.

Edit the VM Settings, Options, Swapfile Location

Swapfile.jpg
Top Expert 2010

Commented:
**NOTE: IF THE HOST OR CLUSTER DEFAULT IS TO STORE THE .VSWP IN AN ANCILLARY DATASTORE, THEN THE .VSWP MAY STILL GET PLACED IN THE ANCILLARY DATASTORE & NOT WITH THE VM. If that is the case, you should select the 2nd option - store with the VM.

Author

Commented:
Ok, I have done that but the file is still there. Do I need to reboot the VM?

Also, the rest of the files are old snapshot files I think.

I'm pretty sure they are orphaned from a prior incident, as the last modified date on the was over a year ago and the VM they relate to is called something different now.

However still unable to delete them.

Exchange_1-00000007.vmdk
Exchange-0000004.vmdk
Exchange_1-00000008.vmdk

All 2MB in size.
Top Expert 2010

Commented:
Yes...you more than likely have to restart the VM...
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
I would move the files, rather than delete, just in case you need them.

you could login at the console or SSH, and check they are not in use, this would be the scientific  way of checking, rather than the just delete them!
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
lsof | grep<name of locked file>
Top Expert 2010

Commented:
I have personally download file to my workstation before deleting just in case I missed something & they were then needed post-deletion....

Author

Commented:
Hmm. Rebooted.

Nothing seems to have changed??
Top Expert 2010

Commented:
Refresh your datastore?
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
login via ssh or on the console, and use

lsof | grep<name of locked file>

check which process has the file opened

Author

Commented:
Refreshed Datatsore, the vswp file is still there.

Logged in via SSH.

lsof | grep <filename>

Just returns the bash prompt again...(i.e no result)

Author

Commented:
I noticed as well in SSH there are some delta files there too which dont show in the datastore browser.

One delta file for each vmdk.
Top Expert 2010

Commented:
?? Wierd! You may be able to take a snap of the VM, wait like 10mins, then go into Snap Mgr and remove the snap. That may take care of those files...

Author

Commented:
Thats the thing - these snapshot files in this datastore I want to get rid of do not even tie up with any current Live VM...

So currently I still have 1 vswp file which wont go away, and some random old snapshot files which I cant delete...

Author

Commented:
OK, I think I got rid of the snapshor files and delta files via SSH.

I copied them to a local datastore and then deleted via rm command.

So that just leaves this vswp file which should be with the VM, but isnt.
Commented:
Ah I think I found something.

Look at the VMX file:

workingDir = "/vmfs/volumes/Snapshots"
fileSearchPath = "/vmfs/volumes/Snapshots;."

Snapshots is the datastore I am trying to get rid of.

Can I just shut this VM down and delete those lines?
Commented:
Well I went ahead and removed it.

Seems to be all working fine, thanks chaps!
Top Expert 2010

Commented:
Wow..that was fast! Sorry...was on a call with someone. Well, glad you're good to go now...

Author

Commented:
No Comment

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial