0

I know that to create swap space on file or disk, we have to use command mkswap //filename, and to create filesystem, we have to use mkfs command, but what is the main difference between creating swap space and a filesystem before mounting them?

2 Answers2

1

These are two completely different things but somehow similar to each other, they prepare disk to store data in a different form.


A File System is a way of storing and retrieving data from disk. from Wikipedia:

Without a file system, information placed in a storage medium would be one large body of data with no way to tell where one piece of information stops and the next begins. By separating the data into pieces and giving each piece a name, the information is easily isolated and identified.

To create these file systems we use utilities like mkfs. There are different type of file systems for different purposes:

There are many different kinds of file systems. Each one has different structure and logic, properties of speed, flexibility, security, size and more. Some file systems have been designed to be used for specific applications. For example, the ISO 9660 file system is designed specifically for optical discs.

File systems like ntfs, ext4, fat, etc can be mounted and used for storing/retrieving data.

However we don't mount a swap area, it's the job of your operating system to work with it. It's not created to store data like we store it on disk using file systems.

From my other answer What does the mkswap command do:

mkswap is somehow like other mkfs utilities, it prepares your file or partition to be used as a swapping space in a special form which it can't be thought of any other kind of file systems. it prepares a portion of your disk which might be upon a file system itself (a swap file) to save the memory pages directly into it.

Also interesting to read: Does swap space have a filesystem?

Ravexina
  • 55,668
  • 25
  • 164
  • 183
0

File system is for permanent storage of information. You must create a file system for permanent storage.

Swap is for temporary storage of information. Swap is optional but generally recommended.

Swap is an extension of RAM (Random Access Memory) which is a much faster form of temporary storage. RAM is mandatory for all computers.