$ command-helper

Linux: disks and filesystems

Finding disks, formatting and mounting, fstab, growing a volume after resize, LVM and disk health.

Requires Google sign-in

Looking around

Disks, partitions and mount points
lsblk -f
Filesystem UUIDs (for fstab)
sudo blkid
Where is what mounted
findmnt
Disk I/O per device every 2 secondsadvanced
iostat -xz 2

New disk

Create a filesystem
sudo mkfs.ext4 /dev/<device>

Destroys any data on the device — check the name with lsblk first.

Mount it
sudo mkdir -p /data && sudo mount /dev/<device> /data
Mount on boot (fstab)
UUID=<uuid>  /data  ext4  defaults,nofail  0  2

nofail keeps the server booting if the disk is missing. Test with sudo mount -a before rebooting.

Unmount; who keeps it busy
sudo umount /data || sudo lsof +f -- /data

Growing a volume (e.g. after EBS resize)

Grow the partition
sudo growpart /dev/<disk> 1
Grow an ext4 filesystem
sudo resize2fs /dev/<device>
Grow an XFS filesystem (by mount point)
sudo xfs_growfs /data

LVM

Physical volumes, groups, logical volumes
sudo pvs && sudo vgs && sudo lvs
Add a disk to a volume groupadvanced
sudo pvcreate /dev/<device> && sudo vgextend <vg> /dev/<device>
Extend a logical volume and its filesystemadvanced
sudo lvextend -r -l +100%FREE /dev/<vg>/<lv>

Health

SMART status of a diskadvanced
sudo smartctl -a /dev/<disk>
Check a filesystem (unmounted!)advanced
sudo fsck -f /dev/<device>