File systems

From ArchWiki
Jump to: navigation, search

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.

Types of file systems

See filesystems(5) for a general overview, and w:Comparison_of_file_systems for a detailed feature comparison. File systems supported by the kernel are listed in /proc/filesystems.

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-linuxAUR 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

Identify existing file systems

To identify existing file systems, you can use 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.

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.
  • 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.

Before continuing, identify the partition where the file system will be created using lsblk and whether or not it is mounted. For example, you can follow the instructions in #Identify existing file systems.

Mounted file systems must be unmounted before proceeding. See #Unmount a file system on how to do so.

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.

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.

Mount a filesystem

To manually mount a filesystem on a device (e.g., a partition) use mount(8):

# mount /dev/sda1 /mnt

This attached the filesystem on /dev/sda1 at the directory /mnt, making the contents of the filesystem 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 /etc/fstab and only the device or mount point is given on the command line, that information will be used in mounting. For example, if /etc/fstab contains a line indicating that /dev/sda1 should be mounted to /mnt, then the following will automatically mount the device to that location:

# mount /dev/sda1

Or

# mount /mnt

mount contains several options, many of which depend on the file system specified. The options can be changed by using flags on the command line with mount, by editing fstab, by creating udev rules, by compiling the kernel yourself, or by using filesystem-specific mount scripts (located at /usr/bin/mount.*). See these related articles and the article of the filesystem of interest for more information.

List mounted file systems

To list all mounted file systems, use findmnt(8):

$ findmnt

findmnt 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/sda1

findmnt gathers information from /etc/fstab, /etc/mtab, and /proc/self/mounts.

Umount a file system

To unmount a file system use umount(8). Either the device containting the file system or the mount point can be specified:

# umount /dev/sda1

Or

# umount /mnt

See also