Search code examples
perldiskspace

How can I find the free space available on mounted points?


I have raised this question previously but none of the solutions work on the mounted points. Neither du nor df work on the mounted points. Is there a way to find it out?


Solution

  • I don't understand what you mean by "doesn't work on the mount points". Change into the directory where you want to untar (if not already there) and execute:

    df . | grep -v '^Filesystem' | awk 'NF=6{print $4}NF==5{print $3}{}'
    

    The grep gets rid of the header and the awk prints out the kilobytes available for both split and no-split lines.

    This is based on the following sort of output, you may have to adjust if your UNIX outputs something different:

    Filesystem    1K-blocks      Used  Available  Use%  Mounted on
    /dev/sda4     206434224  56965356  139065176   30%  /
    varrun          1037296       132    1037164    1%  /var/run
    varlock         1037296         0    1037296    0%  /var/lock
    udev            1037296        68    1037228    1%  /dev
    devshm          1037296        12    1037284    1%  /dev/shm
    /dev/sda2         93327     43535      44973   50%  /boot
    /dev/sdc1     155056484  29417456  117824612   20%  /media/extra160
    gvfs-fuse-daemon
                  206434224  56965356  139065176   30%  /home/pax/.gvfs