|
VMware ESX Server 2.1
Features | Documentation | Knowledge Base | Discussion Forums The vmkfstools command supports the creation of a VMware ESX Server file system (VMFS) on a SCSI disk. Use vmkfstools to create, manipulate and manage files stored in VMFS volumes. You can store multiple virtual disk images on a single VMFS volume. Note: You can also do most of the vmkfstools operations through the VMware Management Interface. Note: You must be logged in as the root user to run the vmkfstools command. The format for the vmkfstools command, when specifying a SCSI device, is: vmkfstools <options> <device_or_VMFS_volume>[:<file>] where <device_or_VMFS_volume> specifies a SCSI device (a SCSI disk or a partition on a SCSI disk) being manipulated or a VMFS volume, and <options> specifies the operation to be performed. If <device_or_VMFS_volume> is a SCSI device, then it is specified in a form such as: vmhba1:2:0:3 Here, vmhba1 specifies the second SCSI adapter activated by the command vmkload_mod .../XXX.o vmhba. (See VMkernel Module Loader for details on vmkload_mod.) The second number specifies the target on the adapter, the third number specifies the LUN (logical unit number) and the fourth number specifies the partition. Partition 0 (zero) implies the whole disk; otherwise, the number specifies the indicated partition. <device_or_VMFS_volume> may also be a VMFS volume label, as set in the management interface or with the vmkfstools --setfsname command. <file> is the name of a file stored in the file system on the specified device. The format for the vmkfstools command, when specifying a VMFS volume or file, is: vmkfstools <options> <path> where <path> is an absolute path that names a directory or a file under the /vmfs directory. For example, you can specify a VMFS volume by a path such as: /vmfs/vmhba1:2:0:3 You can also specify a single VMFS file: /vmfs/lun1/rh9.dsk This section includes a list of all the options used with the vmkfstools command. Some of the tasks in this section include options that are suggested for advanced users only. These advanced options are not available through the VMware Management Interface. Note: The long and short (single letter) forms of options are equivalent. For example, the following commands are identical: vmkfstools --createfs vmfs2 --blocksize 2m --numfiles 32 vmhba1:3:0:1 vmkfstools -C vmfs2 -b 2m -n 32 vmhba1:3:0:1 If the vmkfstools command fails, and you don't know why, then check the log files in /var/log/vmkernel or use the management interface to view the latest warning.
Basic options are common tasks that you may perform frequently. You may also perform through the management interface.
-C --createfs [vmfs1|vmfs2] This command creates a VMFS version1 (vmfs1) or version 2 (vmfs2) file system on the specified SCSI device. For advanced users:
-P --querypartitions <VMFS_volume_name> For a VMFS_volume_name, the listed attributes include the VMFS version number (VMFS-1 or VMFS-2), the number of physical extents (partitions) comprising the specified VMFS volume, the volume label (if any), the UUID (if any), and a listing of the SCSI device names of all the physical extents comprising the VMFS volume. For a VMFS_volume:fileName, the listed attributes include the vmhba name of the raw disk or partition, corresponding to the mapping referenced by fileName, and any identification information for the raw disk. -c --createfile #[gGmMkK] The size is specified in bytes by default, but you can specify the size in kilobytes, megabytes, or gigabytes by adding a suffix of k (kilobytes), m (megabytes), g (gigabytes) respectively. -e --exportfile <dstFile> After the export, you may transfer the virtual disk to another server machine and import it to a SCSI device on the remote machine. If your virtual disk has redo logs, you have the following options:
Use the combination of exportfile and importfile together to copy VMFS files to remote machines. The virtual disk should take less space than the full size of the VMFS file, since the virtual disk does not include zeroed sectors of the VMFS file. -i --importfile <srcFile> This command is often used to import the contents of a VMware Workstation or VMware GSX Server virtual disk onto a SCSI device. You may also run this command to import a virtual disk, that was created by exporting the contents of a disk from another SCSI device. Note: The destination device must have space for the entire size of the virtual disk, even if it is mostly free space, as the complete contents of the source disk are copied. Caution: The vmkfstools command may fail when attempting to import plain disks created with version 2.5 or earlier of GSX Server. If vmkfstools returns an error when importing a plain disk, see Path Name Failures When Importing GSX Server Virtual Machines.
-l --list The output includes permissions, sizes and the last modification time for redo logs, virtual disk files, and swap files. You can use the -h option to print the sizes in an easier-to-read format; for example, 5KB 12.1MB, and so on. (Advanced users only) The -M option lists the vmhba name that corresponds to each raw disk mapping. -S --setfsname <fsName> You can see the VMFS name by running the vmkfstools command with the -l option, vmkfstools -l. Advanced options are tasks that you may perform infrequently. These tasks are not available through the management interface, or are available in a limited form, and are suggested for advanced users only. -m --commit If a virtual machine is in undoable or append mode, then the redo log is created automatically. The name of the redo log is derived by appending .REDO to the name of the file that contains the base disk image. You can commit the changes to the disk that are stored in the redo log by using the commit option or eliminate the changes by using the rm command to delete the redo-log file. -F --config [public|shared|writable] Note: In ESX Server 2.1, private VMFS volumes are deprecated. If you have existing VMFS version 1 (VMFS-1) or VMFS version 2 (VMFS-2) private volumes, then change the access to public. Public With public VMFS-2 volumes, multiple ESX Server computers can access the same VMware ESX Server VMFS volume concurrently. VMware ESX Server file systems with a public access mode use an automatic per-file locking to ensure file system consistency. With a public VMFS-1 volume, multiple ESX Server computers have the ability to access the VMware ESX Server VMFS volume, as long as the VMFS volume is on a shared storage system (for example, a VMFS on a storage area network). However, only one ESX Server can access the VMFS-1 volume at a time. Note: ESX Server creates VMFS volumes as public by default. Shared The shared access mode allows virtual machines on multiple servers to access the same virtual disk on a VMFS-2 volume simultaneously. (In public mode, virtual machines can only access the same VMFS volume, never the same virtual disk, at the same time.) Note: A VMFS volume that is used for failover-based clustering should have its mode set to shared. Writable When virtual machines access a file on a shared VMFS, the file system metadata becomes read-only. That is, no virtual machine or user command can create, delete or change the attributes of a file. If you need to create, remove, or change the length of a file (vmkfstools -X), then you need to change the volume to "writable". First, be sure that no virtual machines are accessing the VMFS volume (all virtual machines are powered off or suspended), then change the file system metadata to writable with the command, vmkfstools --config writable. Once you power on or resume a virtual machine, the file system metadata reverts to being read-only.
-Z --extendfs <extension-SCSIDevice> This option adds another physical extent (designated by <extension-SCSIDevice>), starting at the specified SCSI device. By running this option, you lose all data on <extension-SCSIDevice>. Note: A logical VMFS-2 volume can have at most 32 physical extents. This operation is not supported on the VMFS-1 file system and in fact, returns an error if the specified SCSI device is formatted as VMFS-1. Each time you use this option and extend a VMFS-2 volume with a physical extent, the VMFS volume supports, by default, an additional 64 files. You can change this default number of files by using the -n option. -r --maprawdisk <raw-SCSI-device> Once this mapping is established, you can access the raw disk like a normal VMFS file. The file length of the mapping is the same as the size of the raw disk or partition. The mapping can be queried for the raw SCSI device name by using the -P option. By mapping a raw disk or partition to a file, you can manipulate this raw disk or partition as any other file. In addition, this mapping enables you to have undoable, append, and nonpersistent "raw disks". All VMFS-2 file-locking mechanisms apply to raw disks. -g -- geometry <virtual-disk> The output is in the form: Geometry information C/H/S is 1023/128/32, where C represents the number of cylinders, H represents the number of heads, and S represents the number of sectors. When importing VMware Workstation or VMware GSX virtual disks to VMware ESX Server, you may see a disk geometry mismatch error message. A disk geometry mismatch may also be the cause if you have problems loading a guest operating system, or running a newly created virtual machine. View the events log through the VMware Management Interface (Users and Events page for the virtual machine) or through the service console (the vmware.log file, found, by default, in the <user>/vmware/<guest_operating_system> directory). Look for C/H/S and compare this with the output of the vmkfstools -g command. If the disk geometry information is different, then specify the correct information, from the output of the vmkfstools -g command, in the configuration file of the newly created virtual machine. See Migrating VMware Workstation and VMware GSX Server Virtual Machines for complete details on specifying the disk geometry in a virtual machine's configuration file. -X --extendfile #[gGmMkK] Use this command to extend the size of a disk allocated to a virtual machine, after the virtual machine has been created. The virtual machine that uses this disk file must be powered off when you enter this command. Also, the guest operating system must be able to recognize and use the new size of the disk, for example by updating the file system on the disk to take advantage of the extra space. You specify the size in kilobytes, megabytes, or gigabytes by adding a suffix of k (kilobytes), m (megabytes), g (gigabytes) respectively. -L --lock [reserve|release|reset] Caution: Be careful when using these commands. The reserve, release, and reset commands can interrupt the operations of other servers on a storage area network (SAN), so use these commands with great caution. The -L reserve command reserves the specified raw disk, or the disk containing the specified VMFS volume. After the reservation, other servers will get a SCSI reservation error if they attempt to access that disk, but the server that did the reservation will be able to access the disk normally. The -L release command releases the reservation on the specified disk, or disk containing the specified VMFS volume. Any other server can access the disk again. The -L reset command does a SCSI reset to the specified disk. Any reservation held by another server is released. -R --recover This command enables you to recover a VMFS (accessible by multiple ESX servers) when other vmkfstools commands indicate that the file system is locked by another ESX Server machine, but, in fact, no other server is currently accessing this file system. This situation may occur if the VMFS was being accessed by a server (for example, running a virtual machine) and that server crashed. Note: You should only use this command if you are certain that no other ESX Server is still accessing the file system. -s --scan <FC_SCSI_adapter> This option is particularly useful for adapters connected to storage area networks, particularly if you are reconfiguring your SAN. If a new device or LUN becomes accessible through the adapter, then ESX Server registers this new virtual device for use by virtual machines. If an existing device or LUN is no longer used and appears to be gone, then it is removed from use by virtual machines. Note: Only use this -s option for Fibre Channel adapters. You can see the results of the scan by using ls /vmfs or looking at the contents of /proc/vmware/scsi. -k --createswapfile #[gGmMkK] The size is specified in bytes by default, but you can specify the size in kilobytes, megabytes, or gigabytes by adding a suffix of k (kilobytes), m (megabytes), or g (gigabytes), respectively. Note: You must be logged in to the Service Console with root user permissions to create a swap file. You can resize an existing swap file by specifying the new file size as an argument to the -k option:
If you try to resize an active swap file, ESX Server returns an error message. ESX Server does not automatically activate a swap file after it is created. Use vmkfstools with the -w option to activate a swap file. You can set a swap file to be activated automatically after a system reboot with the Activation Policy option of the Swap Management section in the Options tab of the Management Interface. -w --activateswapfile This command activates the specified swap file. Note: You must be logged in to the Service Console with root user permissions to activate a swap file. -y --deactivateswapfile <fileID> ESX Server assigns a fileID tag to a swap file when it is activated. You must identify a swap file by its fileID tag when specifying which swap file to deactivate with the -y option. Note: You must be logged in to the Service Console with root user permissions to activate a swap file. You can find the fileID tag assigned to a swap file in the swap status file, /proc/vmware/swap/stats. Note: You must shutdown all virtual machines before deactivating a swap file. Entering a vmkfstools -y command returns an error message if any virtual machines are powered on. -T --tovmfs2 This command converts the VMFS volume on the specified partitions from VMFS-1 to VMFS-2, while preserving all files in the volume. ESX Server's locking mechanism attempts to ensure that no remote ESX Server or local process is accessing the VMFS volume that is being converted. Note: If you have an active swap partition, you must deactivate it before running this command. Deactivate swap through the VMware Management Interface and reboot your server. Once this vmkfstools -T command completes, you can reactivate your swap file. This conversion may take several minutes. When your prompt returns, the conversion is complete. Note: In ESX Server 2.1, private VMFS volumes are deprecated. If you have an existing VMFS version 1 (VMFS-1) private volume, then the newly created VMFS-2 volume's access mode is automatically changed to public. Before starting this conversion, check the following:
Caution: The VMFS- 1 to VMFS-2 conversion is a one-way process. Once the VMFS volume is converted to VMFS-2, you cannot revert it back to a VMFS-1 volume. Note: The first time you access a newly converted VMFS-2 volume, the initial access will be slow, because of internal volume consistency checking. This section includes examples using the vmkfstools command with the different options described previously. vmkfstools -C vmfs2 -b 2m -n 32 vmhba1:3:0:1 This example illustrates creating a new VMFS version 2 (vmfs2) on the first partition of target 3, LUN 0 of SCSI adapter 1. The file block size is 2MB and the maximum number of files is 32. vmkfstools -Z vmhba0:1:2:4 vmhba1:3:0:1 This example illustrates extending the new logical file system by adding the 4th partition of target 1 (and LUN 2) of vmhba adapter 0. The extended file system supports a maximum of 64 (2 X 32) files, and spans two partitions vmhba1:3:0:1 and vmhba0:1:2:4. You can address the file system by using the name of its head partition; for example, vmhba1:3:0:1. vmkfstools -S mydisk vmhba1:3:0:1 This example illustrates assigning the name of mydisk to the new file system. vmkfstools -c 2000m mydisk:rh6.2.dsk This example illustrates creating a 2GB VMFS file with the name of rh6.2.dsk on the VMFS volume named mydisk. The rh6.2.dsk file represents an empty disk that may be accessed by a virtual machine. vmkfstools -i ~/vms/nt4.dsk vmhba0:2:0:0:nt4.dsk The example illustrates importing the contents of a virtual disk (that contains Windows NT 4.0) from the service console's file system to a file named nt4.dsk on target 2 of SCSI adapter 0. You can configure a virtual machine to use this virtual disk by adding the following lines to its configuration file:
scsi0.virtualDev = vmxbuslogic Note: The following example, illustrating the -e and -i options, result in the export or import of a virtual disk. This example illustrates migrating a virtual machine's virtual disk file from ESX Server to VMware GSX Server or VMware Workstation, then migrating the virtual disk back to ESX Server. vmkfstools -e winXP.vmdk vmhba0:6:0:1:winXP.dsk The preceding command exports the winXP.dsk virtual disk file to one or more .vmdk files, maximum size 2GB, that you can use as a virtual disk in a virtual machine on GSX Server or Workstation. The resultant winXP.vmdk file(s) can reside on a VMFS volume, or an /ext2, /ext3, or NFS file system. The following example imports a GSX Server or Workstation virtual disk file into the VMFS volume on the specified SCSI device. vmkfstools -i winXP.vmdk vmhba0:6:0:1:winXP.dsk By contrast, if you are importing directly into a raw partition, the example becomes: vmkfstools -i winXP.vmdk vmhba0:6:0:1 vmkfstools -l vmhba0:2:0:0 This command illustrates listing the contents of the file system, including redo logs, virtual disk files, and swap files on target 2 of SCSI adapter 0. This example illustrates scanning the vmhba1 adapter for any new or removed targets or LUNs. vmkfstools -s vmhba1 |