9

I have an EC2 instance and when I log in I get

mktemp: failed to create file via template '/tmp/.colorlsXXX': No space left on device

However when I do df -h I see

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      7.8G  4.2G  3.5G  55% /
devtmpfs        812M   16K  812M   1% /dev
tmpfs           828M     0  828M   0% /dev/shm

Doing df -i gives me

/dev/xvda1     524288 524288      0  100% /
devtmpfs       207790    414 207376    1% /dev
tmpfs          211891      1 211890    1% /dev/shm

What's going on here?

2
  • 1
    Edit your question and post the output of df -i.
    – EEAA
    Oct 2, 2014 at 19:07
  • @EEAA updated with the output you wanted
    – Kyle Decot
    Oct 2, 2014 at 19:11

2 Answers 2

19

You have exhausted all of the inodes available on your filesystem. You likely have a directory somewhere with a metric crap-ton of tiny files. You'll need to locate that directory and remove some of the files.

To search which folder of your server is eating the inode limit, you can run this command:

find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -nr

Command taken from here

6
  • Sure thing - a lot of people forget (or didn't even know) that inodes are a thing.
    – EEAA
    Oct 2, 2014 at 20:57
  • 1
    "Metric crap-ton"! ;-)
    – Sabuncu
    Dec 13, 2014 at 10:16
  • And how exactly would one find that directory?
    – Andy
    Feb 17, 2015 at 10:14
  • 3
    I think you mean "metric crap-tonne". The crap-ton is the old Imperial measure, being approximately 1.016 crap-tonnes.
    – MadHatter
    Nov 7, 2015 at 9:53
  • @MadHatter Ha! Thank you for schooling me on these old archaic measures.
    – EEAA
    Nov 7, 2015 at 13:58
1

This error occurred to me while trying to install ubuntu-desktop as instructed by AWS knowledge-center.

Then I found here how to find all those directories with huge number of tiny files:

for i in /*; do count=`sudo find $i | wc -l`; if [ $count -gt 10000 ]; then echo $i $count; fi; done

/lib 18982
/proc 35223
/sys 36490
/usr 253941
/var 14584

Run it again for each suspicious sub-directory (for me it was hidden under /usr/*).

But before you remove those sub-directories with rm -rf (if you're absolutely sure!), try to safely remove Linux packages that were installed by other packages, but are no longer needed:

sudo apt-get -f install
sudo apt-get autoremove

Run df -i again to see if you have more space now.

3
  • "Cryptic" directories? en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
    – ceejayoz
    Aug 28, 2017 at 13:05
  • They're not hidden, either.
    – ceejayoz
    Aug 28, 2017 at 13:09
  • They're not hidden, cryptical, mysterious, etc. They're on every Linux and OSX distribution, they're extensively documented, and known to anyone with even a few hours of Linux sysadmin knowledge. (It's also the wrong answer, per OP's acceptance of the inode exhaustion explanation.)
    – ceejayoz
    Aug 28, 2017 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.