Difference between revisions of "File systems"

From ArchWiki
Jump to: navigation, search
m (Title hierarchy fixed)
m (Create a file system: wiki link style)
 
(127 intermediate revisions by 27 users not shown)
Line 1: Line 1:
 
[[Category:File systems]]
 
[[Category:File systems]]
[[es:File Systems]]
+
[[es:File systems]]
[[It:File Systems]]
+
[[hu:File systems]]
[[ja:File Systems]]
+
[[it:File systems]]
[[pl:File Systems]]
+
[[ja:ファイルシステム]]
[[zh-cn:File Systems]]
+
[[pl:File systems]]
{{Article summary start}}
+
[[zh-cn:File systems]]
{{Article summary text|An overview of the types of file systems available.}}
+
{{Related articles start}}
{{Article summary heading|Related}}
+
{{Related|Core utilities#lsblk}}
{{Article summary wiki|Partitioning}}
+
{{Related|fstab}}
{{Article summary end}}
+
{{Related|Mount}}
 +
{{Related|Partitioning}}
 +
{{Related|tmpfs}}
 +
{{Related|NFS}}
 +
{{Related|NTFS-3G}}
 +
{{Related|Samba}}
 +
{{Related|List of applications/Internet#Distributed file systems}}
 +
{{Related articles end}}
 +
 
 
From [[Wikipedia:File system|Wikipedia]]:
 
From [[Wikipedia:File system|Wikipedia]]:
:''A file system (or filesystem) is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device(s) which contain it. A file system organizes data in an efficient manner and is tuned to the specific characteristics of the device.''
+
:In computing, a file system (or filesystem) is used to control 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".
  
Individual drive partitions can be setup using one of the many different available filesystems. 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.
+
Individual drive partitions can be setup using one of the many different available filesystems. 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.
  
Before being formatted, a drive should be [[Partitioning|partitioned]].
+
== Create a file system ==
  
== Type of File Systems ==
+
File systems are usually created on a [[partition]], inside logical containers such as [[LVM]], [[RAID]] and [[dm-crypt]], or on a regular file (see [[w:Loop device]]). This section describe the partition case.
  
* [[Wikipedia:Btrfs|Btrfs]] - Also known as "Better FS", is a '''new filesystem with powerful features similar to Sun/Oracle's excellent ZFS'''. These include snapshots, multi-disk striping and mirroring (software RAID without mdadm), checksums, incremental backup, and on-the-fly compression that can give a significant performance boost as well as save space. As of January 2011, Btrfs is considered unstable although it has been merged into the mainline kernel with an experimental status. Btrfs appears to be the future of GNU/Linux filesystems and is offered as a root filesystem option in all major distribution installers.
+
{{Note|1=File systems can be written directly to a disk, known as a [https://msdn.microsoft.com/en-us/library/windows/hardware/dn640535(v=vs.85).aspx#gpt_faq_superfloppy superfloppy] or ''partitionless disk''. Certain limitations are involved with this method, particularly if [[Arch boot process|booting]] from such a drive. See [[Btrfs#Partitionless Btrfs disk]] for an example.}}
* [[Wikipedia:exFAT|exFAT]] - '''Microsoft file system optimized for flash drives'''. Unlike NTFS, exFAT cannot pre-allocate disk space for a file by just marking arbitrary space on disk as 'allocated'. As in FAT, when creating a file of known length, exFAT must perform a complete physical write equal to the size of the file.
+
* [[Wikipedia:ext2|ext2]] - '''Second Extended Filesystem''' is an established, mature GNU/Linux filesystem that is very stable. A drawback is that it does not have journaling support or barriers. Lack of journaling can result in data loss in the event of a power failure or system crash. It may also be '''not''' convenient for root ({{ic|/}}) and {{ic|/home}} partitions because file-system checks can take a long time. An ext2 filesystem can be [[Convert_ext2_to_ext3|converted to ext3]].
+
* [[Wikipedia:ext3|ext3]] - '''Third Extended Filesystem''' is essentially the ext2 system with journaling support and write barriers. It is backward compatible with ext2, well tested, and extremely stable.
+
* [[Wikipedia:ext4|ext4]] - '''Fourth Extended Filesystem''' is a newer filesystem that is also compatible with ext2 and ext3. It provides support for volumes with sizes up to 1 exabyte (i.e. 1,048,576 terabytes) and files sizes up to 16 terabytes. It increases the 32,000 subdirectory limit in ext3 to 64,000. It also offers online defragmentation capability.
+
* [[Wikipedia:F2FS|F2FS]] - '''Flash-Friendly File System''' is a flash file system created by Kim Jaegeuk (Hangul: 김재극) at Samsung for the Linux operating system kernel. The motivation for F2FS was to build a file system that from the start takes into account the characteristics of NAND flash memory-based storage devices (such as solid-state disks, eMMC, and SD cards), which have been widely being used in computer systems ranging from mobile devices to servers.
+
* [[Wikipedia:JFS (file system)|JFS]] - IBM's '''Journaled File System''' was the first filesystem to offer journaling. It had many years of development in the IBM AIX® operating system before being ported to GNU/Linux. JFS makes the smallest demand on CPU resources of any GNU/Linux filesystem. It is very fast at formatting, mounting, and filesystem checks (fsck). JFS offers very good all-around performance especially in conjunction with the deadline I/O scheduler. It is not as widely supported as the ext series or ReiserFS, but still very mature and stable.
+
* [[Wikipedia:NILFS|NILFS2]] - '''New Implementation of a Log-structured File System''' was developed by NTT. It records all data in a continuous log-like format that is only appended to and never overwritten. It is designed to reduce seek times and minimize the type of data loss that occurs after a crash with conventional Linux filesystems.
+
* [[Wikipedia:NTFS|NTFS]] - '''File system used by Windows'''. NTFS has several technical improvements over FAT and HPFS (High Performance File System), such as improved support for metadata, and the use of advanced data structures to improve performance, reliability, and disk space utilization, plus additional extensions, such as security access control lists (ACL) and file system journaling.
+
* [[Wikipedia:Reiser4|Reiser4]] - '''Successor to the ReiserFS file system''', developed from scratch by Namesys and sponsored by DARPA as well as Linspire, it uses B*-trees in conjunction with the dancing tree balancing approach, in which underpopulated nodes will not be merged until a flush to disk except under memory pressure or when a transaction completes. Such a system also allows Reiser4 to create files and directories without having to waste time and space through fixed blocks.
+
* [[Wikipedia:ReiserFS|ReiserFS]] - '''Hans Reiser's high-performance journaling FS (v3)''' uses a very interesting method of data throughput based on an unconventional and creative algorithm. ReiserFS is touted as very fast, especially when dealing with many small files. ReiserFS is fast at formatting, yet comparatively slow at mounting. Quite mature and stable. ReiserFSv3 is not being actively developed at this time. Generally regarded as a good choice for {{ic|/var}}.
+
* [[Wikipedia:Paging|Swap]] - Filesystem used for swap partitions.
+
* [[Wikipedia:File Allocation Table#VFAT|VFAT]] - '''Virtual File Allocation Table''' is technically simple and supported by virtually all existing operating systems. This makes it a useful format for solid-state memory cards and a convenient way to share data between operating systems. VFAT supports long file names.
+
* [[Wikipedia:XFS|XFS]] - '''Early journaling filesystem originally developed by Silicon Graphics''' for the IRIX operating system and ported to GNU/Linux. It provides very fast throughput on large files and filesystems and is very fast at formatting and mounting. Comparative benchmark testing has shown it to be slower when dealing with many small files. XFS is very mature and offers online defragmentation capability.
+
* [[Wikipedia:ZFS|ZFS]] - '''Combined file system and logical volume manager designed by Sun Microsystems'''. The features of ZFS include protection against data corruption, support for high storage capacities, integration of the concepts of filesystem and volume management, snapshots and copy-on-write clones, continuous integrity checking and automatic repair, RAID-Z and native NFSv4 ACLs.
+
  
=== Journaling ===
+
{{Warning|After creating a new filesystem, data previously stored on this partition can unlikely be recovered. '''Create a backup of any data you want to keep'''.}}
  
All the above filesystems with the exception of ext2, FAT16/32,  use [[Wikipedia:Journaling_file_system|journaling]]. Journaling provides fault-resilience by logging changes before they are committed to the filesystem. 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 filesystem.
+
Identify the partition where the file system will be created, for example with [[lsblk]]:
  
Not all journaling techniques are the same. Only ext3 and ext4 offer data-mode journaling, which logs both data and meta-data. Data-mode journaling comes with a speed penalty and is not enabled by default. The other filesystems provide ordered-mode journaling, which only logs meta-data. While all journaling will return a filesystem 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. The trade-off between system speed and data safety should be considered when choosing the filesystem type.
+
{{hc|1=$ lsblk -f|2=
 +
NAME  FSTYPE LABEL    UUID                                MOUNTPOINT
 +
sdb                                                         
 +
└─sdb1 vfat  Transcend 4A3C-A9E9                           
 +
}}
  
=== Arch Linux support ===
+
An existing file system, if present, will be shown in the {{ic|FSTYPE}} column. If [[mount]]ed, it will appear in the {{ic|MOUNTPOINT}} column or in the output of {{man|8|findmnt}}. For example:
  
* {{App|btrfs-progs|[[Btrfs]] support.|http://btrfs.wiki.kernel.org/|{{Pkg|btrfs-progs}}}}
+
$ findmnt ''/dev/sdb1''
* {{App|dosfstools|VFAT support.|http://www.daniel-baumann.ch/software/dosfstools/|{{Pkg|dosfstools}}}}
+
* {{App|exfat-utils|exFAT support.|http://code.google.com/e/exfat/|{{Pkg|exfat-utils}}}}
+
* {{App|fuse-exfat|exFAT mount support.|http://code.google.com/p/exfat/|{{Pkg|fuse-exfat}}}}
+
* {{App|e2fsprogs|ext2, [[ext3]], [[ext4]] support.|http://e2fsprogs.sourceforge.net|{{Pkg|e2fsprogs}}}}
+
* {{App|jfsutils|[[JFS]] support.|http://jfs.sourceforge.net|{{Pkg|jfsutils}}}}
+
* {{App|nilfs-utils|NILFS support.|http://www.nilfs.org/|{{Pkg|nilfs-utils}}}}
+
* {{App|ntfs-3g|[[NTFS]] support.|http://www.tuxera.com/community/ntfs-3g-download/|{{Pkg|ntfs-3g}}}}
+
* {{App|reiser4progs|[[Reiser4|ReiserFSv4]] support.|http://sourceforge.net/projects/reiser4/|{{AUR|reiser4progs}}}}
+
* {{App|reiserfsprogs|ReiserFSv3 support.|https://www.kernel.org/|{{Pkg|reiserfsprogs}}}}
+
* {{App|util-linux|[[Swap]] support.|http://www.kernel.org/pub/linux/utils/util-linux/|{{Pkg|util-linux}}}}
+
* {{App|xfsprogs|[[XFS]] support.|http://oss.sgi.com/projects/xfs/|{{Pkg|xfsprogs}}}}
+
* {{App|zfs|[[ZFS]] support.|http://zfsonlinux.org/|{{AUR|zfs}}}}
+
* {{App|zfs-fuse|[[ZFS_on_FUSE|ZFS]] support via FUSE.|http://zfs-fuse.net/|{{AUR|zfs-fuse}}}}
+
{{Note|The ZFS filesystem cannot be shrunk by disk utilities such as gparted.}}
+
  
== Format a device ==
+
Mounted file systems '''must''' be unmounted with {{man|8|umount}} before proceeding:
  
{{Warning|formatting a device removes everything on it, make sure to backup everything you want to keep.}}
+
# umount ''/mountpoint''
  
=== Requirements ===
+
To create a new file system, use {{man|8|mkfs}}. See [[#Types of file systems]] for the exact type, as well as userspace utilities you may wish to install for a particular file system.
  
Before starting, you need to know which name Linux gave to your device. Hard drives and USB sticks show up as {{ic|/dev/sd''x''}}, where "x" is a lowercase letter, while partitions show up as {{ic|/dev/sd''xY''}}, where "Y" is a number.
+
{{Warning|The purpose of a given partition may restrict the choice of file system. For example, an [[EFI System Partition]] must contain a FAT32 ({{ic|mkfs.vfat}}) file system, and the file system containing the {{ic|/boot}} directory must be supported by the [[:Category:Boot loaders|boot loader]].}}
  
If the device you want to format is mounted, it will show up in the ''MOUNTPOINT'' column from:
+
For example, to create a new file system of type [[ext4]] (common for Linux data partitions), run:
  
  $ lsblk
+
  # mkfs.''ext4'' /dev/''sdb1''
  
If your device is not mounted:
+
{{Tip|
 +
* Use the {{ic|-L}} flag of ''mkfs.ext4'' to specify a [[Persistent_block_device_naming#by-label|file system label]]. ''e4label'' can be used to change the label on an existing file system.
 +
* File systems may be ''resized'' after creation, with certain limitations. For example, an [[XFS]] volume can be increased, but not reduced in size. See [[w:Comparison_of_file_systems#Features|Resize capabilities]] and the respective file system documentation for details.}}
  
# mount /dev/sd''xY'' /some/directory
+
The new file system can now be mounted to a directory of choice.
  
And to unmount it, you can use ''umount'' on the directory you mounted the disk on:
+
== Types of file systems ==
  
# umount /some/directory
+
See {{man|5|filesystems}} for a general overview, and [[w:Comparison_of_file_systems]] for a detailed feature comparison.
 +
 
 +
{| class="wikitable sortable"
 +
! File system
 +
! Creation command
 +
! Userspace utilities
 +
! [[Archiso]] [https://git.archlinux.org/archiso.git/tree/configs/releng/packages.both]
 +
! Kernel documentation [https://www.kernel.org/doc/Documentation/filesystems/]
 +
! Notes
 +
|-
 +
| [[Btrfs]]
 +
| {{man|8|mkfs.btrfs}}
 +
| {{Pkg|btrfs-progs}}
 +
| {{Yes}}
 +
| [https://www.kernel.org/doc/Documentation/filesystems/btrfs.txt btrfs.txt]
 +
| [https://btrfs.wiki.kernel.org/index.php/Status Stability status]
 +
|-
 +
| [[w::File Allocation Table#VFAT|VFAT]]
 +
| {{man|8|mkfs.vfat|url=}}
 +
| {{Pkg|dosfstools}}
 +
| {{Yes}}
 +
| [https://www.kernel.org/doc/Documentation/filesystems/vfat.txt vfat.txt]
 +
|
 +
|-
 +
| [[w:exFAT|exFAT]]
 +
| {{man|8|mkfs.exfat|url=}}
 +
| {{Pkg|exfat-utils}}
 +
| {{Y|Optional}}
 +
| N/A (FUSE-based)
 +
|
 +
|-
 +
| [[F2FS]]
 +
| {{man|8|mkefs.f2fs|url=}}
 +
| {{Pkg|f2fs-tools}}
 +
| {{Yes}}
 +
| [https://www.kernel.org/doc/Documentation/filesystems/f2fs.txt f2fs.txt]
 +
 
 +
| Flash-based devices
 +
|-
 +
| [[ext3]]
 +
| {{man|8|mke2fs}}
 +
| {{Pkg|e2fsprogs}}
 +
| {{Yes}} ({{Grp|base}})
 +
| [https://www.kernel.org/doc/Documentation/filesystems/ext3.txt ext3.txt]
 +
|
 +
|-
 +
| [[ext4]]
 +
| {{man|8|mke2fs}}
 +
| {{Pkg|e2fsprogs}}
 +
| {{Yes}} ({{Grp|base}})
 +
| [https://www.kernel.org/doc/Documentation/filesystems/ext4.txt ext4.txt]
 +
|
 +
|-
 +
| [[w:Hierarchical_File_System|HFS]]
 +
| {{man|8|mkfs.hfsplus|url=}}
 +
| {{Pkg|hfsprogs}}
 +
| {{Y|Optional}}
 +
| [https://www.kernel.org/doc/Documentation/filesystems/hfs.txt hfs.txt]
 +
| [[w:macOS|macOS]] file system
 +
|-
 +
| [[JFS]]
 +
| {{man|8|mkfs.jfs|url=}}
 +
| {{Pkg|jfsutils}}
 +
| {{Yes}} ({{Grp|base}})
 +
| [https://www.kernel.org/doc/Documentation/filesystems/jfs.txt jfs.txt]
 +
|
 +
|-
 +
| [[Wikipedia:NILFS|NILFS2]]
 +
| {{man|8|mkfs.nilfs2|url=}}
 +
| {{Pkg|nilfs-utils}}
 +
| {{Yes}}
 +
| [https://www.kernel.org/doc/Documentation/filesystems/nilfs2.txt nilfs2.txt]
 +
|
 +
|-
 +
| [[NTFS]]
 +
| {{man|8|mkfs.ntfs|url=}}
 +
| {{Pkg|ntfs-3g}}
 +
| {{Yes}}
 +
| N/A (FUSE-based)
 +
| [[w:Microsoft_Windows|Windows]] file system
 +
|-
 +
| [[Reiser4]]
 +
| {{man|8|mkfs.reiser4|url=}}
 +
| {{AUR|reiser4progs}}
 +
| {{No}}
 +
|
 +
|
 +
|-
 +
| [[w:ReiserFS|ReiserFS]]
 +
| {{man|8|mkfs.reiserfs|url=}}
 +
| {{Pkg|reiserfsprogs}}
 +
| {{Yes}} ({{Grp|base}})
 +
|
 +
|
 +
|-
 +
| [[XFS]]
 +
| {{man|8|mkfs.xfs}}
 +
| {{Pkg|xfsprogs}}
 +
| {{Yes}} ({{Grp|base}})
 +
|
 +
[https://www.kernel.org/doc/Documentation/filesystems/xfs.txt xfs.txt]<br>
 +
[https://www.kernel.org/doc/Documentation/filesystems/xfs-delayed-logging-design.txt xfs-delayed-logging-design.txt]<br>
 +
[https://www.kernel.org/doc/Documentation/filesystems/xfs-self-describing-metadata.txt xfs-self-describing-metadata.txt]
 +
|
 +
|-
 +
| [[ZFS]]
 +
|
 +
| {{AUR|zfs-linux-git}}
 +
| {{No}}
 +
| N/A ([[w:OpenZFS|OpenZFS]] port)
 +
|
 +
|}
 +
 
 +
{{Note|The kernel has its own NTFS driver (see [https://www.kernel.org/doc/Documentation/filesystems/ntfs.txt ntfs.txt]), but it has limited support for writing files.}}
 +
 
 +
=== Journaling ===
  
{{Note|Your device must be unmounted to format and create a new file system.}}
+
All the above filesystems with the exception of ext2, FAT16/32, use [[Wikipedia:Journaling_file_system|journaling]]. Journaling provides fault-resilience by logging changes before they are committed to the filesystem. 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 filesystem.
  
Manipulate the partition table as you like. For that you can use '''fdisk''' for MBR or '''gdisk''' for GPT or [[#GUI tools|GUI tools]]. See [[partitioning]] for more information.
+
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 [https://reiser4.wiki.kernel.org/index.php/Reiser4_transaction_models "transaction models"], which include pure journaling (equivalent to ext4's data-mode journaling), pure Copy-on-Write approach (equivalent to btrfs' default) and a combined approach which heuristically alternates between the two former. ''It should be noted that reiser4 does not provide an equivalent to ext4's default journaling behavior (meta-data only).''
  
Now you can create new file systems through console tools or graphic interface tools.
+
The other filesystems provide ordered-mode journaling, which only logs meta-data. While all journaling will return a filesystem 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. The trade-off between system speed and data safety should be considered when choosing the filesystem type.
  
=== Console tools ===
+
=== FUSE-based file systems ===
  
To create a file system you just have to use '''mkfs''':
+
[[Wikipedia:Filesystem in Userspace|Filesystem in Userspace]] (FUSE) is a mechanism for Unix-like operating systems that lets non-privileged users create their own file systems without editing kernel code. This is achieved by running file system code in ''user space'', while the FUSE kernel module provides only a "bridge" to the actual kernel interfaces.
  
# mkfs -t ext4 /dev/''<partition>''
+
Some FUSE-based file systems:
  
As '''mkfs''' is just a unified front-end for the different {{ic|mkfs.''fstype''}} tools.
+
* {{App|adbfs-git|Mount an Android device filesystem.|http://collectskin.com/adbfs/|{{AUR|adbfs-git}}}}
 +
* {{App|fuseiso|Mount an ISO as a regular user.|http://sourceforge.net/projects/fuseiso/|{{Pkg|fuseiso}}}}
 +
* {{App|vdfuse|Mounting VirtualBox disk images (VDI/VMDK/VHD).|https://github.com/muflone/virtualbox-includes|{{AUR|vdfuse}}}}
 +
* {{App|xbfuse-git|Mount an Xbox (360) ISO.|http://multimedia.cx/xbfuse/|{{AUR|xbfuse-git}}}}
 +
* {{App|xmlfs|Represent an XML file as a directory structure for easy access.|https://github.com/halhen/xmlfs|{{AUR|xmlfs}}}}
 +
* {{App|[[EncFS]]|EncFS is a userspace stackable cryptographic file-system.|https://vgough.github.io/encfs/|{{Pkg|encfs}}}}
 +
* {{App|[[gitfs]]|gitfs is a FUSE file system that fully integrates with git.|https://www.presslabs.com/gitfs/|{{Aur|gitfs}}}}
  
To create a swap file system, use '''mkswap''':
+
See [[Wikipedia:Filesystem in Userspace#Example uses]] for more.
  
# mkswap /dev/''<partition>''
+
=== Special-type file systems ===
  
=== GUI tools ===
+
{{Style|Ambiguous section name, c.f. [https://upload.wikimedia.org/wikipedia/commons/3/30/IO_stack_of_the_Linux_kernel.svg].}}
  
There are several GUI tools for partition management:
+
* {{App|[[Wikipedia: cramfs|CramFS]]|'''Compressed ROM filesystem''' is a read only filesystem designed with simplicity and efficiency in mind. Its maximum file size is less 16MB and the maximum file system size is around 272MB.|http://sourceforge.net/projects/cramfs/|{{Pkg|util-linux}}}}
* {{App|[[Gparted]]|GTK+ Partition Magic clone, frontend to GNU Parted.|http://gparted.sourceforge.net|{{Pkg|gparted}}}}
+
* {{App|[[eCryptfs]]|'''Enterprise Cryptographic Filesystem''' is a package of disk encryption software for Linux. It is implemented as a POSIX-compliant filesystem-level encryption layer, aiming to offer functionality similar to that of GnuPG at the operating system level.|http://ecryptfs.org|{{Pkg|ecryptfs-utils}}}}
* {{App|gnome-disk-utility|Disk management utility for GNOME.|http://www.gnome.org|{{Pkg|gnome-disk-utility}}}}
+
* {{App|[[Wikipedia: SquashFS|SquashFS]]|'''SquashFS''' is a compressed read only filesystem. SquashFS compresses  files, inodes and directories, and supports block sizes up to 1 MB for greater compression.|http://squashfs.sourceforge.net/|{{Pkg|squashfs-tools}}}}
* {{App|KDE Partition Manager|KDE utility that allows you to manage disks, partitions, and file systems.|https://sourceforge.net/projects/partitionman/|{{AUR|partitionmanager}}}}
+

Latest revision as of 16:38, 23 September 2016

From Wikipedia:

In computing, a file system (or filesystem) is used to control 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".

Individual drive partitions can be setup using one of the many different available filesystems. 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.

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 w:Loop device). This section describe the partition case.

Note: File systems can be written directly to a disk, known as a superfloppy or partitionless disk. Certain limitations are involved with this method, particularly if booting from such a drive. See Btrfs#Partitionless Btrfs disk for an example.
Warning: After creating a new filesystem, data previously stored on this partition can unlikely be recovered. Create a backup of any data you want to keep.

Identify the partition where the file system will be created, for example with lsblk:

$ lsblk -f
NAME   FSTYPE LABEL     UUID                                 MOUNTPOINT
sdb                                                          
└─sdb1 vfat   Transcend 4A3C-A9E9

An existing file system, if present, will be shown in the FSTYPE column. If mounted, it will appear in the MOUNTPOINT column or in the output of findmnt(8). For example:

$ findmnt /dev/sdb1

Mounted file systems must be unmounted with umount(8) before proceeding:

# umount /mountpoint

To create a new file system, use mkfs(8). See #Types of file systems for the exact type, as well as userspace utilities you may wish to install for a particular file system.

Warning: The purpose of a given partition may restrict the choice of file system. For example, an EFI System Partition must contain a FAT32 (mkfs.vfat) file system, and the file system containing the /boot directory must be supported by the boot loader.

For example, to create a new file system of type ext4 (common for Linux data partitions), run:

# mkfs.ext4 /dev/sdb1
Tip:
  • Use the -L flag of mkfs.ext4 to specify a file system label. e4label can be used to change the label on an existing file system.
  • File systems may be resized after creation, with certain limitations. For example, an XFS volume can be increased, but not reduced in size. See Resize capabilities and the respective file system documentation for details.

The new file system can now be mounted to a directory of choice.

Types of file systems

See filesystems(5) for a general overview, and w:Comparison_of_file_systems for a detailed feature comparison.

File system Creation command Userspace utilities Archiso [1] Kernel documentation [2] Notes
Btrfs mkfs.btrfs(8) btrfs-progs Yes btrfs.txt Stability status
VFAT mkfs.vfat(8) dosfstools Yes vfat.txt
exFAT mkfs.exfat(8) exfat-utils Optional N/A (FUSE-based)
F2FS mkefs.f2fs(8) f2fs-tools Yes f2fs.txt Flash-based devices
ext3 mke2fs(8) e2fsprogs Yes (base) ext3.txt
ext4 mke2fs(8) e2fsprogs Yes (base) ext4.txt
HFS mkfs.hfsplus(8) hfsprogs Optional hfs.txt macOS file system
JFS mkfs.jfs(8) jfsutils Yes (base) jfs.txt
NILFS2 mkfs.nilfs2(8) nilfs-utils Yes nilfs2.txt
NTFS mkfs.ntfs(8) ntfs-3g Yes N/A (FUSE-based) Windows file system
Reiser4 mkfs.reiser4(8) reiser4progsAUR No
ReiserFS mkfs.reiserfs(8) reiserfsprogs Yes (base)
XFS mkfs.xfs(8) xfsprogs Yes (base)

xfs.txt
xfs-delayed-logging-design.txt
xfs-self-describing-metadata.txt

ZFS zfs-linux-gitAUR No N/A (OpenZFS port)
Note: The kernel has its own NTFS driver (see ntfs.txt), but it has limited support for writing files.

Journaling

All the above filesystems with the exception of ext2, FAT16/32, use journaling. Journaling provides fault-resilience by logging changes before they are committed to the filesystem. 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 filesystem.

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 include pure journaling (equivalent to ext4's data-mode journaling), pure Copy-on-Write approach (equivalent to btrfs' default) and a combined approach which heuristically alternates between the two former. It should be noted that reiser4 does not provide an equivalent to ext4's default journaling behavior (meta-data only).

The other filesystems provide ordered-mode journaling, which only logs meta-data. While all journaling will return a filesystem 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. The trade-off between system speed and data safety should be considered when choosing the filesystem type.

FUSE-based file systems

Filesystem in Userspace (FUSE) is a mechanism for Unix-like operating systems that lets non-privileged users create their own file systems without editing kernel code. This is achieved by running file system code in user space, while the FUSE kernel module provides only a "bridge" to the actual kernel interfaces.

Some FUSE-based file systems:

  • adbfs-git — Mount an Android device filesystem.
http://collectskin.com/adbfs/ || adbfs-gitAUR
  • fuseiso — Mount an ISO as a regular user.
http://sourceforge.net/projects/fuseiso/ || fuseiso
  • vdfuse — Mounting VirtualBox disk images (VDI/VMDK/VHD).
https://github.com/muflone/virtualbox-includes || vdfuseAUR
  • xbfuse-git — Mount an Xbox (360) ISO.
http://multimedia.cx/xbfuse/ || xbfuse-gitAUR
  • xmlfs — Represent an XML file as a directory structure for easy access.
https://github.com/halhen/xmlfs || xmlfsAUR
  • EncFS — EncFS is a userspace stackable cryptographic file-system.
https://vgough.github.io/encfs/ || encfs
  • gitfs — gitfs is a FUSE file system that fully integrates with git.
https://www.presslabs.com/gitfs/ || gitfsAUR

See Wikipedia:Filesystem in Userspace#Example uses for more.

Special-type file systems

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Ambiguous section name, c.f. [3]. (Discuss in Talk:File systems#)
  • CramFSCompressed ROM filesystem is a read only filesystem designed with simplicity and efficiency in mind. Its maximum file size is less 16MB and the maximum file system size is around 272MB.
http://sourceforge.net/projects/cramfs/ || util-linux
  • eCryptfsEnterprise Cryptographic Filesystem is a package of disk encryption software for Linux. It is implemented as a POSIX-compliant filesystem-level encryption layer, aiming to offer functionality similar to that of GnuPG at the operating system level.
http://ecryptfs.org || ecryptfs-utils
  • SquashFSSquashFS is a compressed read only filesystem. SquashFS compresses files, inodes and directories, and supports block sizes up to 1 MB for greater compression.
http://squashfs.sourceforge.net/ || squashfs-tools