Unix - Disk Partitioning and File System Mounting in UNIX

Disk partitioning and file system mounting are two fundamental concepts in UNIX system administration. They determine how storage devices are organized, accessed, and managed by the operating system. Proper partitioning and mounting improve system performance, security, and data management while allowing administrators to efficiently utilize available storage resources.

Understanding Disk Partitioning

A disk partition is a logical division of a physical storage device such as a hard disk drive (HDD) or solid-state drive (SSD). Partitioning allows a single disk to be divided into multiple independent sections, each of which can contain its own file system.

For example, a 1 TB hard drive can be divided into:

  • A partition for the operating system

  • A partition for user data

  • A partition for backups

  • A partition for swap space

Each partition behaves like a separate storage unit even though they exist on the same physical disk.

Why Partition a Disk?

Partitioning provides several advantages:

Better Organization

Different types of data can be stored in separate partitions. System files, user files, and application data can be managed independently.

Improved Security

Separating critical system files from user data reduces the risk of accidental modifications or data loss.

Easier Backup and Recovery

Administrators can back up specific partitions without affecting the entire disk.

Multiple Operating Systems

Different operating systems can be installed on separate partitions of the same disk.

Performance Optimization

Certain workloads perform better when applications and data are distributed across different partitions.

Types of Partitions

Primary Partition

A primary partition is a standard partition that can contain a file system and be used to boot an operating system.

Extended Partition

An extended partition acts as a container for logical partitions. It helps overcome limitations on the number of primary partitions.

Logical Partition

Logical partitions are created inside an extended partition and function like regular partitions.

Disk Identification in UNIX

UNIX systems identify storage devices using special files located in the /dev directory.

Examples:

/dev/sda
/dev/sdb
/dev/sdc

Partition names are usually represented as:

/dev/sda1
/dev/sda2
/dev/sda3

Here:

  • /dev/sda represents the disk

  • /dev/sda1 represents the first partition

  • /dev/sda2 represents the second partition

Viewing Disk Information

Administrators can inspect available disks and partitions using commands such as:

lsblk

Output example:

sda
├─sda1
├─sda2
└─sda3

Another useful command is:

fdisk -l

This displays detailed information about all storage devices and partitions.

Creating Partitions

The fdisk utility is commonly used for partition management.

Example:

fdisk /dev/sda

Inside the utility, administrators can:

  • Create new partitions

  • Delete partitions

  • Change partition types

  • Save partition tables

Modern UNIX systems may also use:

parted

or

gparted

for advanced partition management.

Understanding File Systems

After creating a partition, it must be formatted with a file system before it can store data.

A file system determines:

  • How files are stored

  • How directories are organized

  • How free space is managed

  • How permissions are maintained

Common UNIX file systems include:

UFS (Unix File System)

Traditional file system used in many UNIX environments.

ZFS

Advanced file system providing:

  • Data integrity

  • Snapshots

  • Compression

  • Storage pooling

ext4

Widely used in Linux-based UNIX systems.

XFS

Known for high-performance handling of large files and storage volumes.

Creating a File System

The mkfs command is used to create a file system.

Example:

mkfs.ext4 /dev/sda1

This formats the partition and prepares it for data storage.

What Is Mounting?

Mounting is the process of attaching a file system to the UNIX directory structure.

Unlike some operating systems that assign drive letters, UNIX integrates all storage devices into a single directory tree.

Every mounted file system becomes accessible through a directory called a mount point.

Mount Points

A mount point is an existing directory where a file system is attached.

Examples:

/mnt
/media
/home
/data

If a partition is mounted on /data, its contents become accessible through that directory.

Manual Mounting

The mount command is used to attach a file system.

Example:

mount /dev/sda1 /data

After mounting, users can access files stored on that partition through the /data directory.

To verify mounted file systems:

mount

or

df -h

Unmounting a File System

Before removing a storage device or performing maintenance, the file system should be unmounted.

Example:

umount /data

or

umount /dev/sda1

Unmounting ensures that all pending data is written to disk and prevents corruption.

Automatic Mounting at Boot Time

UNIX systems use configuration files to automatically mount file systems during startup.

A common configuration file is:

/etc/fstab

Example entry:

/dev/sda1   /data   ext4   defaults   0 0

Fields represent:

  1. Device name

  2. Mount point

  3. File system type

  4. Mount options

  5. Backup option

  6. File system check order

When the system boots, it reads this file and mounts the listed file systems automatically.

Mount Options

Mount options control how a file system behaves.

Examples include:

Read-Only

mount -o ro /dev/sda1 /data

Prevents modification of files.

Read-Write

mount -o rw /dev/sda1 /data

Allows file creation and modification.

No Execution

mount -o noexec /dev/sda1 /data

Prevents execution of programs from that partition.

These options enhance security and system control.

Common Problems and Troubleshooting

File System Not Mounting

Possible causes:

  • Incorrect file system type

  • Damaged partition

  • Wrong device name

  • Missing mount point

Device Busy Error

Occurs when files or applications are actively using the mounted partition.

Tools like:

lsof

or

fuser

help identify processes using the file system.

Corrupted File System

Utilities such as:

fsck

can examine and repair damaged file systems.

Example:

fsck /dev/sda1

Best Practices

  • Create separate partitions for system files and user data.

  • Regularly back up important partitions.

  • Use meaningful mount points.

  • Monitor disk usage using df and du.

  • Unmount external drives before removal.

  • Use journaling file systems to improve reliability.

  • Periodically check file system health.

Conclusion

Disk partitioning and file system mounting are essential components of UNIX storage management. Partitioning divides storage into logical sections for better organization and control, while mounting makes those partitions accessible through the UNIX directory structure. A thorough understanding of these concepts enables administrators to efficiently manage storage resources, improve system reliability, and maintain secure, well-organized UNIX environments.