1753386 Members
5757 Online
108792 Solutions
New Discussion юеВ

Re: Disk Usage

 
SOLVED
Go to solution

Disk Usage

Hi there,

What is is the best way to determine how much disk space is used (in kb or mb, not blocks) in a filesystem? I have been moving files around over the weekend and I need to make sure they will all fit on their DLT tapes.

Cheers,

Christian Briddon
7 REPLIES 7
Mark van Hassel
Respected Contributor
Solution

Re: Disk Usage

Hi,

You can use bdf or df -k to get a file system usage overview. Alternatively you can use du -k on directories, files etc.

See man pages for more info.

HtH,

Mark
The surest sign that life exists elsewhere in the universe is that none of it has tried to contact us
John Strang
Regular Advisor

Re: Disk Usage

Use du -sk

This gives Disk Usage in kb. If you want more detailed information for the filesystem you can omit the 's' flag.

HTH,

John
If you never make a mistake you'll never make anything.
Justo Exposito
Esteemed Contributor

Re: Disk Usage

Hi,

You can use bdf and then the result are in bytes.

If you use du command the result are in 512 bytes blocks.

Regards,

Justo.
Help is a Beatiful word
Magdi KAMAL
Respected Contributor

Re: Disk Usage

Hi,

You may use the command :

# df -k

for displaying all used and free spaces on file-systems in Kilo-Bytes.

or

# df -k

for displaying only a specific directory used and free spaces on a file-system in Kilo-Bytes.

Then calculate the total amount to check if it stand on DLTs.

Magdi
Roger Baptiste
Honored Contributor

Re: Disk Usage

hi,

Clean way is , put this in a script file, say neat-bdf:
****
/bin/bdf "$@" 2>&1 | awk ' { if(NF == 1) { getline n; sub("^[ ]*", " ", n); print $0" "n; next } }
{ print }'
****

and execute it:

#neat-bdf >bdf.out

that will give the sizes of each filesystem in a single line in kbs


HTH
raj
Take it easy.
Heiner E. Lennackers
Respected Contributor

Re: Disk Usage

Hi,

if you like to use du or bdf, i would prefer to use du -sk rather then
bdf -kl . Two reasons:
1. If you backup only subdirs of a filesystem, bdf -kl will not match at all because it only shows complete filesystems.
2. bdf -kl does not count the size a sparse file will use on tape.

But even du does not count real bytes, because it is block-aligned. If you need the exact size you can use ll or find and ll to add them up.

Heiner


if this makes any sense to you, you have a BIG problem
Trond Haugen
Honored Contributor

Re: Disk Usage

bdf will tell you the kilobyte usage of a mounted filesystem.
If you only want a certain tree of it you can use 'du -k /dir' to get Kb.
Here is a small script I have written to better display larger figures (Mb, Gb):

du_it()
{
bytes=`du -s | cut -f1 -d" "`

if [ $bytes -le 999999 ]
then
bytes=`expr $bytes \* 512`
kbytes=`expr $bytes \/ 1000`
else
kbytes=`expr $bytes \/ 2`
fi

if [ $kbytes -gt 999 ]
then
mbytes=`expr $kbytes \/ 1000`
xbytes=`expr $mbytes \* 1000`
kbytes=`expr $kbytes - $xbytes`
if [ $kbytes -le 10 ]
then
kbytes="00$kbytes"
fi

if [ $kbytes -le 100 ]
then
kbytes="0$kbytes"
fi

if [ $mbytes -gt 999 ]
then
gbytes=`expr $mbytes \/ 1000`
xbytes=`expr $gbytes \* 1000`
mbytes=`expr $mbytes - $xbytes`
if [ $mbytes -le 10 ]
then
mbytes="00$mbytes"
fi

if [ $mbytes -le 100 ]
then
mbytes="0$mbytes"
fi
echo "In `pwd`\t you have used $gbytes,$mbytes Gbytes."

else

echo "In `pwd`\t you have used $mbytes,$kbytes Mbytes."
fi
else
echo "In `pwd`\t you have used $kbytes Kbytes."
fi
}

if [ $# -gt 0 ]
then
startdir=`pwd`
for dirs in $*
do
if [ -d "$dirs" ]
then
cd $dirs
du_it
fi
cd $startdir
done
else
du_it
fi

Regards,
Trond
Regards,
Trond Haugen
LinkedIn