There were several questions today on the VMTN community forums with regards to manipulating .vgz files in ESXi, also known as vmtar files. Due to the sparse amount of information on the web, I wanted to document some of the common operations that can be performed on the vmtar files. I will not be going over the use cases for manipulating or creating custom vmtar files, but here is one use case.

You can find some of these vmtar files with .vgz extension in the ESXi installation iso, here are a few highlighted in red:

Note: With ESXi 5, vmtar files are no longer being used, as far as I can tell, this is is only applicable to ESXi 3.x and 4.x

To operate on existing vmtar files, you will need access to an ESXi host via ESXi Shell and using the /sbin/vmtar utility.

Usage: vmtar {[-x vtar/vgz-file] [-c tar/tgz-file] [-v] -o destination} | -t < vtar/vgz-file

In this example, we will copy the install.vgz to an ESXi host to perform some operations.

To list the contents of a vmtar file, you will need to use the -t option:

To extract the contents of vmtar file, you will need to use the -x and -o option:

vmtar -x install.vgz -o install.tar

Note: The output will be a standard tar file which will then need to be extracted before getting to the actual contents

To extract the tar file, we will be using the tar utility:

Let's say we made a change to one of the files and now we would like to re-create the vmtar file, we will first need to tar up the contents by using the tar utility again:

To verify the contents were all tarred up, we can view the contents by using the following command:

tar -tf install.tar

Now we will create the vmtar file using the vmtar utility:

vmtar -c install.tar -o install.vgz

We can confirm the contents by using vmtar -t option once again:

vmtar -t < install.vgz

If you decide to create your own custom vmtar files and want to verify the file layout, you can use vmkramdisk to assist you. Using vdf command, make note of the number of tardisks that have been mounted up.

Also make note of the filesystem layout by performing an "ls" on / (slash):

Now let's say you wanted to create a directory called virtuallyGhetto with a file in that directory called foobar and you wanted it to be mounted up under /

Here are the steps to perform the above:

Do you notice anything different? How about performing an "ls" on / (slash) again?

To umount the vmtar disk, you would use the following command:

vmkramdisk -u virtuallyGhetto.vgz

4 thoughts on “How to Create and Modify vgz (vmtar) Files on ESXi 3.x/4.x

  1. you have to use gzip after vmtar to actually get a vgz file, otherwise you get only a vtar and it is not compressed.
    gzip < file.vtar > file.vgz

  2. Hello.
    That was very informative. Thanks. I wanted to know how you can create a ramdisk on the host (VMWare ESX) from CLI. I dont think mkfs exists on VMWare ESX. I came across vmkramdisk command but I am not sure whether it makes a ramdisk on VMWare ESX. Could you please answer these questions for me:
    1. what does vmkramdisk do exactly.
    2. How to create ramdisk on VMWare ESX from CLI.

    Thanks again.

Thanks for the comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.