Do you want to know what Linux file system? If you are a beginner of Linux system, especially if you used to be a Windows user, Linux file system may be confusing to you. In this post, MiniTool Partition Wizard will explain what Linux file system is clearly to you.
What Is a File System?
According to Wikipedia, a file system is used to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one large body of data with no way to tell where one piece of data stops and the next begins.
File system can separate the data into pieces and give each piece a name. In this way, the data is easily isolated and identified. Each group of data is called a “file”, while the structure and logic rules used to manage the groups of data and their names are called “file system.”
To put it clearly: A file system is a data management scheme design.
The data management scheme is shown as follows:
According the above scheme, the logical structure form of data management is “file + directory + directory tree”, which is also the data management structure form that most current file systems use (In Windows, directory is called folder).
Information related to the data management logical structure + data = file system’s logical part. Different data management logical structure schemes result in different file systems.
A file system consists of the following three parts: file system API, logical part (data + information about data management structure), and the physical storage of data.
File system’s logical part has been explained in the above part. Now, let’s talk about the physical storage of data. When you store data on storage devices, there is no file, directory/folder, or directory tree. There are only strings of specific binary digits. The problem is how to save the information about those data logical structure forms to external storage.
To explain this problem, I must mention partitions, which are used to manage the storage space of storage device better. When you create partitions on a storage device, the information about these partitions is stored in Partition Table that is located on the first sector of disk (MBR sector). Then, you need to add file systems to these partitions by formatting.
In a file system partition, part of the storage space is used to store the logical structure information of the file system. This part is called different names in different file systems, for example, it is called FAT table in FAT file system, called MFT table in NTFS file system, etc. Then, the remaining space is used to store data in the form of files and directories.
Then, the layout of a disk with partitions will be as shown in the following picture:
As for the last part: file system API, it is an application programming interface through which a utility or user program requests services of a file system. Some file system APIs may also include interfaces for maintenance operations, such as creating or initializing a file system, verifying the file system for integrity, and defragmentation.
About Linux Directory Structure
Linux uses directory tree to manage directories and files. The directory tree information should be also stored on storage device and this part is called root file system (the “/” directory). Therefore, the storage device layout becomes as shown in the following picture:
As we all know, root file system is one directory of Linux system. You may wonder what the relationship between Linux directory structure and file system (partition) is. To figure out this problem, you should understand Linux directory structure first.
In Linux system, the root directory (/) is the most important directory, because:
- All other directories are derived from the root directory;
- The root directory is closely related to the boot, repair and restore of the Linux system.
The root directory contains the following subdirectories (first-level directories):
- /bin: It contains common system commands that can be executed by any users.
- /boot: It saves files related to system startup, such as kernel files and bootloader (grub) files, etc.
- /dev: It contains the device files for every hardware device attached to the system. These are not device drivers, rather they are files that represent each device on the computer and facilitate access to those devices.
- /etc: It contains the local system configuration files for the host computer, such as user information, service startup scripts, configuration files for common services, etc. It’s similar to Windows Registry.
- /home: It’s the default location to log in and save user data. Each user has a subdirectory in /home.
- /lib: It contains shared library files that are required to boot the system.
- /media: It’s the place used to mount external removable media devices such as floppy disks, CDs, and USB thumb drives that may be connected to the host.
- /mnt: It’s the traditional mountpoint for regular hard drive partitions (file systems). But most people like to mount hard drives under /home
- /misc: It’s the place used to mount the shared directory of the NFS service.
- /opt: It’s the place used to place and install other software.
- /usr: Its full name is Unix Software Resource. It is the default installation location of the software and similar to the complex of “C:Windows + C:Program files” in the Windows system.
- /root: It is the home directory for the root user. It’s the default location to log in and save root user data.
- /sbin: It saves commands related to system environment settings. Only root can use these commands, but there are also commands that allow ordinary users to view.
- /srv: It contains data for services. After some system services are started, they can call out or save necessary data in this directory.
- /tmp: It is a place where the system stores temporary files, under which all users can access and write.
- /lost+found: When the system crashes unexpectedly or shuts down unexpectedly, some file fragments will be stored here. During system startup, the fsck tool will check this directory and repair the damaged file system. Please note this directory only appears in each partition (file system).
- /proc: The data in this directory is not saved on the hard disk, but in the memory. It mainly saves the system’s kernel, process, external device status and network status, etc.
- /sys: It’s similar to the /proc directory and the data in this directory is stored in memory, but it mainly stores information related to the kernel.
- /var: It is used to store dynamic data, such as caches, log files, and files generated during software operation.
The above directories also contain subdirectories (secondary directories). When you install Linux system, you should partition the disk and then mount partitions under these directories. When you partition disk for Linux, many people may advise you to create 4 partitions: “/” partition for root directory, “/boot” partition, “/home” partition, and “swap” partition for virtual memory.
As for other directories under which no partition is mounted, they and their data are stored in the root partition (file system) along with the root directory.
There is a picture showing the layout of Linux directories and partitions:
The relationship between Linux directory structure and partition is as follows:
- The directory is the logical location of data, while the partition is the physical location of data.
- A partition must be mounted in a directory before it can be used.
- In general, it’s recommended to mount one partition under one directory. But Linux allows you to mount the same partition under several directories, and allows you to mount several partitions under the same directory through aufs (some Linux systems do not support this feature).
- If mount two partitions under the same directory without aufs, the last partition will cover the previous partition. But don’t worry! The data in the previous partition will not be lost.
- When you unmount a partition, the data in the partition won’t be lost.
Common Linux File Systems
Linux supports reading around 100 partition types, but it can create and write to only a few of these. The commonly used Linux file systems are as follows: ext2, ext3, ext4, JFS, ReiserFS, XFS, and Btrfs. In this part, I will introduce them briefly to you.
Ext2, Ext3, and Ext4
The ext (extended file system) is the first file system created specifically for the Linux kernel. It was implemented in April 1992 and aimed to overcome certain limitations of the MINIX file system.
- Pro: It used the new virtual file system (VFS) abstraction layer and could address up to 2GB of storage.
- Con: It uses primitive timestamping (only one timestamp per file, rather than the three separate stamps for inode creation, file access, and file modification we’re familiar with today). Due this point, it was replaced by ext2 soon.
Ext2 was the first commercial-grade file system for Linux and it was designed according to the same principles as the Berkeley Fast File System from BSD.
- Pro: It is prominent in speed and CPU utilization, and has excellent file access performance, especially for medium and small files. Therefore, it was quickly and widely adopted, both in the Linux kernel and eventually in MINIX, as well as by third-party modules making it available for MacOS and Windows.
- Con: It was prone to catastrophic corruption if the system crashed or lost power while data was being written to disk. It also suffered from significant performance losses due to fragmentation as time went on.
Ext3 project started since 1998 and it was adopted in November 2001. Like ext2, ext3 uses 16-bit internal addressing. This means that with a block size of 4K, the largest file size it can handle is 2 TB in a maximum file system size of 16 TB.
- Pro: It uses journaling to improve reliability and eliminates the need to check the file system after an unclean shutdown. If the system crashes suddenly, the newly rebooted system will recognize the operation that you performed just now as an incomplete transaction and roll it back as though it had never taken place.
- Con: It does not have the high performance that can improve file data processing speed and decompression and it has the limitation of the largest file system and the largest file.
Ext4 started since 2006 and was released officially in 2008. It was based on ext3 and aimed to extend storage limits of ext3. Ext4 can support storing a file up to 16TB and creating a partition up to 1EB.
[SOLVED] Failed to Format Ext4 Windows? – Solutions Are Here!
JFS
JFS (Journaled File System) is a 64-bit journaling file system developed by IBM for AIX UNIX. This file system is mainly designed and developed to meet the high throughput and reliability requirements of servers (from single-processor systems to advanced multi-processor and cluster systems).
In February 2000, IBM announced that it would port the Linux version of the JFS file system under an open source license. Therefore, a large number of users have installed and used this enterprise-level file system.
- Pro: It has fast restart capability. JFS can restore the file system to a consistent state within seconds or minutes.
- Con: It will cause a certain loss in the performance and the high ratio of system resource occupation, because when it saves a log, the system needs to write a lot of data.
ReiserFS
ReiserFS, occasionally referred to as Reiser3, is a general-purpose, journaled computer file system initially designed and implemented by a team at Namesys led by Hans Reiser. It was introduced as an alternative to ext3 with improved performance and advanced features.
There was a time when SuSE Linux‘s default file format was ReiserFS but later Reiser was convicted for murder and Namesys went out of business in 2008. SuSe had no option other than to return back to ext3. ReiserFS is now maintained as open source by volunteers.
- Pro: It introduced a new on-disk format allowing bigger file sizes and improving storage efficiency, speed, and functionality. Its successor is Reiser4.
- Con: It requires the disk to be formatted every time a version is upgraded, and its security performance and stability have a certain gap compared with ext3. It cannot handle extremely long file directories correctly, if you create a file directory with more than 768 characters and use ls or other echo commands, it may cause the system to hang.
XFS
XFS is a high-performance 64-bit journaling file system created by Silicon Graphics, Inc (SGI) in 1993. Since 2001, it has been built into the Linux kernel.
- Pro: It can meet most storage capacity and I/O storage requirements. In addition, it has high degrees of concurrency (i.e., a really large number of processes all writing to the file system at once).
- Con: It is slightly complicated and difficult to implement, so XFS is currently mainly used in high-end Linux enterprise applications.
Btrfs
Btrfs (B-tree file system) is a file system based on the copy-on-write (COW) principle and its development began in 2007. Since November 2013 the file system’s on-disk format has been declared stable in the Linux kernel.
- Pro: It is intended to address the lack of pooling, snapshots, checksums, and integral multi-device spanning in Linux file systems. It aims to offer multiple device management, per-block check summing, asynchronous replication, inline compression, and more.
- Con: It’s not a reliable volume manager. It suffers from significant performance problems and its next-generation features—replication, multiple-disk topologies, and snapshot management—can be pretty buggy, which may cause data loss.
How to Create an Ext2/3/4 Partition in Windows System
If you plan to dual boot Windows and Linux or create a Linux USB with persistent storage, creating ext2/3/4 partition in Windows system may help you save a lot of efforts. To create an ext2/3/4 partition in Windows system, I recommend you to use MiniTool Partition Free Edition.
MiniTool Partition Wizard FreeClick to Download100%Clean & Safe
Step 1: Click the above button to download MiniTool Partition Wizard. Launch this software and go to its main interface. Right-click unallocated space and choose Create. If there is no unallocated space, you can use Move/Resize feature to make one.
Step 2: In the popup window, expand the drop-down menu next to File System to choose ext2, ext3, or ext4, and then adjust the size and location of the new partition. As for other parameters, you can keep the default settings. Then, click OK to continue.
Step 3: Preview the changes and click Apply to confirm the changes.
After creating ext2/3/4 partition, you can start to install Linux system. As for the detailed steps about how to dual boot Windows and Linux and how to create a potable Linux with persistent storage, please refer to the following post:
Bottom Line
After reading this post, have you gaind something new about Linux file system? Anyway, please leave a comment below. In addition, if you encounter problem when creating ext2/3/4 partitions, please contact us via [email protected]. We will get back to you as soon as possible.