AKIWEB
AKIWEB

Reputation: 19612

Find the size of directory in unix

Problem Statement:-

I am getting this below exception-

org.apache.hadoop.hdfs.protocol.DSQuotaExceededException:
org.apache.hadoop.hdfs.protocol.DSQuotaExceededException: The DiskSpace 
quota of /tmp is exceeded: quota=659706976665600 diskspace consumed=614400.1g

So I just wanted to know how much is the size of /tmp directory currently and because of that I am getting this exception. How can I see the free space in /tmp?

Update:-

bash-3.00$ df -h /tmp
Filesystem             size   used  avail capacity  Mounted on
rpool/tmp               10G   2.2G   7.8G    22%    /tmp

I am puzzled right now why I am getting that exception then as it clearly states above that I have space available.

Upvotes: 5

Views: 38498

Answers (3)

PANDURANG BHADANGE
PANDURANG BHADANGE

Reputation: 69

Managing HDFS Space Quotas It’s important to understand that in HDFS, there must be enough quota space to accommodate an entire block. If the user has, let’s say, 200MB free in their allocated quota, they can’t create a new file, regardless of the file size, if the HDFS block size happens to be 256MB. You can set the HDFS space quota for a user by executing the setSpace-Quota command. Here’s the syntax:

$ hdfs dfsadmin –setSpaceQuota <N> <dirname>...<dirname>

The space quota you set acts as the ceiling on the total size of all files in a directory. You can set the space quota in bytes (b), megabytes (m), gigabytes (g), terabytes (t) and even petabytes (by specifying p—yes, this is big data!). And here’s an example that shows how to set a user’s space quota to 60GB:

$ hdfs dfsadmin -setSpaceQuota 60G /user/alapati

You can set quotas on multiple directories at a time, as shown here:

$ hdfs dfsadmin -setSpaceQuota 10g /user/alapati /test/alapati

Upvotes: 0

pkm
pkm

Reputation: 2783

for a in ls; do du -ch ${a} | grep total ; echo ${a}; done

try this but it takes time if the size of dir is in GBs

Upvotes: 1

favoretti
favoretti

Reputation: 30167

You can do (For SunOS)

# du -sh /tmp

To see how much it uses now, but that you already saw.

To see how much total, free and used space is on the partition where /tmp resides you can use:

# df -h /tmp

Note that filling up space is not the only thing that can prevent writing to filesystem.

Running out of inodes is another popular reason.

You can check that with

# df -i /tmp

Upvotes: 12

Related Questions