Operations 30 min read

Master Linux Disk Management: Devices, RAID, Partitioning, and LVM

This comprehensive guide explains Linux's "everything is a file" philosophy, details disk types and interfaces, compares SSD and HDD characteristics, describes RAID levels and their trade‑offs, walks through MBR/GPT partitioning, filesystem creation, mounting, persistent fstab entries, essential disk tools, real‑world enterprise scenarios, and step‑by‑step LVM setup and expansion.

Raymond Ops
Raymond Ops
Raymond Ops
Master Linux Disk Management: Devices, RAID, Partitioning, and LVM

Disk Management

Linux treats everything as a file, including hardware devices that appear as device files.

# ll /dev/sda*
brw-rw---- 1 root disk 8, 0 Nov 20 04:11 /dev/sda
brw-rw---- 1 root disk 8, 1 Nov 20 04:11 /dev/sda1
brw-rw---- 1 root disk 8, 2 Nov 20 04:11 /dev/sda2
# ll /dev/zero
crw-rw-rw- 1 root root 1, 5 Nov 20 04:11 /dev/zero
Major number identifies device type; minor number identifies a specific device.

1. Disk External Structure

Disk classifications:

Solid‑state drive (SSD): internal architecture similar to a USB flash drive.

Mechanical hard drive (HDD): rotating platters, spindle, actuator arm, similar to a DVD.

NVMe drive.

PCI‑E interface.

Size categories:

3.5‑inch – desktop computers.

2.5‑inch – servers and laptops.

Interface types:

IDE – obsolete.

SCSI – obsolete.

SATA – desktop and laptop.

SAS – enterprise server standard.

SSD is faster but more expensive and has limited lifespan; HDD is cheaper, larger, and slower. Performance improves with higher rotation speed (5400, 7200, 10K, 15K rpm). Note: speed is not solely determined by interface; NVMe drives are the fastest.

2. Disk Array (RAID)

Purpose:
  Obtain larger capacity   # combine multiple disks into one
  Increase performance    # write to two disks faster than one
  Improve reliability     # mirror data on two disks

Interview questions

RAID levels summary:

RAID 0 – at least one disk, usable capacity = total size, no safety, fastest read/write, suitable for speed‑critical workloads like database replicas.

RAID 1 – exactly two disks, usable capacity = half, can lose one disk, slower write, typical for system disks.

RAID 5 – at least three disks, usable capacity = n‑1 disks, can lose one disk, balanced performance, suitable for stable business traffic.

RAID 10 – at least four disks (multiple of two), usable capacity = half, can lose half the disks, high read/write speed, ideal for high‑concurrency scenarios.

3. Disk Partitioning

Windows default uses MBR, which supports up to four primary partitions (C D E F). MBR can also have three primary partitions plus one extended partition containing many logical partitions.

Linux device naming example:

sda   # first disk
sda1  # first partition of first disk
sda2  # second partition of first disk
sdb   # second disk
sdb1  # first partition of second disk
sdb5  # first logical partition of second disk

1. Linux partition schemes

# System partition example (300 GB disk)
/boot 200M   # kernel and bootloader
/      rest  # root filesystem

# Swap partition example
/boot 200M
swap 2G   # temporary memory when RAM is insufficient

# Custom example
/boot 200M
swap 2G
/ 50G   # system
/data 1.8T   # data partition

2. Partition types

MBR: up to 4 primary partitions. GPT: up to 128 primary partitions.

3. Partition steps

1. For MBR (<2 TB) use fdisk.
2. For GPT (>2 TB) use parted.

# Scan SCSI bus
for i in $(ls /sys/class/scsi_host/); do echo '- - -' > /sys/class/scsi_host/${i}/scan; done

# fdisk example
fdisk /dev/sdb
# (use 'n' to create, 'p' for primary, specify size, etc.)

# partprobe to refresh kernel partition table
partprobe

Non‑interactive fdisk example:

# echo -e 'p
n

+1G
p
' | fdisk /dev/sdb

parted example (GPT):

(parted) mklabel gpt
(parted) mkpart primary xfs 0 500G
(parted) print

4. Filesystems

A filesystem defines how files are organized and stored on a storage device.

Common Linux filesystems:

ext2 – suitable for small, rarely‑updated partitions (e.g., /boot).

ext3 – ext2 with journaling.

ext4 – latest ext version with large file support, nanosecond timestamps, and performance improvements.

xfs – SGI, supports up to 8 EB.

swap – dedicated swap partition.

iso9660 – optical disc filesystem.

Common Windows filesystems:

FAT32 – max 4 GB file, 16 TB volume.

NTFS – max 16 EB file and volume.

exFAT.

Common Unix filesystems:

FFS (fast).

UFS – default on many Unix systems.

JF32.

3. Creating filesystems

# mkfs.ext4 /dev/sdb1
# mkfs.xfs /dev/sdb2

5. Disk Mounting

mount [-lhV]
mount -a [options]
mount --source /dev/sdb1 -o ro /dir1

Mount source can be a device file, label, UUID, or pseudo‑filesystem (proc, sysfs, devtmpfs, configfs). The mount point must exist and is usually an empty directory. Only one device can be mounted on a point at a time, but a device may be mounted on multiple points.

6. Persistent Mounts

Entries in /etc/fstab have six fields: device (or LABEL/UUID), mount point, filesystem type, mount options, dump frequency, and fsck order.

/dev/sdb1 /mnt/xfs xfs defaults 0 0

7. Common Disk Tools

df – display filesystem usage (e.g., df -t ext4 -h).

du – display directory usage (e.g., du -sh /etc/).

dd – low‑level copy, useful for backing up MBR ( dd if=/dev/sdb of=./sdb.img bs=512 count=1) or entire disks.

8. Enterprise Cases

Case 1: Swap sizing and creation

# dd if=/dev/zero of=/swapfile bs=1G count=1
# mkswap /swapfile
# swapon /swapfile

Case 2: Disk full – locate large files # find / -type f -size +1G Case 3: Insufficient space – add larger disk, mount, move log, create symlink

# mount /dev/sdc3 /data
# mv /var/log/10g /data/
# ln -s /data/10g /var/log/10g

Case 4: Deleting a file still held by a process

# lsof | grep 10g
# kill -9 <pid>

9. Logical Volumes (LVM)

LVM provides an abstraction layer for flexible storage management: physical volumes → volume group → logical volume → filesystem.

1. What is a logical volume

LVM allows resizing, adding, and moving logical volumes across multiple physical devices.

2. Creating logical volumes

# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3
# vgcreate vg1 /dev/sdb1 /dev/sdb2
# lvcreate -L 5G -n lv1 vg1
# mkfs.ext4 /dev/vg1/lv1
# mount /dev/vg1/lv1 /lv1

3. Extending logical volumes

# vgextend vg1 /dev/sdb3
# lvextend -L 7G /dev/vg1/lv1
# resize2fs /dev/vg1/lv1   # for ext* filesystems
# xfs_growfs /dev/vg1/lv2  # for XFS after lvextend
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxLVMFilesystemRAIDdisk-management
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

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.