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 name | Meaning |
|---|---|
/dev/sda | Whole SATA/SCSI disk; partitions are sda1, sda2 |
/dev/nvme0n1 | NVMe disk; partitions are nvme0n1p1 |
/dev/vda | Virtio disk in a virtual machine |
/dev/mapper/vg-lv | A logical volume assembled by LVM |
/dev/loop0 | A 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 toomkfsoverwrites whatever was on the device. Confirm withlsblk -fandblkidthat 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.
-ronlvextendruns the resize for you; without it you must callresize2fsorxfs_growfsyourself.
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| Option | Effect |
|---|---|
noatime | Skip access-time writes; fewer I/Os on busy filesystems |
nofail | Boot continues when the device is missing (good for removable data) |
ro | Read-only mount; useful to recover data before repair |
nosuid / nodev / noexec | Block setuid binaries, device nodes or executables on untrusted mounts |
defaults | rw, suid, dev, exec, auto, nouser, async |
- Boot order matters:
0for no fsck,1for the root filesystem,2for everything else. - Run
sudo mount -aafter every fstab edit. A typo there can drop a server into an emergency shell on reboot. systemdturns fstab into generated mount units — inspect them withsystemctl 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.Related
Performance triage and troubleshooting Archiving, syncing and backups
Last refreshed 2026-09-18.