command to remove old headers
~$ sudo du -sh /usr/src/*
113M /usr/src/
...
(5GB)
...
114M /usr/src/
Is it possable to clean up that folder?
Our little VM OS disk is full and googling show that some of these headers are from 2018
I can't really find any documentation on what and how to clean.
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Manfred Hampl
- Solved:
- Last query:
- Last reply:
Revision history for this message
![]() |
#1 |
There is a mechanism to mark old kernel and header files as "automatically installed", such that they can be removed with the command
sudo apt --purge autoremove
Before you execute that command, I suggest that you test the function first by running
apt --simulate autoremove
In case that this does not work as desired, it will be necessary to dig further into details, e.g. by checking "apt-mark showmanual" etc.
Revision history for this message
![]() |
#2 |
What is the output of:
dpkg -l | awk '{print $2}' | grep header; lsb_release -a; uname -a
Thanks
Revision history for this message
![]() |
#3 |
dpkg -l | awk '{print $2}' | grep header; lsb_release -a; uname -a
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-azure-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-
linux-headers-azure
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
Linux [SERVER NAME] 4.15.0-1103-azure #114~16.04.1-Ubuntu SMP Wed Dec 16 02:39:42 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Revision history for this message
![]() |
#4 |
What output does the command
apt --simulate autoremove
produce?
Revision history for this message
![]() |
#5 |
Executing both the "simulate" and real call in PROD now
NOTE: It's a huge dump of almost 500 lines so I'm condencing it here
sudo apt --simulate autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-
...
linux-
linux-
...
linux-
linux-
linux-
...
linux-
linux-
linux-
...
linux-
linux-
...
linux-
linux-
...
linux-
linux-
linux-
...
linux-
linux-
...
linux-
linux-
0 upgraded, 0 newly installed, 389 to remove and 91 not upgraded.
Remv linux-cloud-
Remv linux-azure-
Remv linux-cloud-
Remv linux-azure-
...
Remv linux-cloud-
Remv linux-azure-
Remv linux-cloud-
Remv linux-azure-
...
Remv linux-cloud-
Remv linux-azure-
Remv linux-cloud-
Remv linux-azure-
...
Remv linux-cloud-
Remv linux-azure-
Remv linux-headers-
Remv linux-azure-
Remv linux-headers-
Remv linux-azure-
Remv linux-headers-
Remv linux-azure-
...
Remv linux-headers-
Remv linux-azure-
Remv linux-headers-
Remv linux-azure-
...
Remv linux-headers-
Remv linux-azure-
Remv linux-headers-
Remv linux-azure-
...
Remv linux-headers-
Remv linux-azure-
Remv linux-headers-
Remv linux-azure-
...
Remv linux-headers-
Remv linux-azure-
Remv linux-tools-
Remv linux-azure-
Remv linux-tools-
Remv linux-azure-
Remv linux-tools-
Remv linux-azure-
...
Remv linux-tools-
Remv linux-azure-
Remv linux-tools-
Remv linux-azure-
...
Remv linux-tools-
Remv linux-azure-
Remv linux-tools-
Remv linux-azure-
...
Remv linux-tools-
Remv linux-azure-
Remv linux-tools-
Remv linux-azure-
...
Remv linux-tools-
Remv linux-azure-
Remv linux-image-
Remv linux-image-
Remv linux-image-
Remv linux-image-
...
Remv linux-image-
Remv linux-image-
Remv linux-image-
Remv linux-image-
...
Remv linux-image-
Remv linux-image-
Remv linux-image-
Remv linux-image-
Remv linux-image-
Remv linux-image-
Remv linux-image-
...
Remv linux-image-
Remv linux-image-
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
...
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
...
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
Remv linux-modules-
...
Remv linux-modules-
Remv linux-modules-
Revision history for this message
![]() |
#6 |
All done
This is soooooooo much better. The little server is happy now.
sudo du -sh /usr/src/*
114M /usr/src/
114M /usr/src/
114M /usr/src/
16M /usr/src/
17M /usr/src/
17M /usr/src/
I'm good. thanks.
Any last queries before closing?
Revision history for this message
![]() |
#7 |
Just some remarks:
The command did not only remove obsolete header files, but also kernel images (from /boot) and modules (from /lib/modules/).
The command "sudo apt --purge autoremove" removes all versions of the kernel and header packages except the newest two and the package of the kernel version currently in use (if it's not within the newest two). In your case the two newest ones are 4.15.0-1112-azure and 4.15.0-1113-azure and the running kernel is 4.15.0-1103-azure.
It is good practice to periodically run "apt autoremove". You have to decide on the frequency in line with the way of operating your server (e.g. monthly, once a quarter).
Revision history for this message
![]() |
#8 |
Thanks Manfred Hampl, that solved my question.