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
2
Answers
You can use the
dh
utilityit 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
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.
Check the user
.pm2/logs
directory, if your node app as errors or many regular logs this can increase disk space used.I think that 8 Go is too small. I think you should upgrade your server to allocate more space. This will solved your problem.
If you can’t or if you don’t want to add disk space, you can take a look at the
/var/log
directory to delete some extra log. On long term, you can use logrotate to compress log files and upload compressed one to another place in order to keep/var/log
as small a possible.UPDATE
Also, i am not a specialist of ubuntu and snap, but your /snap directory is 2,1Go in size. You can check this to see if snap retain old version of snap package or if there is some cache that can be cleared.
Here is a bash script to remove old snaps version that i find here : https://www.debugpoint.com/clean-up-snap/
You can also delete files in
/var/lib/snapd/cache
it’s a snap cache that can be cleared.But as i say, not a specialist of Ubuntu, so not tested.