OS - File System

Updated: 2019-04-23

Default File Systems

  • macOS/iOS: APFS, Apple File System

    • replaces HFS+
    • optimized for flash and solid-state drive storage, with a primary focus on encryption
    • APFS supports 64-bit inode numbers, supporting over 9 quintillion files on a single volume
  • Windows 10: NTFS
  • Red Hat/CentOS: XFS

Check FileSystem Types

$ df -Th

You may find other filesystem like:

  • tmpfs: a common name for a mounted file system, but stored in volatile memory instead of a persistent storage device
  • drvfs: mounted Windows disks, seen in Windows Subsystem for Linux (WSL). e.g. C:\ will be /mnt/c, and D:\ will be /mnt/d

FUSE

FUSE: Filesystem in Userspace. The interface that lets non-privileged users create their own file systems without editing kernel code; a "bridge" to the actual kernel interfaces. E.g. GlusterFS, GmailFS.

Code: https://github.com/libfuse/libfuse

Layout

Linux

/var: contains files to which the system writes data during the course of its operation.

  • /var/cache (contains cached data from application programs),
  • /var/games (contains variable data relating to games in /usr),
  • /var/lib (contains dynamic data libraries and files),
  • /var/lock (contains lock files created by programs to indicate that they are using a particular file or device),
  • /var/log (contains log files),
  • /var/run (contains PIDs and other system information that is valid until the system is booted again) and
  • /var/spool (contains mail, news and printer queues).

After systemd, /run replaces /var/run, will be cleared at the beginning of the boot process.

/run/user/$uid: created by systemd, local to the system, only accessible by the target user, the same as $XDG_RUNTIME_DIR.

/usr vs /usr/local

/usr is for software built elsewhere and then installed on the machine (mostly from your distributions package management system)

/usr/local is for software built locally

List All Block Devices and Partitions

$ cat /proc/partitions
major minor  #blocks  name

253        0   31457280 vda
253       16   62914560 vdb
253       32      65536 vdc
253       48  251658240 vdd

Use file -s <device> to check type

$ sudo file -s /dev/vda
/dev/vda: Linux rev 1.0 ext4 filesystem data, UUID=6f54f78f-3f47-488c-ab1b-b1b8a596c2d3, volume name "c3image-rootfs" (needs journal recovery) (extents) (large files) (huge files)

gvfs

gvfs: GNOME Virtual file system. GNOME's userspace virtual filesystem.