Section 8.8. vmkfstools and vmware-cmd


8.8. vmkfstools and vmware-cmd

Two powerful tools VMware provides natively for creating and managing both your ESX Server and your virtual machines are the commands:

  • vmkfstools

  • vmware-cmd

The commands and their associated options can be run from the command line, or in scripts that you can start manually or run as cron (backup) jobs.

8.8.1. vmkfstools

Use PuTTY to log in to your ESX Server and type vmkfstools help.

The various options for this command will appear, and there are many (see Figure 8.16).

Figure 8-16. vmkfstools Options


Many of this tool's options can be used in the MUI as well. The first option to discuss here is one the authors have used many timesin fact, more than any othertheX orextendfile option. What this option allows you to do is extend the size of a virtual disk. If you recall, in Chapter 3 we discussed creating gold images or templates of virtual machines. These templates' virtual disks are exactly the same size. When you clone them, however, you may need to adjust the size of the virtual disk. This is where the vmkfstoolsX command comes in handy.

Let's say the template you're cloning has a virtual disk of 5 gigabytes, but the virtual server you need to build requires 10 gigabytes. Of course, you could build a number of clones of various sizes and use the one you need accordingly, or you could use vmkfstools to expand the virtual disk to the size required. The following is an example. First, we'll clone the virtual disk of your template with a simple cp command and rename it appropriately (or you could go into the MUI and select Manage Files and copy the file there). We named our new .vmdk file my_new_sqlserver.vmdk.

Once the copy of your template is complete, type ls lh in the directory of where the template was copied. Note in Figure 8.17 the size of our new .vmdk.

Figure 8-17. The New .vmdk File


Now type the following: Vmkfstools X 10G my_new_sqlserver.vmdk.

What this command does is increase the my_new_sqlserver.vmdk to 10GB. When finished, type ls lh again (see Figure 8.18).

Figure 8-18. Output of ls lh


Now the size of the virtual disk is 10GB. When this virtual machine is started, it will still see only its original size. Use a disk partitioning tool to easily repartition this drive to its full size. And voilà, you're done.

This method could be used for already provisioned virtual machines as well. If you need to increase the size of an existing disk and can't simply add another virtual disk, you can use this method to do so.

The vmkfstools command can be used for creating and managing virtual disks, as well as managing the vmfs file system which contains the virtual disks. There are a number of basic and advanced arguments (options) you can select when running this command, many of which we'll discuss in Chapter 13. A few are described in the next section of this chapter.

8.8.1.1. vmkfstools Basics

The vmkfstools command can be used to create the ESX Server file system vmfs. The following example shows how to accomplish this:

 vmkfstools C myvm_s  -b 2m n 16 vmhba0:1:0:1 

Let's go through the command option by option. The C (capital C; don't forget, Linux is case sensitive) is the create option for generating a vmfs partition. You may also use the longer version of this option, which is createfs. myvm_ s is the name of the vmfs volume and the -b sets the blocksize. n sets the number of .vmdk files that can exist in this vmfs volume. If this argument is excluded, the default is 256.

What you should become intimately familiar with is the nomenclature for identifying SCSI device, Target, LUN, and Partition IDs. In our example, vmhba0:1:0:1 is broken down in the following manner:

The first section, vmhba0, is the first SCSI device recognized by the ESX Server. The second number, 1, is the target number, the third number is the logical unit number (LUN), and the fourth number is the partition number. If this number is set to zero that means the partition is the whole disk, while in our example, 1 indicates the first partition on a disk.

There are many other uses for vmkfstools. See Chapter 13 for more details.

8.8.1.2. vmware-cmd

vmware-cmd is another very powerful command-line tool provided by VMware. With this tool, you can obtain the running state of a virtual machine, apply a redo log to a running virtual machine, start, stop, and suspend a virtual machine, and carry out many other actions.

From the command line of your ESX Server, type vmware-cmd. The results will look like the output in Figure 8.19

Figure 8-19. vmware-cmd help


There are many options, but the basic syntax for a command with arguments to start a virtual machine is as follows:

 vmware-cmd /vmware/dc1/winNetEnterprise.vmx start 

The following command is broken down this way. Input the command, followed by the path of the configuration file for the virtual machine you want to run the command against. Add the argument, which in this example is start. This starts the virtual machine dc1 (see Figure 8.20).

Figure 8-20. Result of vmware-cmd <cfg> start


Note the result: start() = 1. This means that the command completed successfully. If you were to run the command again, you'd receive the error message shown in Figure 8.21

Figure 8-21. Error from vmware-cmd


A well-defined error is given detailing why the command could not be carried out.

A powerful command argument is the ability to add a redo file to a running virtual machine. This command has similar syntax to the previous example except you change the argument to addredo.

So, running this command to the same virtual machine would look like the following:

 vmware-cmd /vmware/dc1/winNetEnterprise.vmx addredo 

This command adds a redo file to your virtual machine, meaning that all changes to the virtual machine will be made in the .redo file. In your VMFS volume, you should now see something similar to the image in Figure 8.22

Figure 8-22. Adding the .REDO file


Notice there's now a dc1.vmdk.REDO. All changes made to this virtual machine are being kept in this REDO file.

If you apply or commit the redo file to the virtual disk, then the changes made will be permanently written to the virtual machine. However, if you discard the changes, the virtual machine will be in the same state it was prior to adding the redo file. To commit the REDO file, type the following command:

 vmware-cmd /vmware/dc1/winNetEnterprise.vmx commit scsi0:0 000 

Note the addition of scsi0:0. This scsi target is based on the scsi disk of the virtual machine itself. More detailed information on the vmwre-cmd command and its associated arguments is included later in this chapter.

For more information on vmware-cmd, see Chapter 13.




Virtualization With VMware ESX Server
Configuring VMware ESX Server 2.5 (Vol 1)
ISBN: 1597490199
EAN: 2147483647
Year: 2005
Pages: 173

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net