Understanding LINUX drives, partitions, volumes, file systems
A unformatted disk drive is like a warehouse, like a big empty room.
If the disk drive has one partition, think of the disk drive as a warehouse with one single room … a big empty room
If the disk drive has several partitions — think of each partition like a warehouse with several rooms … several big empty rooms.
Linux Disk Drives (/dev/sda), and partitions (/dev/sda2)
$ lsblk
We see two disk drives >>> think warehouseA and warehouseB
sda and sdb: literally “scsi device a” and “scsi device b”
We see see two partitions on /dev/sda (two big empty rooms)
/dev/sda1 >>> think warehouseA-room1
/dev/sda2 >>> think warehouseA-room2
We see one partition on /dev/sdb >>> think warehouseB (one big empty room.
Empty disk drives are laid out in blocks (each 4KB).
File systems keeps track of what data is on what block(s).
Filesystems — here I make a filesystem on /dev/sdb
(yes it erases all pre-existing data, use with care).
the warehouse analogy — Filesystems are like numbered shelves in your warehouse and the file system keeps track of what stuff is on what shelf.
— — foo.txt is block 44–66 in /dev/sda — — using the warehouse metaphor — its stored on shelves 44–66 in warehouseA (this is single partition, only one room in the warehouse)
— — foo.txt is block 44–66 in /dev/sda1 — — using the warehouse metaphor — its stored on shelves 44–66 in warehouseA/room1 (multiple partition, multiple warehouse rooms)
once we have a device with a file system, we store the operating system, and reboot, login, install some software, store some data.
try it for yourself. find a spare hard drive or ssd. plug it into your linux system.
$ lsblk — — shows devices
$ mkfs /dev/sdb — type=ext4 — formats device /dev/sdb with ext4 filesystem
$ mkdir /mnt3
$ mount /dev/sdb /mnt3
$lsblk shows sdb >> 240GB >> /mnt3
$df /mnt3 (diskfull) shows 240GB
we have sorted out disks, partitions, volumes, filesystems ::: hurray!!