0 votes
1 view
in AWS by (19.2k points)

When I run df -h on my Amazon EC2 server, this is the output:

[[email protected] ~]$ df -h

Filesystem     Size Used Avail Use% Mounted on

/dev/xvda1     25G  25G     0  100% /

tmpfs         4.0G    0  4.0G    0% /dev/shm

for some reason, something is eating up my storage space.

I'm trying to find all of the big files/folders and this is what I get back:

[[email protected] ~]$ sudo du -a / | sort -n -r | head -n 10

993580  /

639296  /usr

237284  /usr/share

217908  /usr/lib

206884  /opt

150236  /opt/app

150232  /opt/app/current

150224  /opt/app/current/[deleted].com

113432  /usr/lib64

How can I find out what's eating my storage space?

1 Answer

0 votes
by (44.6k points)

Well, I think it's one (or more) logfiles which have grown too large and need to be removed/backupped. My suggestion is to go for the big files first. To find all files greater than 10 MB (10 MB is a big enough file size, you can choose +1M for 1MB similarly)

sudo find / -type f -size +10M -exec ls -lh {} \;

and now you can identify which ones are causing the trouble and deal with them accordingly.

As for your original du -a / | sort -n -r | head -n 10 command, that won't work since it is sorting by size, and so, all ancestor directories of the large file will go up the pyramid, while the individual files will most probably be missed.

It should be pretty simple to notice the occurrence of similar other log files/binaries in the location of the files you so find, so as a suggestion, do cd into the directory containing the original file to clean up more files of the same kind. You can also iterate with the command for files with sizes greater than 1MB next, and so on.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...