Operations 51 min read

Master Linux Disk & Network Fundamentals: CHS, Partitioning, LVM, RAID, Filesystems, and TCP/IP

This comprehensive guide walks you through Linux storage concepts—from CHS terminology and MBR/GPT layouts to partition creation, LVM management, RAID levels, filesystem formatting, mounting, swap handling, package management, private YUM repository setup, OSI model layers, port basics, TCP handshakes, and IP address classification—providing commands, examples, and practical tips for system administrators.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Disk & Network Fundamentals: CHS, Partitioning, LVM, RAID, Filesystems, and TCP/IP

Hard Disk Storage Terminology (CHS)

Head : magnetic head; number of heads equals number of disk surfaces.

Track : circular path on a surface; number of tracks equals number of cylinders.

Sector : smallest addressable unit, typically 512 bytes.

Cylinder : set of tracks aligned vertically across all surfaces. Example: 63 heads × 255 sectors ≈ 7.84 MiB per cylinder.

# View CHS information
fdisk -l /dev/sda

Disk Storage Management

Benefits of partitioning include optimized I/O, quota enforcement, faster recovery, isolation of system and applications, and the ability to use different filesystems.

Partitioning schemes : MBR (Master Boot Record) and GPT (GUID Partition Table).

MBR Structure

Boot code (offset 0x0000‑0x0087, 136 bytes) loads the active partition’s bootloader.

Error message area (offset 0x0088‑0x00E0).

Partition table (offset 0x01BE‑0x01FD, 64 bytes) holds up to four primary partition entries; each entry is 16 bytes. The final two bytes (0x01FE‑0x01FF) must be 55AA as the boot signature.

GPT Structure

Protective MBR : prevents legacy tools from overwriting a GPT disk.

GPT Header : stored in LBA 1, defines the location and size of partition entries and includes a CRC checksum.

Partition Entries : typically 128 entries (LBA 2‑33); each entry stores type GUID, unique GUID, start/end LBAs, and attributes. GPT supports up to 128 partitions on Windows.

Partition Data : actual filesystem data follows the entries; no concept of extended or logical partitions.

Summary : Use MBR for disks ≤ 2 TiB with up to four primary partitions; use GPT for larger disks, more partitions, and UEFI boot.

Partition Management Commands

# List block devices
lsblk
# Show partition details
blkid

Create partitions with fdisk (MBR) or gdisk (GPT). Example workflow for a 20 GiB disk /dev/sdb:

Run fdisk /dev/sdb.

Choose n to create a new primary partition, specify size +5G.

Use p to print the table, then w to write changes.

To create an extended partition and logical partitions, select type e for extended, then l for logical and repeat the size steps.

File Systems

Common Linux filesystems:

ext4 : journaled, supports up to 1 EiB total size and 16 TiB per file.

XFS : high‑performance, 8 EiB limit, suitable for databases and large files.

# Create ext4 on /dev/sdb1
mkfs.ext4 /dev/sdb1
# Create XFS on /dev/sdb5
mkfs.xfs /dev/sdb5

Mounting

Mounting attaches a filesystem to a directory in the existing hierarchy.

# Temporary mount
mount /dev/sdb1 /mnt/logs
# Read‑only mount
mount -o ro /dev/sdb5 /mysql
# Permanent mount (add to /etc/fstab)
UUID=b47109a2-041c-4c77-97c3-bf37caf8b307 /logs ext4 defaults 0 0

Swap Management

# Disable swap
swapoff -a
# Comment out swap line in /etc/fstab
# Enable swap
swapon -a
# Adjust swappiness
echo "vm.swappiness = 10" >> /etc/sysctl.conf
sysctl -p

LVM (Logical Volume Manager)

Key concepts:

Physical Volume (PV) : underlying disk or partition.

Volume Group (VG) : pool of PVs.

Logical Volume (LV) : virtual partition carved from a VG.

Typical workflow:

Create a PV: pvcreate /dev/sdb3.

Create a VG: vgcreate testvg /dev/sdb3.

Create an LV: lvcreate -L 2G -n log_lv testvg.

Format and mount the LV.

# Extend LV to use all free space
lvextend -l +100%FREE /dev/mapper/testvg-log_lv
# Resize filesystem
resize2fs /dev/testvg/log_lv

To add more storage, create a new PV, then vgextend testvg /dev/sdb4 and extend LVs as needed.

RAID Levels

RAID 0 : striping, 100 % utilization, no redundancy, requires ≥ 2 disks.

RAID 1 : mirroring, 50 % utilization, high redundancy, requires ≥ 2 disks.

RAID 5 : block‑level striping with distributed parity, (n‑1)/n utilization, tolerates one disk failure, requires ≥ 3 disks.

RAID 10 : mirrored stripes, 50 % utilization, high performance and redundancy, requires ≥ 4 disks.

Package Management

RPM (Red Hat based)

# Install a package
rpm -ivh package.rpm
# Remove a package
rpm -e package_name
# Query installed packages
rpm -qa
# Verify package integrity
rpm -V package_name

YUM/DNF (CentOS, Rocky Linux)

# List repositories
yum repolist -v
# Install, update, remove packages
yum install vim
yum update
yum remove httpd
# Clean cache and rebuild
yum clean all
yum makecache

APT/dpkg (Debian/Ubuntu)

# Install .deb file
dpkg -i package.deb
# Remove package (keep config)
dpkg -r package
# Purge package (remove config)
dpkg -P package
# List installed packages
dpkg -l
# Search for file ownership
dpkg -S /bin/ls
# Install via apt
apt update
apt install git curl
# Upgrade system
apt upgrade
# Remove package
apt remove nginx
# Purge package
apt purge nginx

Private YUM Repository Setup

1. Install a web server (e.g., httpd or nginx) to serve repository files.

2. Create directory structure under the web root:

mkdir -p /var/www/html/rockylinux/8/{BaseOS,AppStream,extras}

3. Mount installation media and copy its contents into the appropriate directory.

mount /dev/cdrom /mnt
cp -r /mnt/* /var/www/html/rockylinux/8/

4. Create a repo file on client machines pointing to the server’s HTTP address, then run yum repolist, yum clean all, and yum makecache to use the private repository.

YUM repository directory layout
YUM repository directory layout

System Initialization After Installation

Rocky Linux

# Update all packages
dnf upgrade
# Install development tools
dnf groupinstall "Development Tools"
dnf install vim wget curl git
# Enable/disable firewall
systemctl enable firewalld
systemctl stop firewalld
# Disable SELinux (optional)
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# Set timezone
timedatectl set-timezone Asia/Shanghai

Ubuntu

# Update package list
apt update
# Upgrade packages
apt upgrade
# Install development tools
apt install build-essential vim wget curl git
# Set timezone
timedatectl set-timezone Asia/Shanghai

OSI Seven‑Layer Model

Physical : hardware media (Ethernet, USB, Wi‑Fi, etc.).

Data Link : MAC addressing, error detection (Ethernet, PPP, HDLC).

Network : routing, IP, ICMP, ARP.

Transport : TCP, UDP.

Session : connection management (NetBIOS, RPC, TLS).

Presentation : data formatting (JPEG, MPEG, TLS).

Application : protocols like HTTP, FTP, DNS, SMTP.

Linux Port Basics

Port ranges: 0‑1023 system ports, 1024‑49151 registered ports, 49152‑65535 dynamic ports. TCP provides reliable, connection‑oriented communication; UDP offers connectionless, low‑latency transmission.

# List listening TCP ports
netstat -tuln
# Add firewall rule for HTTP
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload

TCP Overview

TCP is a transport‑layer, connection‑oriented, full‑duplex protocol with features such as sequencing, acknowledgments, retransmission, flow control (sliding window), and congestion control (slow start, avoidance).

TCP Header Fields

Source Port (2 bytes): sender’s port number.

Destination Port (2 bytes): receiver’s port number.

Sequence Number (4 bytes): first byte number in this segment.

Acknowledgment Number (4 bytes): next expected byte.

Data Offset (1 byte): header length in 32‑bit words.

Reserved (1 byte): must be zero.

Flags (1 byte): control bits (URG, ACK, PSH, RST, SYN, FIN).

Window Size (2 bytes): receiver’s advertised window.

Checksum (2 bytes): header + data integrity.

Urgent Pointer (2 bytes): offset for urgent data (if URG set).

Options (variable): e.g., MSS, window scaling.

Padding (variable): align header to 32‑bit boundary.

TCP Control Flags

URG (bit 5): urgent pointer valid.

ACK (bit 4): acknowledgment field valid.

PSH (bit 3): push function, deliver data to application immediately.

RST (bit 2): reset the connection.

SYN (bit 1): synchronize sequence numbers (connection setup).

FIN (bit 0): no more data from sender (connection teardown).

TCP Three‑Way Handshake

Client → Server: SYN, seq = x.

Server → Client: SYN‑ACK, seq = y, ack = x + 1.

Client → Server: ACK, seq = x + 1, ack = y + 1. Both sides enter ESTABLISHED state.

TCP Four‑Way Termination

Client → Server: FIN, seq = x.

Server → Client: ACK, ack = x + 1.

Server → Client: FIN, seq = y.

Client → Server: ACK, ack = y + 1. Client enters TIME_WAIT, then closes; server moves to CLOSED.

IP Address Classification

A (0.0.0.0‑127.255.255.255): 8‑bit network, 24‑bit host, default mask /8.

B (128.0.0.0‑191.255.255.255): 16‑bit network, 16‑bit host, mask /16.

C (192.0.0.0‑223.255.255.255): 24‑bit network, 8‑bit host, mask /24.

D (224.0.0.0‑239.255.255.255): multicast.

E (240.0.0.0‑255.255.255.255): reserved for research.

Special ranges: 127.0.0.1 (loopback), 255.255.255.255 (broadcast), private networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16).

CIDR Example

# Calculate subnet mask and host count for 201.222.200.111/18
Subnet mask: 255.255.192.0
Host bits: 14 → 2^14 − 2 = 16382 usable hosts

Network‑Segment Determination

# Determine if 10.0.1.1/16 and 10.0.2.2/24 are in the same subnet
A network address: 10.0.0.0
B network address: 10.0.2.0
Result: different subnets; communication requires routing.
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.

LinuxstorageLVMRAID
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.