A swap partition contains a filesystem. This is the proposition that is widely seen across the Internet. Every disk has partitions, and every partition has a filesystem. The swap is a special type of partition that is left blank on a drive so that the operating system can use that blank space as extended storage for paging when the RAM is about to reach its capacity. A file system is a way of arranging files in a certain way on a storage device such as a hard drive or an SSD. Different filesystems are used as a default on different operating systems. A specific type of file system is used for specific purposes.
What is a Partition?
Before diving into the phrase “a swap partition contains a filesystem,” let us understand what a partition is. Disk Partitioning is the process of dividing the disk into smaller regions so that each region can be managed and used separately. From the operating system’s perspective, each of the partitions appears as a distinct disk called logical disks or drives. A disk partition utility program such as Gparted is used to create the disk partition table. Each partition can be used separately for different purposes such as booting, file storage, swap, etc.
Understanding File System
To decode the phrase “a swap partition contains a filesystem,” we would have to dig a little deeper into what filesystems are. A file system is a scheme or a method of storing the data in the form of files on a storage device in a certain predefined data structure. There are different kinds of file systems depending on the data structure, logical units, use cases, etc. The default file system for Windows is NTFS (New Technology File System), while for Linux, it is ext4. The FAT32 file system is typically used for bootable devices.
What is a swap partition?
A swap partition is just like the other logical disk partitions except for the fact that it is not used for persistent data or file storage. The swap itself is not a file system. It is a kind of flag that indicates the operating system that this logical partition of the disk is to be used in accordance with the system’s low physical RAM. This is done through the process called swapping. Swapping is a kind of memory paging process in which, In the absence of sufficient physical memory, working data is stored in the swap partition, virtually increasing the usable memory.
An Example of swap partition in Linux
In this example, we try to put everything together and understand the filesystem and partitions before heading to our phrase, “A swap partition contains a filesystem”. Below is a snapshot of the fdisk -l command on a Linux machine with a dual boot configuration, which would help understand the concepts of partitions and file systems.
The disk /dev/sda is partitioned into nine parts of different sizes and file systems in the above. The device column contains the name of the partition. The size column contains the size of the partition, the start, end, and sectors column contains the staring offset, ending offset, and the number of data sectors, respectively. The type column in the table shows the filesystem of the partitions. The following points can be noted from this partition table.
- /dev/sda1 is a Windows specific partition for recovery mode.
- /dev/sda2 is the Windows boot manager bootloader.(FAT32)
- /dev/sda3 is Microsoft’s reserved disk space.
- /dev/sda4 to /dev/sda6 is the NTFS file storage partitions mainly used by Windows. (NTFS)
- /dev/sda7 is the 4GB of Linux swap.
- /dev/sda8 is the EFI boot system for linux. (FAT32 file system)
- /dev/sda9 is the ext4 File System for linux root. (ext4)
A swap Partition contains a filesystem Explained
The phrase “A swap partition contains a filesystem” is misleading. The swap partition doesn’t have any specific file system arranged in it. The swap partition is just an empty region that can be used by the operating system along with the system’s physical RAM. Therefore, to say that a swap partition contains a filesystem is technically incorrect. The swap partition only contains its meta-data in a data structure called the swap header. While installing the Linux-based operating system, the partitioned is only flagged as a swap or Linux swap. The operating system can identify it as the swap partition the partition is not reformatted to any particular file system.
What is the difference between a swap file and swap partition?
A swap file is like an ordinary system file of sufficient size that resides within the Linux file system. When swap space is needed, instead of swapping the data to a whole other partition, the data is stored in the file. The main advantage of a swap file is that you can create the swap file yourself and use swapping without having to partition your disk.
The difference between a swap file and a swap partition is that a swap file is a system file, it resides in the root file system and can be created, mounted, or deleted without altering the partition table of a disk it resides in the user environment. While a swap partition needs to be created by making changes in the disk partition table and then formatting the partition. A swap file is a software-based approach to swapping, while a swap partition is hardware-based.
FAQs Related to Swap Partition Sontains a Filesystem
What is the typical size of a swap partition under a Linux system?
The typical suggested size for a swap partition is equal to the size of the RAM.
How to make swap partition permanent?
Open the /etc/fstab with your text editor with higher privileges, and add this /dev/<your_swap_partition> swap swap defaults 0 0. Save and exit the file.
Which command is used to check swap partition or file?
The swapon command is used to check swap space.
“A swap partition contains a filesystem” this phrase should be taken as a question rather than a statement, with the correct answer being “No”. In this article, we broke down the sentence and tried to explain each concept separately. We also provided the example of a dual-boot partitioned table with a Linux swap partition to clarify the concept. It was concluded that the swap partition of a drive does not contain any specific file system. It is a reserved empty space on the disk that is used for memory swapping.