Using vifs to Manipulate Files on Remote ESXi Hosts
In most cases, vmkfstools and other commands are used to manipulate virtual machine files. In some cases, you might have to view and manipulate files on remote ESXi hosts directly.
The vifs command performs common operations such as copy, remove, get, and put on ESXi files and directories. The command is supported against ESXi hosts but not against vCenter Server systems.
Some similarities between vifs and DOS or UNIX/Linux file system management utilities exist, but there are many differences. For example, vifs does not support wildcard characters or current directories and, as a result, relative pathnames. Use vifs only as documented.
Instead of using the vifs command, you can browse datastore contents and host files by using a Web browser. Connect to the following location:
http://ESX_host_IP_Address/host
http://ESX_host_IP_Address/folder
You can view datacenter and datastore directories from this root URL. For example:
http://<ESXi_addr>/folder?dcPath=ha-datacenter
http://<ESXi_host_name>/folder?dcPath=ha-datacente
The ESXi host prompts for a user name and password.
The vifs command supports different operations for the following groups of files and directories. Different operations are available for each group, and you specify locations with a different syntax. The behavior differs for vSphere 4.x and vSphere 5.0.
The /tmp directory and files in that directory.
Datastore prefix style: '[ds_name] relative_path'. For example:
URL style: /folder/dir/subdir/file?dsName=<name>. For example:
To avoid problems with directory names that use special characters or spaces, enclose the path in quotes for both operating systems.
When you run vifs, you can specify the operation name and argument and one of the standard connection options. Use aliases, symbolic links, or wrapper scripts to simplify the invocation syntax.
Options
vifs command-specific options allow you to retrieve and upload files from the remote host and perform a number of other operations. All vifs options work on datastore files or directories. Some options also work on host files and files in the temp directory. You must also specify connection options.
Copies a file in a datastore to another location in a datastore. The <source> must be a remote source path, the <target> a remote target path or directory.
The - -force option replaces existing destination files.
Lists the datastore names on the ESXi system. When multiple data centers are available, use the - -dc (-Z) argument to specify the name of the datacenter from which you want to list the datastore.
Moves a file in a datastore to another location in a datastore. The <source> must be a remote source path, the <target> a remote target path or directory.
The - -force option replaces existing destination files.
You can list information about the remote directories in several ways. Specify one of the connection options listed in Connection Options in place of <conn_options>.
vifs <conn_options> --listds.
The command lists the names of all datastores on the specified server. For example:
osdc-cx700-02
osdc-cx700-03
osdc-cx700-02
osdc-cx700-03
osdc-cx700-04
osdc-cx700-05
You can use each name that has been returned to refer to datastore paths by using square bracket notation, as follows:
'[my_datastore] dir/subdir/file'
vifs <conn_options> --dir '[osdc-cx700-02] winxpPro-sp2'
The command lists the directory content. In this example, the command lists the contents of a virtual machine directory.
Content Listing
_________________
vmware-37.log
vmware-38.log
...
vmware.log
...
winxpPro-sp2.vmdk
winxpPro-sp2.vmx
winxpPro-sp2.vmxf
...
vifs <conn_options> --dir '[osdc-cx700-02]'
The command lists the complete contents of the datastore.
The following example scenario illustrates other uses of vifs. Specify one of the connection options listed in Connection Options in place of <conn_options>.
To manage files and directories on the remote ESXi system
1
vifs <conn_options> --mkdir '[osdc-cx700-03] vcli_test'
You must specify the precise path; there is no concept of a relative path.
2
vifs <conn_options> - -put /tmp/test_doc '[osdc-cx700-03] vcli_test/test_doc'
3
vifs <conn_options> - -move '[osdc-cx700-03] vcli_test/test_doc'
'[osdc-cx700-03] winxpPro-sp2/test_doc
A message indicates success or failure.
4
The following example retrieves a log file for analysis.
vifs <conn_options> --get '[osdc-cx700-03] winxpPro-sp2/vmware.log' ~user1/vmware.log
5
vifs <conn_options> --rm '[osdc-cx700-03] vcli_test/test_doc'
vifs <conn_options> --rmdir '[osdc-cx700-03] vcli_test'