Can I delete the VSWP file in VMware?

The simplest answer is yes, you can delete VSWP files. But you should rather ask if you really want to do it? At this time you probably figured out that VSWP is going to be the main topic of this article. We will start with answering what these files really are and why in most cases, their removal is challenging by the VMware hypervisor? Then we will move forward.

Is a workstation a traditional computer?

Let’s start from a different angle and talk about current solutions dedicated to workstations. Working at a computer at work or even in a home laboratory, we often forget that a monitor, mouse, keyboard, or even a “box” somewhere next to it isn’t the same as using a workstation. Currently, in the IT world dominated by virtualized, cloud, and containerized environments, it must be remembered that we often work on a workspace, which is a generated environment. Often the boxes that stand or are mounted next to the monitors are only thin clients. Such solutions mean that the equipment on our desk is only used to display our remote environment to us. 

Very often technologies such as virtualization, clouding, and containerization are combined and create one extensive infrastructure in a company. Such solutions are not that rare and have already been implemented by many global organizations.

VMware as a hypervisor

From the previous entries in which we have described VMware products in more detail, we know that its application is perfect for implementations that focus on infrastructures based on the virtualization of entire IT environments. It’s worth noting that VMware puts great emphasis on adapting their products to be hybrid. This approach means that in the latest versions of vSphere, we are not only able to virtualize whole virtual machines but also containers. We can also connect the whole thing to the cloud, and in this way, we get a truly hybrid solution. The VMware market, with its comprehensive product vSphere, leads the way and is set by many specialists as a role model. Thanks to vSphere and ESXi, companies can virtualize multiple servers and keep their entire pools of virtual servers on a single, shared, and managed from one physical ESXi server farm. We described the differences between ESXi and WMware vSphere in detail in one of our past articles. Then you already know that this approach to the infrastructure has many advantages. In addition to the above-mentioned possibilities of virtualizing entire servers, containers and connecting these two worlds with resources in the cloud, we also have those less obvious, but for years characterized by VMware’s hypervisor. Technologies such as snapshots, which allows you to create points with the state of a given virtual machine, or the ability to copy, migrate and develop templates for mass production of virtual machines. 

Xopero ONE VMware backup free trial

How a virtual machine is built

Each hypervisor must generate and store virtual machines in some form. VMware also creates its folder when creating a new virtual machine. We will find files such as:

  • xxxx.log – file with logs. There may be several or even a dozen of them
  • xxxx.vmdk – virtual disk file that stores the contents of the virtual machine HDD
  • xxxx.nvram – file with virtual machine BIOS
  • xxxx.vmsd – file with snapshot metadata and information
  • xxxx.vmx – file with virtual machine configuration

Of course, these are not all the files we can find in the virtual machine folder. For example, xxx.vmss files with information about the virtual machine’s state that has been suspended.

So, what are VSWP files?

Sometimes in the virtual machine folder, we can find new files with the .vswp extension. Before we describe what we can do with them, we need to explain what they are. This extension can be expanded as a virtual swap file. You’ve probably encountered SWAP files, i.e., system-created or user-defined files that extend RAM, more than once. We live in exciting times, and currently used disks can be faster than RAM, but let’s leave these considerations for another time. SWAP files are created when the system or user wants to expand the RAM. This means that the system reserves disk space and thus broadens the memory available to it. This is the case, for example, when RAM space is insufficient, and the operating system needs more memory to complete tasks. The same state can be observed when the hypervisor of VMware “deems” that the virtual machine is short of RAM. The SWAP file with the .vswp extension is created in the folder of such a machine. 

Can we delete VSWP files?

The truth is, we shouldn’t be doing this. We have already established that VSWP files are an extension of the RAM for a given machine, so VMware blocks such a file, and in the standard case, we will not be able to do so. Of course, several solutions will allow us to get rid of such files. For example, we could reset the virtual machine in question. This action should cause the VSWP file to be deleted because VMware doesn’t need any more memory at the moment. Of course, this will only occur when this is indeed the case. That’s why before processing with any kind of operations we should first analyze why the RAM defined in the configuration was missing. Then either increase its amount or get rid of the reason why all RAM was used up in the operating system of the virtual machine itself. 

However, there may be times when the VSWP file is not deleted after increasing the RAM and restarting the virtual machine. In this case, you may need to restart the entire hosting server. However, there is also a method definitely not advised by the author to remove the lock from such a file. Each such locked file on the ESXi server is marked with the name lck-xxxx, and from the console level (for example, by logging in via SSH), we can delete such a file. I also recommend checking the integrity of the virtual machine after doing so. 

Deleting VSWP or not… – a very short summary

During the lecture of this post, we learned that VSWPs are extended RAM files of a given virtual machine. They are created automatically according to the needs of the VMware hypervisor. And by default, they are blocked. Always keep in mind that deleting such files manually without shutting down the virtual machine first may simply damage it. And that’s why you really shouldn’t be removing them on your own.