Swapping is the process of storing the page of memory in the already configured hard disk space that is defined as the swap space. Virtual memory is the combination of both the random access memory as well as the swap space.
Swapping is mainly used for the purpose of memory utilization of the RAM for the current process instead of sticking with the allocated memory in RAM. Importantly, while the initialization process, many files were used for the kernel boot after that this will not use any more. swaps, part comes into the picture, never used again files will be moved into the swap space to free up the memory in the RAM.
The drawback of the swap space is to access the swap memory is very slow when compared to the RAM memory. Tens of thousand times slower for the swap memory access than RAM.
The speed of the RAM is in nanoseconds, but for the swap memory speed is in milliseconds. If we more depend on swap space which means slower our system.
In a Linux system, two ways of swap space are there i.e., the swap partition and swap file. The swap partition is the dedicated memory space on the hard disk and this space only for the less used page memory from RAM not for the data files.
But the swap file is not the dedicated space that means which space will be used for both the data files as well as the less used memory files from the RAM.