File systems
Related articles
- Partitioning
- Device file#lsblk
- File permissions and attributes
- fsck
- fstab
- List of applications#Mount tools
- QEMU#Mounting a partition from a raw image
- udev
- udisks
- umask From Wikipedia:
- In computing, a file system or filesystem controls how data is stored and retrieved. 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. Taking its name from the way paper-based information systems are named, each group of data is called a "file". The structure and logic rules used to manage the groups of information and their names is called a "file system".
- eCryptfs — The enterprise cryptographic file system is a package of disk encryption software for Linux. It is implemented as a POSIX-compliant file system–level encryption layer, aiming to offer functionality similar to that of GnuPG at the operating system level.
- SquashFS — SquashFS is a compressed read only file system. SquashFS compresses files, inodes and directories, and supports block sizes up to 1 MB for greater compression.
- Glusterfs — Cluster file system capable of scaling to several peta-bytes.
- Tahoe-LAFS — Tahoe Least-Authority File System is a free and open, secure, decentralized, fault-tolerant, peer-to-peer distributed data store and distributed file system.
- VMware VMFS — VMware's VMFS (Virtual Machine File System) is used by the company's flagship server virtualization suite, vSphere.
- using flags on the command line with mount
- editing fstab
- creating udev rules
- compiling the kernel yourself
- or using file system–specific mount scripts (located at ).
Individual drive partitions can be set up using one of the many different available file systems. Each has its own advantages, disadvantages, and unique idiosyncrasies. A brief overview of supported filesystems follows; the links are to Wikipedia pages that provide much more information.
Types of file systems
See for a general overview and Wikipedia:Comparison of file systems for a detailed feature comparison. File systems already loaded by the kernel or built-in are listed in , while all the installed modules can be seen with ls /lib/modules/$(uname -r)/kernel/fs
.
File system | Creation command | Userspace utilities | Archiso | Kernel documentation | Notes |
---|---|---|---|---|---|
Btrfs | mkfs.btrfs(8) | btrfs.html | Stability status | ||
VFAT | vfat.html | Windows 9x file system | |||
exFAT | Native file system in Linux 5.4. | ||||
N/A (FUSE-based) | |||||
F2FS | mkfs.f2fs(8) | f2fs-tools | f2fs.html | Flash-based devices | |
ext3 | ext3.html | ||||
ext4 | ext4.html | ||||
HFS | hfs.html | Classic Mac OS file system | |||
HFS+ | hfsplus.html | macOS (8–10.12) file system | |||
JFS | jfs.html | ||||
NILFS2 | nilfs-utils | nilfs2.html | Raw flash devices, e.g. SD card | ||
NTFS | ntfs3.html | Windows NT file system. New driver, available since Linux 5.15. | |||
ntfs-3g | ntfs.html | Old driver. Has very limited write support. Officially supported kernels are built without so this driver is not available. | |||
N/A (FUSE-based) | FUSE driver with extended capabilities. | ||||
ReiserFS | ReiserFS is deprecated in Linux 5.18 and scheduled for removal from the kernel in 2025. | ||||
UDF | udf.html | ||||
XFS |
xfs.html |
File system | Creation command | Kernel patchset | Userspace utilities | Notes |
---|---|---|---|---|
APFS | linux-apfs-rw-dkms-gitAUR | macOS (10.13 and newer) file system. Read only, experimental. | ||
Bcachefs | bcachefs(8) | |||
Reiser4 | ||||
ZFS | , | OpenZFS port |
Journaling
All the above file systems with the exception of exFAT, ext2, FAT16/32, Reiser4 (optional), Btrfs and ZFS, use journaling. Journaling provides fault-resilience by logging changes before they are committed to the file system. In the event of a system crash or power failure, such file systems are faster to bring back online and less likely to become corrupted. The logging takes place in a dedicated area of the file system.
Not all journaling techniques are the same. Ext3 and ext4 offer data-mode journaling, which logs both data and meta-data, as well as possibility to journal only meta-data changes. Data-mode journaling comes with a speed penalty and is not enabled by default. In the same vein, Reiser4 offers so-called "transaction models" which not only change the features it provides, but in its journaling mode. It uses a different journaling techniques: a special model called wandering logs which eliminates the need to write to the disk twice, write-anywhere—a pure copy-on-write approach (mostly equivalent to btrfs' default but with a fundamentally different "tree" design) and a combined approach called hybrid which heuristically alternates between the two former.
The other file systems provide ordered-mode journaling, which only logs meta-data. While all journaling will return a file system to a valid state after a crash, data-mode journaling offers the greatest protection against corruption and data loss. There is a compromise in system performance, however, because data-mode journaling does two write operations: first to the journal and then to the disk (which Reiser4 avoids with its "wandering logs" feature). The trade-off between system speed and data safety should be considered when choosing the file system type. Reiser4 is the only file system that by design operates on full atomicity and also provides checksums for both meta-data and inline data (operations entirely occur, or they entirely do not and does not corrupt or destroy data due to operations half-occurring) and by design is therefore much less prone to data loss than other file systems like Btrfs.
File systems based on copy-on-write (also known as write-anywhere), such as Reiser4, Btrfs and ZFS, have no need to use traditional journal to protect metadata, because they are never updated in-place. Although Btrfs still has a journal-like log tree, it is only used to speed-up fdatasync/fsync.
FUSE-based file systems
See FUSE.
Stackable file systems
Read-only file systems
Clustered file systems
Shared-disk file system
Identify existing file systems
To identify existing file systems, you can use lsblk:
An existing file system, if present, will be shown in the column. If mounted, it will appear in the column.
Create a file system
File systems are usually created on a partition, inside logical containers such as LVM, RAID and dm-crypt, or on a regular file (see Wikipedia:Loop device). This section describes the partition case.
Before continuing, identify the device where the file system will be created and whether or not it is mounted. For example:
Mounted file systems must be unmounted before proceeding. In the above example an existing file system is on and is mounted at /mnt
. It would be unmounted with:
To find just mounted file systems, see #List mounted file systems.
To create a new file system, use . See #Types of file systems for the exact type, as well as userspace utilities you may wish to install for a particular file system.
For example, to create a new file system of type ext4 (common for Linux data partitions) on , run:
# mkfs.ext4 /dev/sda1The new file system can now be mounted to a directory of choice.
Mount a file system
To manually mount a file system located on a device (e.g., a partition) to a directory, use mount(8). This example mounts to /mnt
.
This attaches the file system on at the directory /mnt
, making the contents of the file system visible. Any data that existed at /mnt
before this action is made invisible until the device is unmounted.
fstab contains information on how devices should be automatically mounted if present. See the fstab article for more information on how to modify this behavior.
If a device is specified in and only the device or mount point is given on the command line, that information will be used in mounting. For example, if contains a line indicating that should be mounted to /mnt
, then the following will automatically mount the device to that location:
Or
# mount /mntmount contains several options, many of which depend on the file system specified. The options can be changed, either by:
See these related articles and the article of the file system of interest for more information.
List mounted file systems
To list all mounted file systems, use :
$ findmntfindmnt takes a variety of arguments which can filter the output and show additional information. For example, it can take a device or mount point as an argument to show only information on what is specified:
$ findmnt /dev/sda1findmnt gathers information from , , and .
Unmount a file system
To unmount a file system use umount(8). Either the device containing the file system (e.g., ) or the mount point (e.g., /mnt
) can be specified:
or
# umount /mntTroubleshooting
"linux Structure needs cleaning"
Unmount the file system and run fsck on the problematic volume.