Search code examples
linuxamazon-web-servicesamazon-ec2amazon-ecsrhel

Freeing some memory space on my Amazon Linux 2


I was doing testing on my server and always getting this error

 file for here-document: No space left on device
-bash: cannot create temp file for here-document: No space left on device

So I check it with the command "df".

Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs         1970540       0   1970540   0% /dev
tmpfs            1988952       0   1988952   0% /dev/shm
tmpfs            1988952   65980   1922972   4% /run
tmpfs            1988952       0   1988952   0% /sys/fs/cgroup
/dev/nvme0n1p1   8376300 8376280        20 100% /
tmpfs             397792      16    397776   1% /run/user/1000

I saw that the file /dev/nvme0n1p1 is using most of the memory. Is there any way I can free those memory? Or what can I do to have free some memory.


Solution

  • To free memory you can do the following:

    1. Check log files located in /var/log and empty any big log files.
    2. Install and configure logrotate tool to make sure that logs are will not consume disk space specially if you are using any webserver "Nginx, Apache for example".
    3. Remove unused packages and delete unused files.
    4. Use find command as the following: find / -size +100M | xargs du -sch this command will list big files and show it's size.