Disks, filesystems and mounts

Block devices, partitions, mkfs, fstab entries by UUID, and extending a volume without losing data.

Seeing what you have

lsblk -f                    # tree of disks, partitions, filesystems, UUIDs
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
blkid                       # UUID and filesystem type per device
df -h                       # space per mounted filesystem
df -i                       # inode usage - full inodes look like a full disk
du -sh /var/log/* | sort -h | tail

findmnt /                    # where a mount came from and with which options
mount | column -t
Device nameMeaning
/dev/sdaWhole SATA/SCSI disk; partitions are sda1, sda2
/dev/nvme0n1NVMe disk; partitions are nvme0n1p1
/dev/vdaVirtio disk in a virtual machine
/dev/mapper/vg-lvA logical volume assembled by LVM
/dev/loop0A file used as a block device, common for snaps
💡
Device names are not stable. /dev/sdb becomes /dev/sda after a reboot or a cable change, so anything persistent — especially /etc/fstab — must reference a UUID= or LABEL=, never the device path.

Partitioning, formatting and LVM

# inspect first, always
sudo fdisk -l /dev/sdb
lsblk /dev/sdb

sudo parted -s /dev/sdb mklabel gpt
sudo parted -s /dev/sdb mkpart primary ext4 0% 100%
sudo partprobe /dev/sdb

sudo mkfs.ext4 -L data /dev/sdb1
sudo mkfs.xfs /dev/sdb2

# XFS cannot shrink, so plan sizes before you format
sudo xfs_growfs /mount/point
# LVM: grow a filesystem later without downtime
sudo pvcreate /dev/sdc
sudo vgcreate vgdata /dev/sdc
sudo lvcreate -L 20G -n app vgdata
sudo mkfs.ext4 /dev/vgdata/app

# later, after adding a disk
sudo pvcreate /dev/sdd
sudo vgextend vgdata /dev/sdd
sudo lvextend -r -l +100%FREE /dev/vgdata/app    # -r resizes the filesystem too
  • mkfs overwrites whatever was on the device. Confirm with lsblk -f and blkid that the target holds nothing and is not mounted.
  • ext4 can grow and shrink; XFS can only grow. That decides which one you put on a volume you may need to reduce.
  • -r on lvextend runs the resize for you; without it you must call resize2fs or xfs_growfs yourself.

Mounts and fstab

sudo mkdir -p /srv/data
sudo mount /dev/vgdata/app /srv/data

# /etc/fstab - UUID based, with sensible options
UUID=7f3c-9a11  /srv/data  ext4  defaults,noatime,nofail  0  2

sudo mount -a          # test fstab NOW, before rebooting
sudo systemctl daemon-reload

sudo umount /srv/data
sudo umount -l /srv/data     # lazy: detach when nothing uses it
fuser -m /srv/data           # who is holding the mount open
sudo mount -o remount,rw /srv/data
OptionEffect
noatimeSkip access-time writes; fewer I/Os on busy filesystems
nofailBoot continues when the device is missing (good for removable data)
roRead-only mount; useful to recover data before repair
nosuid / nodev / noexecBlock setuid binaries, device nodes or executables on untrusted mounts
defaultsrw, suid, dev, exec, auto, nouser, async
  • Boot order matters: 0 for no fsck, 1 for the root filesystem, 2 for everything else.
  • Run sudo mount -a after every fstab edit. A typo there can drop a server into an emergency shell on reboot.
  • systemd turns fstab into generated mount units — inspect them with systemctl list-units '*.mount'.

FAQ

df says the disk is full but du finds nothing?
A process is holding a deleted file open. Nothing frees until it closes: find it with lsof +L1, then restart or signal that process.
How do I extend a partition on a disk I already resized in the hypervisor?
Grow the partition (growpart or parted resizepart), then grow the filesystem (resize2fs for ext4, xfs_growfs for XFS). With LVM, extend the PV, LV and filesystem in that order.

Performance triage and troubleshooting Archiving, syncing and backups

Last refreshed 2026-09-18.