VMware Cloud Community
Amadeus1756
Contributor
Contributor

Orphaned folders in a data store

I've been moving VMs around my datastores (using the GUI in VCenter - Migrate, change datastore) which seemed to work ok, but it looks like it's basically copied a machine, leaving loads (20+) of VM folders behind.

Whilst I'm confident (but that might be misplaced - I'm pretty new to Powershell and VMware tho I have written some scripts I'm pretty happy with) that I can find out the size of a folder on a datastore, what I don't know is how I can determine which of those folders is an orphan in terms of not being a machine listed anywhere in VCenter.

I'm not looking for someone to write this for me (tho if there is something already done which would allow me to get this information, I'll gladly save myself the time), more for guidance on how I can get this information.

As an aside, if anyone knows of a reason why this situation happens (even if it's a bug in VMware), I'd be glad to hear it.

Many thanks

Message was edited by: Amadeus1756 - correct spelling mistake

0 Kudos
8 Replies
MartinAmaro
Expert
Expert

here are two

http://sigtar.com/2011/01/21/vmware-finding-orphaned-files/

or

http://www.lucd.info/2011/04/25/orphaned-files-and-folders-spring-cleaning/

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful.
Amadeus1756
Contributor
Contributor

Thanks very much Martin - I'll take a look at them.

Rgds

0 Kudos
LucD
Leadership
Leadership

Make sure to run my script first without the Delete switch, that will list the files and folders without actually deleting them.

If you need further guidance, feel free to ask.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Amadeus1756
Contributor
Contributor

Thanks Luc.

I had a little look at your script and frankly I was amazed by the comments from people not having looked to see what it did before they used the -Delete option, but maybe that's just me being cautious and I should live a little... 🙂

Other things have come up today so almost certainly I won't get a chance to look at for a few days; I'll shout if I have any questions or issues.

As a slight aside, are you planning on updating your PowerCLI book to deal with version 5?

Many thanks

0 Kudos
LucD
Leadership
Leadership

Yes, people tend to not read the instructions:smileycry:

Let me know when you had time to try it out, if there are questiions.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Amadeus1756
Contributor
Contributor

Hi Luc,

I finally managed to get some time to look at your script; I had a certain amount of success but I have a number of questions.

Let me describe the scenario to you.

I have a datastore - VMFS-VB02.  If I use VCenter to navigate to Inventory -> Datastores and look at the Virtual Machines tab, I see 23 rows - 7 templates and 16 VMs.

If I go to the "Getting Started" tab of the datastore and use the link "Browse this datastore", I see 37 folders.

Using :

     Get-Datastore "VMFS-VB02" | RemoveOrphanedData"

gives me a list of 9 folders.

So the question is, what about the other 5?

As I suspect is common in many organisations, the folder names do not always match up with VM names which makes it a little more tricky to identify what's going on.

I suppose I should go through every VM on the datastore, use the Summary tabl of the VM to determine what datastore it's on.  But will that show *everything* associated with the VM (it looks like it can only show one datastore)?

If I use the datastore browser, I see one folder has only ~30 snapshots (each of a trivial size).  Can a smapshot be on a different datastore to the rest of the VM?

One folder has just one file - a vmdk file.  I *believe* (correct me if I'm wrong!) that it is possible to use a VMDK file on any datastore.

Many thanks for any guidance you can offer.

Rgds

0 Kudos
LucD
Leadership
Leadership

Yes, you can change the location if snapshot files by manipulating the .VMX file. See KB1002929

But that is not foreseen in the script. I'll have to post an update for that.

Yes, you can have a .VMDK in a seperate folder. But the script should handle those. That was introduced in the May 22nd 2011 update.

Did you check if there are perhaps a couple of VMs that are stored in the same folder as another VM ?

You can easily store 2 VMX files in the same folder. That would give 2 VMs but only 1 folder.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Amadeus1756
Contributor
Contributor

That's an interesting thought - I'll take a look at that tomorrow - thanks Luc

0 Kudos