0

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.

1 Answer 1

1

From the man page of df(1):

df [OPTION]... [FILE]...
...
Show  information  about the file system on which each FILE resides, or
all file systems by default.
...

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.

1
  • As a basic rule - use the "Mounted on" value rather than the "Filesystem" for using with df
    – Evengard
    Aug 18, 2015 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .