I have an EC2 instance running my API, but I'm running out of space and can't restart it. I found that a lot of space is being used up by files named linux-modules, like linux-modules-5.15.0-1026-aws. Can anyone explain what these files do and if it's safe to delete them to free up some space?
3 Answers
Cleaning up space is always tricky! If those linux-modules belong to old kernels that you're not using anymore, it's generally safe to remove them. However, be cautious; if you accidentally delete modules for your currently running kernel, you might run into some serious issues. Also, consider other paths like /var/log or /tmp for additional cleanup. If you're not comfortable resizing disks or managing partitions, it might be easier to create a new server with more storage for your API instead.
You can definitely increase your EBS volume and resize the root volume without rebooting your instance. Just be careful about what files you delete; targeting places like /var/cache can help clear up some disk space.
I noticed that a bunch of large files are in usr/share/doc. Are those changelogs essential?
If you're using Ubuntu or a Debian-based system, you can clean up old kernel modules with the command `sudo apt-get autoremove --purge`. But remember, if your disk is already full, that might not work, so consider truncating some log files to create a bit of space first!
Good tip! I'll try that and see if I can buy some space before removing anything.

That makes sense! I just want to avoid breaking my setup, so I'll consider your advice.