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.
UPDATE (10/16/18) - For ESXi 6.5+, please use the following commands and the example below is using the s.v00 file:
Decompress file:
gunzip < s.v00 > s.v00.xz
xz --single-stream --decompress < s.v00.xz > s.v00.vtar
vmtar -v -x s.v00.vtar -o s.v00.tar
tar -xvf s.v00.tar
Compress file:
tar -cvf s.v00-new.tar bin/ etc/ lib/ lib64/ opt/ usr/ var/
vmtar -v -c s.v00.tar -o s.v00.vtar
xz --single-stream --compress < s.v00.vtar > s.v00.xz
xz --single-stream --compress < s.v00.vtar > s.v00
You can find some of these vmtar files with .vgz extension in the ESXi installation iso, here are a few highlighted in red:
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
This comment has been removed by the author.
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
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.