In my GCP instances, we have /usr/src directory that is taking more space on my disk. Is it mandatory to maintain those files.
We have multiple instances running in GCP. Every instance has a different size of /usr/src directory.
How can I remove files that aren't mandatory to keep?
This directory usually contains files with source code that is being used to compile drivers, applications or kernel. This is the default pleace where the OS will look for them when you try to compile anytyhing.
You say that in your case this directory takes up a lot of space on your system disk. You can do this with du /usr/src -sh
and you will see something like this:
me@local:~$ du /usr/src/ -sh
80M /usr/src/
You can remove those files (as a root you can do everything) but it's best not to do that manually. Try using sudo apt-get autoremove
and check with du
again how much space you just recovered.
If you want to free up some disk space you can have a look at this discussion to give you some ideas.
Or if it's not an issue you can increase your VM's disk size with gcloud
utility - after that you will have to increase the size of the partitions on this drive for the OS to actually "see" the difference.
Everything depends on your use case - it's up to you which solution you prefer.