skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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/

    #!/bin/bash
     #Removes old revisions of snaps
     #CLOSE ALL SNAPS BEFORE RUNNING THIS
     set -eu
     LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
         while read snapname revision; do
             snap remove "$snapname" --revision="$revision"
         done
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search