Does swap space have a filesystem?

Swap technically doesn't have specific filesystem. The whole purpose of filesystem is to structure data in certain way. Swap partition in particular doesn't have structure, but it does have a specific header, which is created by mkswap program. In particular , this (taken from kernel.org):

 25 union swap_header {
 26     struct 
 27     {
 28         char reserved[PAGE_SIZE - 10];
 29         char magic[10];
 30     } magic;
 31     struct 
 32     {
 33         char     bootbits[1024];
 34         unsigned int version;
 35         unsigned int last_page;
 36         unsigned int nr_badpages;
 37         unsigned int padding[125];
 38         unsigned int badpages[1];
 39     } info;
 40 };

Each partition has specific code associated with it, and according to TLDP:

code for ext2 is 0x83 and linux swap is 0x82

When swap file is involved, that's a slightly different story. The kernel must respect the fact that the filesystem may have their own way of structuring data. From the same kernel.org link:

Remember that filesystems may have their own method of storing files and disk and it is not as simple as the swap partition where information may be written directly to disk. If the backing storage is a partition, then only one page-sized block requires IO and as there is no filesystem involved, bmap() is unnecessary.

In conclusion, technically you could call swap space a filesystem of its own type, but it's not quite comparable with filesystems like NTFS or ext4

You've also asked

I want to know how it is possible to write in a storage space without file system

Strictly speaking, there's no need for RAM to be structured. However, portions of RAM can be structured as tmpfs under Unix-like OSes. There's also ramfs, and initramfs , which is what gets loaded during boot process. But the RAM data technically is supposed to be just raw 1s and 0s, so there's no need to structure them in anyway.


Swap space is used by the kernel to temporarily store pages of system memory (RAM) as it becomes full. The kernel uses it's own internal tables to "remember" exactly where within the swap disk it put the page. As a result, swap disks do not contain a proper filesystem and are usually just blank partitions on the disk.

What you may be interested in, is a RAM-disk, which is a small filesystem stored in the system's memory. If more memory is needed, the kernel will push it (and other contents) out to the swap space. See here for instructions on setting one up.


Swap space is divided into blocks the same size as memory pages (usually 4kB), and a record of the mapping of these pages to application memory forms an extension of the virtual memory subsystem in the CPU and OS.

That is, there is already a mapping system between application memory spaces and the actual physical memory address. An application is given a large memory address space which they can use as much or as little of as they can. As more of this memory address space is actually used, physical memory is mapped to that application to serve as the storage medium.

When memory is swapped to disk, a related system maintains that mapping of an application's memory space to the block on disk.

The mapping table itself is not stored on disk, and the data remaining on the disk is useless after a reboot.