I see that my /lib/modules taking so much space on CentOS 7 Linux box. It is like 300MB:
du -ch /lib/modules
Can i delete /lib/modules directory in Linux safely and what is the purpose of it?
I see that my /lib/modules taking so much space on CentOS 7 Linux box. It is like 300MB:
du -ch /lib/modules
Can i delete /lib/modules directory in Linux safely and what is the purpose of it?
No. Do not delete /lib/modules/ directory. It contains Linux kernel module i.e. Linux device drivers. Your system might not work as expected. What you can do is delete older unused Linux kernels.
Execute
uname -mrs
Sample outputs:
Linux 4.20.6-200.fc29.x86_64 x86_64
Run rpm command or yum command
rpm -qa | grep kernel-
OR
yum list installed 'kernel-*'
I am using the Linux kernel version 4.20.6-200. I am going to delete older kernel versions such as 4.20.5-200 and 4.20.4-200. Use yum command again to delete:
sudo yum erase kernel-4.20.5-200.fc29.x86_64 kernel-4.20.4-200.fc29.x86_64
I learned the hard way that if there are two folders there, you can’t manually delete one, the newer might be part of an unfinished transaction even. Do the version double check described here ubuntu - Can I delete folders in /lib/modules/ after calling "apt-get purge" - Server Fault
I think CentOS and Ubuntu/Debian treats kernel updates differently. At least that is what impression I am getting from the linked thread.