AKGuidebooks Home Server Admin

Linux commands

Disks and storage#

See what's there (safe)#

Command Shows
lsblk All disks and partitions as a tree
lsblk -o NAME,SIZE,MODEL,FSTYPE,MOUNTPOINTS Same, with model, format and where mounted
lsblk -f Formats, labels and UUIDs
sudo blkid UUID of every partition
findmnt Everything mounted, as a tree
cat /etc/fstab What mounts automatically at startup

Names: nvme0n1 = internal NVMe SSD, sda/sdb = USB or SATA drives, sdb1 = the first partition on sdb.

Free space#

Command Shows
df -h Size, used and free space of every mounted disk
df -h /srv/files One disk only
du -sh FOLDER Size of one folder
sudo du -sh /var/log /srv/* /home/* 2>/dev/null Size of the usual big folders
sudo du -h --max-depth=1 / 2>/dev/null | sort -h Biggest top-level folders, sorted
ncdu /srv Interactive explorer of what takes space (sudo apt install ncdu)

Mount and unmount#

Command Does
sudo mount -a Mount everything in /etc/fstab (also tests your fstab for errors)
sudo umount /srv/backup Unmount before unplugging a drive
mountpoint /srv/backup Says whether a drive is really mounted there

Commands that erase

mkfs, parted, fdisk, wipefs, dd. Only use them as Chapter 15 describes, and only after checking the drive's size and model with lsblk.

Disk health (SMART)#

sudo apt install smartmontools
sudo smartctl -H /dev/sdb          # overall health: PASSED or FAILED
sudo smartctl -a /dev/sdb          # everything
sudo smartctl -t short /dev/sdb    # start a 2-minute self-test
sudo smartctl -l selftest /dev/sdb # read test results afterwards

For the internal NVMe use /dev/nvme0n1. Some USB enclosures don't pass SMART through. If it fails, add -d sat: sudo smartctl -H -d sat /dev/sdb.

What to watch in -a: Reallocated_Sector_Ct, Current_Pending_Sector and Offline_Uncorrectable should be 0. If they grow, replace the drive.

Read speed (safe)#

sudo apt install hdparm
sudo hdparm -t /dev/sdb

USB 2 gives about 30–40 MB/s, USB 3 often 100+ MB/s.

Made by Anish · 2026