Storage, filesystems and mounts
Find disks, format and mount them, and make mounts survive a reboot without breaking boot.
lsblk -f # devices, filesystems, UUIDs and mount points
blkid # UUID of each filesystem
findmnt # what is mounted whereAdding a disk
sudo mkfs.ext4 /dev/sdb1 # DESTROYS existing data on sdb1
sudo mkdir -p /data
sudo mount /dev/sdb1 /dataCarefulmkfs erases the partition. Check the device name twice with lsblk before you run it. Writing to the wrong disk is unrecoverable.
Make it persistent: /etc/fstab
# /etc/fstab
UUID=3f2b1c9e-8a74-4f0a-9d5b-0c1e2a7b5d11 /data ext4 defaults,nofail 0 2- Use the UUID, not
/dev/sdb1. Device names can change between boots. nofaillets the system boot even when the disk is missing.- The last number orders filesystem checks at boot (
2for non-root). - Test with
sudo mount -abefore you reboot. A broken line can stop the boot.
LVM in one paragraph
LVM adds a layer between disks and filesystems. Physical disks become physical volumes (PV), are pooled in a volume group (VG) and are cut into logical volumes (LV) that you can grow while mounted: lvextend -r -L +10G /dev/vg0/data extends the volume and its filesystem.
NoteRAID and LVM are not backups. A deleted file is deleted on every copy. Keep separate backups and test restoring them.
Test yourself
Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.