IOError: No space left on device - which device?

Deadly 提交于 2019-12-03 03:18:52
ABM

@Tom Hunt's comment was on the right track.

This unix SE answer explains what happened.

As a protection against low disc space, some daemons automatically "shadows" the current /tmp/ dir with a ram disc if the the root partition runs out of disc space. Sadly there's no automatic reversion of that process once enough disc space is free again.

I unmounted /tmp directory and followed Nitesh's suggestion:

sudo umount /tmp
sudo echo 'MINTMPKB=0' > sudo /etc/default/mountoverflowtmp

and now uploads are working properly.

If you can get a shell on the server, try typing df -h and looking for any entries which show Use% of 100%, or Avail of less than your file size.

Werkzeug stores files over a certain size in your temp directory using tempfile.TemporaryFile(), but take into account that those files are unlinked for security. You won't see them listed in the directory. tempfile.gettempdir() is the correct method of determining the directory used for this.

Your /var/tmp directory is probably configured for a smaller partition. Check with df -h to see if that partition still has enough space left. You also need to check for free inodes, with df -i.

It could also be that a process (possibly yours) is hanging on to such unlinked files too long and the space hasn't been returned to the OS yet. You can check for processes holding on to deleted files with:

lsof -nP | grep '/var/tmp' | grep '(deleted)'

or

find /proc/*/fd -ls | grep '/var/tmp' | grep  '(deleted)'

Try df -i , maybe there are no free inodes.

EDIT:

another option, find werkzeug pid, let it be 777,

  • run strace -p 777 &> /tmp/strace_log
  • try to upload a file
  • stop strace
  • find that No space left on device message, it will be like write(1, "blah blah ..."..., 57) = -1 ENOSPC (No space left on device) first argument to write is a file descriptor
  • go up and try to locate specific open(... = X syscall , that X is a file descriptor that will fail in "write" syscall step

Pretty cumbersome, I know, but that's debugging.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!