• Post author:Bhaskar Soni
  • Post published:
  • Post category:Operating System
  • Post comments:0 Comments
  • Reading time:4 mins read

Disks store raw blocks of data. Users and programs, however, think in files and folders. File system management is the part of the operating system that bridges this gap. It decides how files are named, stored, found, protected and recovered.

This guide explains what a file system does, file attributes and access methods, file types, directories, how space is allocated, and the file systems you will meet on Windows, Linux and other devices.

file system management

What a file system does

A file system:

  • organises data into files and directories;
  • tracks where each file’s data sits on disk;
  • manages free space;
  • stores metadata, such as size, owner and timestamps;
  • enforces permissions;
  • protects consistency after crashes, often with journaling.

File attributes

Each file carries metadata. Common attributes include:

AttributeMeaning
NameHuman-readable name
IdentifierInternal number, such as an inode number on Linux
TypeRegular file, directory, link or device
LocationWhere the data blocks sit
SizeCurrent size in bytes
PermissionsWho can read, write or execute
TimestampsCreated, modified and last accessed
OwnerUser and group that own the file

On Linux, stat filename shows most of these.

File access methods

  • Sequential access: read or write from start to end, like a log file or a tape.
  • Direct (random) access: jump to any block, as databases do.
  • Indexed access: use an index to find records quickly, then access them directly.

File types in Unix-like systems

Linux and Unix treat almost everything as a file:

Typels -l symbolExample
Regular file-Text, images, programs
Directoryd/home
Symbolic linklShortcut to another file
Character devicec/dev/tty, serial ports
Block deviceb/dev/sda, disks
Named pipepCommunication between processes
SocketsLocal network-style communication

Device files have a major number, which identifies the driver, and a minor number, which identifies the specific device.

Directories

Directories organise files into a tree. Linux uses one tree starting at /, with standard locations such as /etc for configuration and /var for changing data. Windows uses a tree per drive letter, such as C:\. Both support links, so one file can appear in more than one place.

How space is allocated

MethodHow it worksPros and cons
ContiguousEach file uses consecutive blocksFast reads, but fragmentation
LinkedEach block points to the nextNo fragmentation, but slow random access
IndexedAn index block lists all data blocksFast random access; used by inodes
ExtentsRanges of consecutive blocksEfficient for large files; used by ext4, XFS and NTFS

Journaling file systems first record planned changes in a journal. As a result, after a crash they can recover quickly without a full disk check.

Partitions, firmware and booting

Before a disk holds a file system, it needs a partition table. Older systems use MBR, which supports up to four primary partitions and disks up to 2 TiB. Modern systems use GPT with UEFI firmware, which supports many partitions and very large disks. Read more in our guide to partitions.

Common file systems

Windows

  • NTFS: the default for Windows, with permissions, journaling and encryption support.
  • ReFS: designed for resilience on servers and storage pools.
  • FAT32 and exFAT: simple formats for USB drives and memory cards; exFAT supports large files.

Linux

  • ext4: the long-time default on many distributions; stable and well supported.
  • XFS: default on RHEL and its rebuilds; strong with large files.
  • Btrfs: supports snapshots, checksums and compression; default on Fedora desktop and openSUSE.
  • ZFS: advanced pooling, checksums and snapshots; popular for storage servers.

macOS and mobile

  • APFS: used by macOS and iOS, optimised for SSDs.
  • F2FS: a flash-friendly file system used on many Android devices.

Embedded and flash

  • UBIFS and JFFS2: designed for raw flash chips in routers and IoT devices.

Useful commands

df -h          # free space per file system
lsblk -f       # block devices and their file systems
mount          # mounted file systems
du -sh /var/*  # space used per directory

Related guides

Sources

Running Linux servers in production? Our Linux server hardening & security audit checks configuration, patching, SSH and logging. You can also use our free Linux server hardening checklist, or contact us.

Post author avatar

Bhaskar Soni

Bhaskar Soni is a Security Engineer and the founder of Youngster Company, based in Ahmedabad, Gujarat. He works hands-on with Linux server hardening, vulnerability assessment and penetration testing (VAPT), ISO 27001 compliance and OSINT investigations. He writes practical, tested guides for IT professionals and Indian businesses, and every article on this site is written or reviewed by him.

Leave a Reply