Search code examples
node.jsamazon-web-servicesamazon-ec2pm2

Error: ENOSPC: no space left on device, write pm2 server


I am not able to identify what is causing my ec2 disk space to reach 100% of capacity. I have a script which deletes files in tmp folder.But still randomly sometimes my disk capacity reaches 100%. I have attached the logs of df -i to show disk utilization.

Error

PM2        | Error: ENOSPC: no space left on device, write
PM2        |     at Object.writeSync (fs.js:679:3)
PM2        |     at Object.writeFileSync (fs.js:1393:26)
PM2        |     at ProcessContainer (/usr/lib/node_modules/pm2/lib/ProcessContainer.js:70:10)
PM2        |     at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainer.js:103:3)
PM2        |     at Module._compile (internal/modules/cjs/loader.js:999:30)

I am using command df -i to find [![enter image description here][1]][1]

[![enter image description here][2]][2]

du -h -d 1


Solution

  • You can use the dh utility

    cd /
    du -h -d 1
    

    it will show the disk usage for every folder in /, then you can cd in the biggest ones and repeat the same.

    You can also run

    du | sort -n
    

    and you'll get (after a while) all the folders size in the filesystem (ordered by ascending size). By my experience I'd take a first look at /home, /tmp and /var.