ESXi Datastore Best Practices
Overview
This guide covers best practices for naming and managing ESXi datastores in a homelab environment, particularly for VCF deployments.
Datastore Naming Conventions
Why Not Use “datastore1”?
The default “datastore1” name:
- Provides no context about the storage
- Creates confusion in multi-host environments
- Makes troubleshooting difficult
- Doesn’t indicate storage type or purpose
Recommended Naming Patterns
Local Datastores
<hostname>-<storage-type>-<purpose>
Examples:
esxi-nuc-01-ssd-local
esxi-ms-a2-01-nvme-boot
esxi-ms-a2-02-nvme-vsan
Shared Datastores (iSCSI/NFS)
<storage-system>-<protocol>-<purpose>
Examples:
synology-iscsi-vcf-content
synology-nfs-iso-library
freenas-iscsi-vm-storage
vSAN Datastores
vsan-<cluster-name>
Examples:
vsan-mgmt-cluster
vsan-workload-cluster
Storage Configuration by Host Type
Intel NUCs
Local Storage:
- Name: esxi-nuc-XX-ssd-local
- Size: 250GB NVMe
- Purpose: ESXi boot, local VMs
Shared Storage:
- Name: synology-iscsi-nuc-shared
- Size: 4TB (RAID0)
- Purpose: VM storage
MS-A2 Hosts
Boot Drive:
- Name: esxi-ms-a2-XX-nvme-boot
- Size: 500GB
- Purpose: ESXi installation
vSAN Capacity:
- Name: (Managed by vSAN)
- Size: 4TB+ NVMe
- Purpose: vSAN datastore
Datastore Discovery in Scripts
Dynamic Datastore Discovery
Instead of hardcoding datastore paths, scripts should discover available datastores:
# List all datastores
esxcli storage filesystem list
# Get first available datastore (excluding VFFS)
DATASTORE=$(esxcli storage filesystem list | grep -E "VMFS|NFS" | head -1 | awk '{print $2}')
# Get largest datastore
DATASTORE=$(esxcli storage filesystem list | grep -E "VMFS|NFS" | sort -k3 -nr | head -1 | awk '{print $2}')
# Get datastore by name pattern
DATASTORE=$(esxcli storage filesystem list | grep "local" | head -1 | awk '{print $2}')
Safe Datastore Selection
# Function to select appropriate datastore
select_datastore() {
# Try to find local datastore first
local datastore=$(esxcli storage filesystem list | grep -i "local" | head -1 | awk '{print $2}')
# If no local datastore, get any VMFS datastore
if [ -z "$datastore" ]; then
datastore=$(esxcli storage filesystem list | grep "VMFS" | head -1 | awk '{print $2}')
fi
# If still nothing, get first available
if [ -z "$datastore" ]; then
datastore=$(esxcli storage filesystem list | grep -v "VFFS" | head -1 | awk '{print $2}')
fi
echo "$datastore"
}
Renaming Datastores
Via ESXi Command Line
# Get current datastore info
vim-cmd hostsvc/datastore/listsummary
# Rename datastore (example)
vim-cmd hostsvc/datastore/rename datastore1 "esxi-nuc-01-ssd-local"
Via vCenter/vSphere Client
- Navigate to Storage view
- Right-click datastore
- Select “Rename”
- Enter new descriptive name
Via PowerCLI
# Connect to vCenter/ESXi
Connect-VIServer -Server vcenter.lab.local
# Rename datastore
Get-Datastore -Name "datastore1" | Set-Datastore -Name "esxi-nuc-01-ssd-local"
VCF Specific Considerations
Management Domain Datastores
VCF expects specific datastore configurations:
- vSAN Datastore (Preferred)
- Automatically created during VCF deployment
- Named by VCF (e.g., “vsanDatastore”)
- Do not rename VCF-managed datastores
- Local Datastores
- Used for ESXi boot only
- Can be renamed before VCF deployment
- Not used for VCF workloads
Workload Domain Datastores
- Follow organizational naming standards
- Include workload type in name
- Examples:
vsan-prod-workloadvsan-dev-clusteriscsi-tanzu-storage
Script Improvements
Original (Problematic)
BACKUP_DIR="/vmfs/volumes/datastore1/host-backup-$(date +%Y%m%d)"
Improved (Dynamic)
# Discover available datastore
DATASTORE=$(esxcli storage filesystem list | grep VMFS | head -1 | awk '{print $2}')
if [ -z "$DATASTORE" ]; then
echo "Error: No VMFS datastore found"
exit 1
fi
BACKUP_DIR="${DATASTORE}/host-backup-$(date +%Y%m%d)"
Best Practice (Parameterized)
# Allow user to specify datastore
DATASTORE="${1:-$(esxcli storage filesystem list | grep VMFS | head -1 | awk '{print $2}')}"
if [ -z "$DATASTORE" ]; then
echo "Error: No datastore specified or found"
echo "Usage: $0 [datastore-path]"
exit 1
fi
BACKUP_DIR="${DATASTORE}/host-backup-$(date +%Y%m%d)"
Monitoring and Maintenance
Regular Tasks
-
Monitor Datastore Usage
esxcli storage filesystem list df -h -
Check Datastore Health
esxcli storage core device list esxcli storage vmfs extent list -
Verify Naming Consistency
- Ensure all datastores follow naming convention
- Document any exceptions
- Update automation scripts as needed
Summary
Key takeaways:
- Never use default “datastore1” name in production
- Use descriptive names that include host/purpose/type
- Make scripts discover datastores dynamically
- Don’t rename VCF-managed datastores
- Document your naming convention
- Be consistent across the environment
This approach makes troubleshooting easier and automation more reliable.