Skip to content

Storage

Computer storage is broadly divided into two categories:

  • Primary storage (RAM, cache) - fast but volatile; lost on power off
  • Secondary storage (HDDs, SSDs, cloud) - persistent, slower, permanent

TypeKey Characteristics
SATAReplaced IDE; 7-pin cable; native hot-swap; seen as SCSI device
SCSI8-16 bit bus; 5-160 MB/s; multiple versions (Fast, Wide, Ultra)
SASPoint-to-point serial; better performance than SATA; preferred for servers
USBFlash drives, floppies; treated as SCSI devices
SSDNo moving parts; lower power; faster transfers; dropping in price; pairs well with rotational drives
IDE/EIDEObsolete

Rotational disks are made of platters read by heads that scan circular tracks, divided into sectors (traditionally 512 bytes; 4 KB is now standard). A cylinder is the set of the same track across all platters.

Terminal window
# Inspect physical vs logical sector size
sudo fdisk -l /dev/sdc | grep -i sector
# Sector size (logical/physical): 512 bytes / 4096 bytes
ArchitectureProtocolCharacteristics
DAS (Direct Attached Storage)Block (direct cable)Fast, reliable, affordable; dedicated to one host; good for small businesses
NAS (Network Attached Storage)NFS/CIFS over ethernetShared file storage; reasonably fast; not suitable for OS installs
SAN (Storage Area Network)Fibre Channel or iSCSIBlock storage over network; fast, highly available, redundant; expensive

DAS NAS SAN


A partition is a physically contiguous section of a disk. Separating storage into partitions provides:

  • Isolation: a runaway log file on /var won’t fill up / and crash the OS
  • Security: different permissions, quotas, and mount options per partition
  • Performance: put frequently-used data on faster media
  • Multi-OS support: each OS on its own partition
  • Easier backups: separate /home or /data can be snapshotted independently
  • Swap isolation: keep swap separate from data

A common minimal layout:

PartitionPurpose
/bootKernel and bootloader files (usually 500 MB - 1 GB)
/ (root)OS and core directories
swapVirtual memory overflow; also used for hibernation
/homeUser files (separate partition for easy re-install)

Partition types

TypeDescription
PrimaryDirectly bootable; max 4 per disk under MBR
ExtendedContainer used to hold Logical Partitions; not directly usable as storage; overcomes MBR’s 4-partition limit
LogicalLives inside an Extended partition; numbered from 5+ (e.g., /dev/sda5)
FeatureMBRGPT
Max partitions4 primary (+ logical inside extended)128 primary (default)
Max disk size2 TB8 ZiB (theoretical)
Partition sizeUp to 2 TBUp to 9.4 ZB
RedundancySingle table in sector 0Two copies (start + end of disk)
Boot modeBIOS/LegacyUEFI (also supports legacy via Protective MBR)

The MBR occupies the first 512 bytes of a disk:

  • Bytes 0-445: boot loader code
  • Bytes 446-509: partition table (4 x 16-byte entries)
  • Bytes 510-511: magic number 0x55AA (end-of-sector marker)

Each 16-byte partition entry contains: active bit, CHS start/end (ignored by Linux), partition type code, LBA start sector, sector count. Linux uses LBA for all addressing.

GPT uses a Protective MBR in sector 0 (for backward compatibility), followed by the GPT header and partition entries. The partition table is also copied to the end of the disk, providing redundancy. If the primary header is corrupted, the backup is used to recover.

Terminal window
# Show partition table layout and type
sudo fdisk -l /dev/sda # MBR or GPT
sudo gdisk -l /dev/sda # GPT-specific details
sudo parted /dev/sda print # works with both
RAMTraditional Recommendation
< 2 GB2x RAM
2-8 GBEqual to RAM
> 8 GBAt least 4 GB; consider 1x RAM if hibernation needed

Linux exposes storage as device nodes under /dev. The naming convention:

/dev/sd[a-z][1-15] # SATA, SCSI, USB drives
/dev/nvme[0-9]n[1-9] # NVMe SSDs (namespace-based)
/dev/hd[a-d] # Old IDE drives (obsolete)
/dev/vd[a-z] # Virtio virtual drives (VMs)
/dev/mmcblk[0-9] # SD cards, eMMC

Examples:

DeviceMeaning
/dev/sdaFirst SATA/SCSI disk
/dev/sdbSecond SATA/SCSI disk
/dev/sdb1First partition on second disk
/dev/sdc4Fourth partition on third disk
/dev/nvme0n1First NVMe drive, first namespace
/dev/nvme0n1p1First partition on above
FeatureBlock DeviceCharacter Device
AccessRandom-access, seekableSequential, byte-by-byte
BufferingCan be cached in page cacheImmediate - no kernel buffering
Examples/dev/sda, /dev/nvme0n1/dev/tty, /dev/urandom, /dev/null
Major:MinorIdentifies driver type : specific deviceSame scheme

Each device has a Major number (identifies the driver) and Minor number (identifies the specific device instance). Visible with ls -l /dev:

Terminal window
ls -l /dev/sda
# brw-rw---- 1 root disk 8, 0 Mar 2 19:00 /dev/sda
# ^ ^
# major minor

Terminal window
lsblk # tree view of all block devices and mount points
lsblk -f # include filesystem type, UUID, label
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,UUID
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 1G 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 463.8G 0 part /home
nvme0n1 259:0 0 476.9G 0 disk
└─nvme0n1p1 259:1 0 476.9G 0 part /
zram0 251:0 0 8G 0 disk [SWAP]

blkid identifies the contents of block devices (filesystem type, UUID, label) by reading metadata fingerprints from the device.

Terminal window
sudo blkid # show all devices
sudo blkid /dev/sda1 # specific device
sudo blkid -U "uuid-here" # find device by UUID
sudo blkid -L "mylabel" # find device by label
sudo blkid -t TYPE=ext4 # find all ext4 devices
Terminal window
# GPT system example
sudo blkid /dev/sda1
# /dev/sda1: UUID="53ea9807-fd58-4433-9460-d03ec36f73a3" TYPE="ext4"
# PARTUUID="0c79e35b-e58b-4ce3-bd34-45651b01cf43"

Key attributes:

  • UUID: Identifies the filesystem on the partition. Changes when you reformat.
  • PARTUUID: Identifies the partition itself (GPT only). Stays same even after reformat.
  • LABEL: Human-readable name assigned at format time.
Terminal window
sudo fdisk -l # list all disks and partitions
sudo fdisk -l /dev/sda # specific disk
sudo fdisk /dev/sdb # interactive: create/delete/type partitions
Terminal window
df -h # disk usage of mounted filesystems (human-readable)
df -Th # include filesystem type
df -i # show inode usage instead of block usage
du -sh /var/log # size of a directory
du -sh /* 2>/dev/null | sort -h # find largest top-level directories