I have a script that monitors various unix servers, and one of the things it does is check the free disk space using df -m /dev/whatever. I've run into a problem with a CentOS 7 server that I've been asked to monitor. If I run df -m I get:
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 51175 5434 45742 11% /
devtmpfs 1884 0 1884 0% /dev
tmpfs 1893 0 1893 0% /dev/shm
tmpfs 1893 9 1885 1% /run
tmpfs 1893 0 1893 0% /sys/fs/cgroup
/dev/sda1 497 119 379 24% /boot
/dev/mapper/centos-home 202086 33 202054 1% /home
I only want to check the free space on the main file system /dev/mapper/centos-home. But if I run df -m /dev/mapper/centos-home I get:
Filesystem 1M-blocks Used Available Use% Mounted on
devtmpfs 1884 0 1884 0% /dev
I freely admit I don't know a lot about unix (my background is Windows) and I'm probably making some basic error. However if someone would tell me why df -m /dev/mapper/centos-home is giving me the stats for the wrong file system I'd be very grateful. Even more so if you can tell me how to fix the problem.
The technique I've used does work on all the other flavours of unix I've tried including QNAP and Synology NASes.
From the man page of df(1):
You're giving df the FILE argument of '/dev/mapper/centos-home' which resides on the '/dev' file system. Use 'df /' for the device on which the '/' file system resides.