6.8 Disk and Storage Commands
df -h # disk space per mounted filesystem (human readable)
df -Th # include filesystem type (xfs, ext4)
sudo du -sh /var/log # total size of a folder
sudo du -h --max-depth=1 /var | sort -h # which sub-folder is big?
lsblk # block devices (disks & partitions) as a tree
lsblk -f # with filesystem type, UUID and mount point
sudo blkid # UUIDs of all filesystems
findmnt / # what is mounted at /
sudo mount /dev/nvme1n1 /data
sudo umount /data
cat /etc/fstab # permanent mounts (read at boot)
free -h # memory
Ravindra Bagale's Tip
When the disk is 100% full, MySQL and Nginx give strange errors, and many students sit searching for the problem in their code. Whenever something strange happens, check df -h first. To find the big folders, use du -h --max-depth=1 | sort -h.
Ravindra Bagale's Tip – मराठी
Disk 100% भरला की MySQL आणि Nginx विचित्र errors देतात आणि बरेच students code मध्ये problem शोधत बसतात. काही विचित्र झालं की आधी df -h बघा. मोठा folder शोधायला du -h --max-depth=1 | sort -h.
Ravindra Bagale's Tip – हिंदी
Disk 100% भरने पर MySQL और Nginx अजीब errors देते हैं और बहुत से students code में problem ढूँढते रहते हैं. कुछ भी अजीब हो तो पहले df -h देखो. बड़ा folder ढूँढने के लिए du -h --max-depth=1 | sort -h.
Practice task
Show free disk space, the size of /var/log, the three largest folders under /var, and the block devices with lsblk -f.