Fundamentals 51 min read

Understanding Mechanical Hard Drives: Structure, Partitioning, and Linux Management

This guide explains the physical structure of mechanical hard drives, how data is organized into sectors, tracks, and cylinders, and provides step‑by‑step Linux commands for calculating disk capacity, creating MBR/GPT partitions, formatting filesystems, and managing swap space.

Linux Cloud Computing Practice
Linux Cloud Computing Practice
Linux Cloud Computing Practice
Understanding Mechanical Hard Drives: Structure, Partitioning, and Linux Management

Mechanical Hard Drive Structure

Mechanical hard drives consist of multiple platters that rotate around a spindle. Each platter has read/write heads that hover just above the surface, moving radially to access data. All platters and heads operate synchronously, so data is read or written on the same cylinder across all heads.

Data is divided into sectors, tracks, and cylinders. A sector is the smallest addressable unit (commonly 512 bytes, though modern drives may use larger sizes). Tracks are concentric circles on a platter, numbered from 0 outward. Cylinders are sets of tracks at the same radius across all platters.

Disk Capacity Calculation

Capacity is calculated using the formula: disk_size = units × cylinders or

disk_size = heads × sectors_per_track × 512 × cylinders

Example using fdisk -l /dev/sda3:

[root@xuexi tmp]# fdisk -l /dev/sda3
Disk /dev/sda3: 19.1 GB, 19116589056 bytes
255 heads, 63 sectors/track, 2324 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Partition Types (MBR and GPT)

MBR (Master Boot Record) supports up to four primary partitions. Additional partitions are created by defining an extended partition that can contain unlimited logical partitions.

GPT (GUID Partition Table) removes the four‑partition limit, allowing up to 128 primary partitions and supporting disks larger than 2 TB.

Partitioning Tools

fdisk – works with MBR disks. Use commands like n (new), p (primary), e (extended), l (logical), and w (write).

gdisk – works with GPT disks. Similar interactive commands, with n to create a partition and w to write the table.

parted – supports both MBR and GPT, can operate non‑interactively with the -s flag.

Formatting Filesystems

The mkfs family creates filesystems. Example for ext4 with custom block and inode sizes: mkfs -t ext4 -b 4096 -I 256 /dev/sdb2 Use mke2fs for detailed ext2/3/4 options, and tune2fs to adjust automatic checks.

Filesystem Inspection Tools

lsblk

– lists block devices and their mount points. blkid – shows UUID and type of each filesystem. df – reports space usage of mounted filesystems. du – estimates directory/file space usage. dumpe2fs – displays superblock information for ext filesystems.

Mounting and Unmounting

Mount a device or image with: mount -t ext4 /dev/sdb1 /mydata/data Mount an ISO image using the loop option:

mount -o loop CentOS-6.6-x86_64-bin-DVD2.iso /mnt

Unmount with umount or force with -l -f. Use fuser -v to find processes keeping a mount busy.

Swap Management

Create a swap partition, format it with mkswap, enable it with swapon, and add an entry to /etc/fstab for automatic activation at boot.

Check swap usage with free -m or swapon -s.

LinuxStoragePartitioningFilesystemhard drive
Linux Cloud Computing Practice
Written by

Linux Cloud Computing Practice

Welcome to Linux Cloud Computing Practice. We offer high-quality articles on Linux, cloud computing, DevOps, networking and related topics. Dive in and start your Linux cloud computing journey!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.