How do I clear space on my main system drive on a Linux CentOS system?

Sorry if this sounds dumb, but I'm not sure what to do.

I've got an Amazon EC2 instance with a completely full Ephemeral drive ( the main drive with all the system files ). Almost all the directories where I've installed things like Apache, MySQL, Sphinx, my applications, etc. are on a separate physical drive and have symlinks from the ephemeral drive. As far as I am aware, none of thier data or logs write to the ephemeral drive, so I'm not sure what happened to the space.

Obviously lots of system stuff is still on the ephemeral drive, but I'm not sure how to clear things off to make space. My best guess is that amazon filled the drive when it did some auto updates to the system. I'm trying to install some new packages, and update all my system packages via YUM, but the drive has no space.

What should I do?


du --max-depth=1 -h /

where / can be any directory starting from root will show you the size in human readable form (-h) without further recursing further down.

Once you find something big that you want to remove you can do it via

rm <thing you want to remove>

this accepts shell expansion, so for instance to remove all mp3 files:

rm *.mp3      

if it's a directory then you need to add -r

rm -r /dir/to/remove

to protect yourself it would be advisable to add the -i switch to every rm call, this forces you to acknowledge that you want the files removed.

if there are a lot of readonly files you want to remove then you could add the -f switch to force deletion, be very careful with this.

Be careful that rm accepts multiple parameters so when you specify an absolute path make sure to do it within quotes or not to have any spaces, especially should you execute it as root and super especially with the -r and -f options. (otherwise you'll join the group of people that did rm -rf / some/directory/* and killed their / inadvertantly)

If you just want to look for big files and delete those then you could also use find

find / -type f -size +100M

would search for files only (-type f) with a size > 100MB (-size +100M)

subsequently you could use the same command to delete them.

find / -type f -size +100M -exec rm \{\} \;

-exec executes a program which gets passed the file or folder it has found ( \{\} ), needs to be terminated with \;

don't forget you could add -i to rm to approve or disapprove a deletion.

You can use the unix disk utility command du to see what's taking up all the space for starters.

This works great. Can take a few minutes on bigger drives ( over a few hundred GB ):

find /directory/to/scan/ -type f -exec du -a {} + | sort -n -r | less

The output will be the biggest files first. You can page through the results with normal "less" commands ... space bar ( next page ) and b ( previous page ).

Need Your Help

twig filter multiple parameters

php symfony twig twig-filter

I'm trying to create a specific twig filter that can handle 2 parameters.

How does using statement scope work when using Stream's created from other Stream's?

c# .net stream using

I have a situation in which I am using multiple streams to download a zipped file via http. To do so I need to use multiple streams. I.e. get a web response stream, read into a binary reader stream,