In the blog before this one. I explained how you could create a (software) RAID1 with LVM. This storage is meant to be shared as NFS. One of it’s purposes is NFS datastore on ESXi 5.*. Underneath i will explain how to mount the NFS on the ESXi commandline, but also I will give you a tip how to store your snapshots and vswap files on another datastore than the datastore the VM’s is stored on.
– I assume you have created your own share.
– You have created the proper firewall rules (or disabled it)
– Have esxcli and ssh enabled on the ESXi host.
Step 1: Mounting NFS on ESXi
First ssh into the ESXi host.
The command for mounting the NFS share is relatively easy:
esxcli storage nfs add --host=10.0.0.123 --share=/mnt/storage/esx --volume-name=nfsstore
*Note: If you want to remove the nfs share use this command:
esxcli storage nfs remove -v nameofshare
* host, can also be the hostname or FQDN as long as your dns is setup correct 😉
* share, is the remote folder
* volume-name, here you can choose the name you want to specify for the mounted NFS share.
If you want to check wether it succeeded or not:
/vmfs/volumes # ls -ltra
drwxr-xr-x 1 root root 8 Jan 1 1970 c34c5b7b-1c62de71-74d7-937ec239b9ba
drwxr-xr-x 1 root root 8 Jan 1 1970 b08d9470-61e58dd0-1709-e9f513a608b3
drwxr-xr-x 1 root root 8 Jan 1 1970 5410b940-62753a52-cb37-001b78cb439a
drwxr-xr-x 1 root root 8 Jan 1 1970 5410b92c-88e9c029-43bf-001b78cb439a
drwxr-xr-x 1 root root 512 Sep 17 14:40 ..
drwxr-xr-t 1 root root 2520 Nov 7 16:52 5410b938-5a660f15-7f35-001b78cb439a
lrwxr-xr-x 1 root root 17 Nov 10 09:06 nfsstore -> aff9aebd-4469282f
lrwxr-xr-x 1 root root 35 Nov 10 09:06 datastore1 -> 5410b938-5a660f15-7f35-001b78cb439a
drwxr-xr-x 1 root root 512 Nov 10 09:06 .
drwxr-xr-x 1 root root 40 Nov 10 2014 aff9aebd-4469282f
As you can see, the nfsstore was added. I can also see it in my vsphere (web) client:
Step 2: Changing the snapshot and vswap location:
My virtual machines run on a hp server. Which has a raid5 with 10k SAS disks. So for speed and fail security purposes I’d like to have the vm files on there. However snapshots could be stored on the nfs store. I found this addition that makes the above possible.
First go to your vsphere client and download the .vmx file of your VM (make sure it is down!)
Next open the .vmx with a tool like notepad++. Add the rules beneath and enter the correct collection of your storage folder. (Please don’t forget to upload the .vmx file to the datastore). I’d like to recommend you create folders per vm, else all snashots will be in the same folder.
workingDir = "/vmfs/volumes/nfsstore/eros"
snapshot.redoNotWithParent = "true"
sched.swap.dir = "/vmfs/volumes/nfsstore/eros"
IMPORTANT: Please make sure you create the folders manual on forehand. Else the VM will NOT start!
Now start the VM and create a snapshot to test if it’s working!
As you can see the snapshot was created and written to the nfs share! This will save me alot of space on the standard datastore.