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, compares old and new zoning methods, and provides detailed Linux commands for calculating capacity, creating partitions with MBR or GPT, formatting filesystems, and managing mounts and swap space.
Mechanical Hard Drive Structure
A mechanical hard drive consists of multiple platters that rotate around a spindle, with read/write heads that hover just above each platter surface. All platters and heads move synchronously, and data is accessed by rotating the platters and moving the heads across tracks.
Platters are divided into concentric tracks, each split into sectors (typically 512 bytes, though sector size can vary). The outer tracks contain more sectors than inner tracks, leading to older "uniform" zoning and newer "zoned" designs where sector count per track varies.
Cylinders are formed by aligning tracks of the same radius across all platters; data is often read/written per cylinder for performance.
Capacity Calculation
Disk size can be estimated using:
Disk Size = units × cylinders
Disk Size = heads × sectors per track × 512 × cylindersExample using fdisk -l /dev/sda3 shows a 19.1 GB disk with 255 heads, 63 sectors/track, and 2324 cylinders.
Partitioning Overview
Partitions divide a disk logically, using cylinders as units (CentOS 7 uses sectors). MBR supports up to four primary partitions; additional partitions require an extended partition and logical partitions. GPT removes the four‑partition limit, supporting up to 128 primary partitions.
Partition Tools
fdisk – interactive MBR partitioning.
gdisk – GPT partitioning.
parted – supports both MBR and GPT, can operate non‑interactively.
Common commands include n to create a partition, p to print the table, and w to write changes.
Non‑Interactive Partitioning
Commands can be piped into fdisk or written to a script file. Example for creating two partitions:
echo -e "n
p
1
+5G
n
p
2
+1G
w
" | fdisk /dev/sdbSimilar approaches work for gdisk and parted using the -s (script) option.
Filesystem Creation
After partitioning, format partitions with mkfs or specific tools like mkfs.ext4. Example: mkfs -t ext4 /dev/sdb2 The mke2fs utility offers many options, such as block size ( -b), inode size ( -I), and inode density ( -i).
Filesystem Tuning
Use tune2fs to adjust automatic checks, e.g., tune2fs -i 0 /dev/sdb1 disables periodic checks.
Inspecting Devices and Filesystems
lsblk– lists block devices and their mount points. blkid – shows filesystem type and UUID. df – reports filesystem space usage. du – estimates directory/file space usage. dumpe2fs – displays ext* superblock details.
Mounting and Unmounting
Mount filesystems with mount, specifying type ( -t ext4) and options ( -o ro, -o rw, -o loop for images). Example mounting an ISO: mount -o loop CentOS-6.6-x86_64-bin-DVD2.iso /mnt Bind mounts duplicate a directory view: mount --bind /mydata /mnt Unmount with umount or force with -l -f. Use fuser -v to find processes keeping a mount busy.
Automatic Mounting
Add entries to /etc/fstab for boot‑time mounts. Example line for a swap partition: /dev/sda3 swap swap defaults 0 0 For on‑demand mounting, configure autofs with /etc/auto.master and related map files.
Swap Management
Check swap usage with free or swapon -s. Create a swap partition with mkswap /dev/sdb5 and enable it using swapon /dev/sdb5. Add it to /etc/fstab for automatic activation.
Additional Tools
Mount Windows shares using mount.cifs (specify vers=2.0 for newer Windows). Use sshfs to mount remote directories over SSH.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
