![]() In my case, DS01 has about 27000 files, enumerating which using Get-ChildItem took an hour… And in an enterprise environment, 27000 files is not that many. Get-Childitem -Path vmstore:DatacenterDS-NFS-00 -Recurse -ForceĪnd you get plenty of results. Now, when leveraging the -Recurse parameter, I should be able to traverse the entire datastore: For example, in my case with the datastore named “DS-NFS-00”, the following caused an error: Not so in the harsh mountains of Linux, make sure you get the capitalization correct. LESSON LEARNED: I live in a Microsoft world where we all happily frolic in a field of files that don’t care if you use the correct capitalization when you call them. Get-Childitem -Path vmstore:DatacenterDS-NFS-00 It’s a drive, so Get-ChildItem should work: ![]() That’s the one we want, and we are working with our datacenter that’s conveniently called Datacenter and datastore DS01. Vmstores contains all the known datastores, Vmstores are the ones available on the VCenter server you are currently connected to. There are VimInventory drives (which as the name suggests are an inventory of the configurations), and VimDatastores. Sounds promising, so let’s give it a try: This enables us to look at the virtualization datastores as if they were regular disk drives. The first technique I will discuss is leveraging the fact that PowerCLI exposes PSDrives for the available file datastores. However, for the task at hand, it is important that I see the same picture that my virtualization infrastructure sees. Of course, there may be ways of gaining direct access to the storage array. The first thing I need to do is to gain a view of the storage from the vSphere perspective. Let’s start with initializing our PowerShell session and establishing a connection to the vCenter server: As you will see, using PowerShell has its advantages (such as the potential for automating the process of searching the datastores, and being able to perform simple root-cause analysis for disk space shortage without third-party software), as well as several drawbacks and caveats. To accomplish the task, I will be using the VMware PowerShell module (AKA PowerCLI). So this is my mission: Find all files on a VMware Datastore, see how long they have not been changed for and then determine if they are still useful or can be deleted safely. The best candidates for immediate deletion are files that occupy significant space and are not actually used, or, as it may be in some cases, are not even connected to any VMs. ![]() Like any storage, over time datastores tend to fill up, and when the percentage of used space reaches worrying levels it’s time to look for stuff that can be thrown away in order to clear the mess before a storage crisis unfolds. Datastores in any typical virtualized environment are critical components that hold virtual disks, snapshots, and other data that keeps your VMs alive. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |