Linux Mastery

The Human Knowledge Project


CHAPTER 3 — DISKS, STORAGE, PARTITIONS & PACKAGING

Why This Chapter Matters

Every file you save, every program you install, and every operating system you run depends on storage.

Understanding how Linux organizes disks, partitions, and filesystems will help you install Linux, manage data safely, troubleshoot storage problems, and make informed decisions about your computer.

In this chapter, you'll build the mental model needed to understand how Linux stores and retrieves information.


WHAT IS STORAGE

Storage is the long-term memory of a computer. Unlike RAM, which loses its contents when power is removed, storage retains information even after the computer is turned off.

Storage is where Linux keeps:

✔ operating system files

✔ programs

✔ user data

✔ logs

✔ configuration files

Examples


HOW LINUX SEES DISKS

Linux treats hardware devices as files.

This is one of Linux's most elegant design principles. By representing devices as files, Linux provides a consistent way for programs to interact with hardware.

Examples


WHAT IS A PARTITION

A partition is a logical division of a physical disk.

Example:

A single disk may contain:

/dev/sda1

/dev/sda2

/dev/sda3

Each partition may contain:

✔ an operating system

✔ user data

✔ swap space

✔ backup storage


WHY PARTITIONS EXIST

Partitions allow a single physical disk to be divided into independent sections, each serving a different purpose.

Partitions solve several practical problems and make a computer easier to manage.

✔ organize storage

✔ separate data

✔ support multiple operating systems

✔ improve recovery and management


FILESYSTEMS

A filesystem determines how data is organized on storage.

Common filesystems:

ext4

xfs

ntfs

fat32

Linux commonly uses ext4.


FORMATTING

Formatting creates a filesystem on a partition.

Example:


sudo mkfs.ext4 /dev/sdb1

WARNING:

Formatting destroys existing data.


MOUNT POINTS

Linux does not use drive letters like Windows.

Instead, partitions are attached to directories called mount points.

Example:

/dev/sdb1 mounted at:

/home/norm/STORAGE_250


VIEW STORAGE DEVICES


lsblk

VIEW PARTITIONS


sudo fdisk -l

VIEW STORAGE USAGE


df -h

MOUNT A DRIVE


sudo mount /dev/sdb1 /mnt

UNMOUNT A DRIVE


sudo umount /dev/sdb1

AUTOMATIC MOUNTING

Linux uses:

/etc/fstab

to automatically mount drives during boot.


WHAT IS A PACKAGE

A package is a bundled piece of software.

A package may contain:

✔ program files

✔ libraries

✔ configuration files

✔ metadata


PACKAGE MANAGERS

Linux distributions use package managers.

Examples


WHY PACKAGES MATTER

Packages:

✔ simplify installation

✔ manage dependencies

✔ improve security

✔ allow centralized updates


INSTALL SOFTWARE


sudo apt install package_name

Example:


sudo apt install htop

REMOVE SOFTWARE


sudo apt remove package_name

DEPENDENCIES

Programs often require supporting libraries called dependencies.

Package managers install these automatically.


WHERE PROGRAMS ARE STORED

/usr/bin

/usr/lib

/etc


MENTAL MODEL

Disk

→ Partition

→ Filesystem

→ Mount Point

→ Files & Programs


END OF CHAPTER 3