Linux: disks and filesystems
Finding disks, formatting and mounting, fstab, growing a volume after resize, LVM and disk health.
Looking around
Disks, partitions and mount points
lsblk -fFilesystem UUIDs (for fstab)
sudo blkidWhere is what mounted
findmntDisk I/O per device every 2 secondsadvanced
iostat -xz 2New 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 -- /dataGrowing 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 /dataLVM
Physical volumes, groups, logical volumes
sudo pvs && sudo vgs && sudo lvsAdd 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>